diff --git a/packages/imagetools_3/astroViteConfigs.js b/packages/imagetools_3/astroViteConfigs.js index 8b2d327..2f7b5cc 100644 --- a/packages/imagetools_3/astroViteConfigs.js +++ b/packages/imagetools_3/astroViteConfigs.js @@ -1,12 +1,12 @@ export default { - "environment": "dev", + "environment": "build", "isSsrBuild": false, "projectBase": "", "publicDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\public\\", "rootDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\", - "mode": "dev", - "outDir": "dist", - "assetsDir": "/_astro", + "mode": "production", + "outDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\dist\\", + "assetsDir": "_astro", "sourcemap": false, "assetFileNames": "/_astro/[name]@[width].[hash][extname]" } \ No newline at end of file diff --git a/packages/polymech/src/app/config.json b/packages/polymech/src/app/config.json index 8d982c6..47cfa79 100644 --- a/packages/polymech/src/app/config.json +++ b/packages/polymech/src/app/config.json @@ -1,8 +1,8 @@ { "site": { "title": "Polymech", - "base_url": "https://polymech.io/", - "description" : "", + "base_url": "https://polymech.info/", + "description": "", "base_path": "/", "trailing_slash": false, "favicon": "/images/favicon.png", @@ -17,51 +17,6 @@ "alt": "Astrofront" } }, - "footer_left": [ - { - "href": "/rss.xml", - "text": "RSS" - }, - { - "href": "/helpcenter/home", - "text": "Home" - }, - { - "href": "/infopages/dpa", - "text": "DPA" - }, - { - "href": "/infopages/cookies", - "text": "Cookies" - }, - { - "href": "/infopages/terms", - "text": "Terms" - }, - { - "href": "/infopages/privacy", - "text": "Privacy" - }, - { - "href": "/infopages/cookies", - "text": "Cookies" - }, - { - "href": "/forms/contact", - "text": "Contact" - }, - { - "href": "/infopages/about", - "text": "About us" - }, - { - "href": "/404", - "text": "Error 404" - } - ], - "footer_right": [ - - ], "settings": { "search": true, "account": true, @@ -101,10 +56,10 @@ "featured_products": "featured-products" } }, - "pages":{ - "home":{ + "pages": { + "home": { "hero": "https://assets.osr-plastic.org/machines//assets/newsletter/common/products/extruders/overview-3.jpg", - "_blog":{ + "_blog": { "store": "posts" } } diff --git a/packages/polymech/src/app/navigation.ts b/packages/polymech/src/app/navigation.ts index dc8fe1b..9d4b818 100644 --- a/packages/polymech/src/app/navigation.ts +++ b/packages/polymech/src/app/navigation.ts @@ -1,44 +1,37 @@ -import { translate } from '@/base/i18n.js' -import { I18N_SOURCE_LANGUAGE } from './config.js' -import config from "./config.json" with { "type": "json" } +import { translate } from '../base/i18n.js' +import { I18N_SOURCE_LANGUAGE } from 'config/config.js' +import { loadConfig } from './config-loader.js' import pMap from 'p-map' +const defaultMap = async (locale: string, items: { href: string, text: string }[]) => { + const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale) + return await pMap(items, async (item) => { + return { + "href": item.href, + "title": await _T(item.text), + "ariaLabel": item.text, + "class": "hover:text-orange-600" + } + }); + +} + export const items = async (opts: { locale: string }) => { - const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, opts.locale) - return [ - { - "href": `/${opts.locale}`, - "title": _T("Home"), - "ariaLabel": "Home", - "class": "hover:text-orange-600" - }, - { - "href": `/${opts.locale}/resources/home`, - "title": _T("Resources"), - "ariaLabel": "Resources", - "class": "hover:text-orange-600" - } - ] + const locale = opts.locale || I18N_SOURCE_LANGUAGE; + const config = loadConfig(locale); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return defaultMap(locale, config.navigation.top as any); + } + export const footer_left = async (locale: string) => { - const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale) - return await pMap(config.footer_left, async (item: any) => { - return { - "href": `${item.href}`, - "title": await _T(item.text), - "ariaLabel": item.text, - "class": "hover:text-orange-600" - } - }); + const config = loadConfig(locale); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return defaultMap(locale, config.footer_left as any); } + export const footer_right = async (locale: string) => { - const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale) - return await pMap(config.footer_right, async (item: any) => { - return { - "href": `/${item.href}`, - "title": await _T(item.text), - "ariaLabel": item.text, - "class": "hover:text-orange-600" - } - }); + const config = loadConfig(locale); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return defaultMap(locale, config.footer_right as any); } \ No newline at end of file diff --git a/packages/polymech/src/components/global/Navigation.astro b/packages/polymech/src/components/global/Navigation.astro index 42dc797..3657deb 100644 --- a/packages/polymech/src/components/global/Navigation.astro +++ b/packages/polymech/src/components/global/Navigation.astro @@ -1,8 +1,12 @@ --- import Wrapper from "@/components/containers/Wrapper.astro"; + import { I18N_SOURCE_LANGUAGE } from "@/app/config"; -import { items } from "config/navigation.js"; + +import { items } from "@/app/navigation.js"; + import ThemeToggle from "./ThemeToggle.astro"; + const locale = Astro.currentLocale || I18N_SOURCE_LANGUAGE; const navItems = await items({ locale }); ---