footer | json-ld | content

This commit is contained in:
lovebird 2025-03-12 08:56:48 +01:00
parent 05ecfbf384
commit f91332c7a6
17 changed files with 2087 additions and 76 deletions

View File

@ -296,11 +296,7 @@
} }
}, },
"resources": { "resources": {
"type": "array", "type": "string"
"items": {
"$ref": "#/definitions/projects/properties/alternatives/items"
},
"default": []
}, },
"tests": { "tests": {
"type": "array", "type": "array",
@ -413,6 +409,27 @@
}, },
"score": { "score": {
"type": "number" "type": "number"
},
"body": {
"type": "string"
},
"features": {
"type": "string"
},
"highlights": {
"type": "string"
},
"specs": {
"type": "string"
},
"license": {
"type": "string"
},
"readme": {
"type": "string"
},
"shared": {
"type": "string"
} }
}, },
"required": [ "required": [

View File

@ -296,11 +296,7 @@
} }
}, },
"resources": { "resources": {
"type": "array", "type": "string"
"items": {
"$ref": "#/definitions/store/properties/alternatives/items"
},
"default": []
}, },
"tests": { "tests": {
"type": "array", "type": "array",
@ -413,6 +409,27 @@
}, },
"score": { "score": {
"type": "number" "type": "number"
},
"body": {
"type": "string"
},
"features": {
"type": "string"
},
"highlights": {
"type": "string"
},
"specs": {
"type": "string"
},
"license": {
"type": "string"
},
"readme": {
"type": "string"
},
"shared": {
"type": "string"
} }
}, },
"required": [ "required": [

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
export default { export default {
"environment": "dev", "environment": "build",
"isSsrBuild": false, "isSsrBuild": false,
"projectBase": "", "projectBase": "",
"publicDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\public\\", "publicDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\public\\",
"rootDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\", "rootDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\",
"mode": "dev", "mode": "production",
"outDir": "dist", "outDir": "C:\\Users\\zx\\Desktop\\polymech\\polymech-site\\dist\\",
"assetsDir": "/_astro", "assetsDir": "_astro",
"sourcemap": false, "sourcemap": false,
"assetFileNames": "/_astro/[name]@[width].[hash][extname]" "assetFileNames": "/_astro/[name]@[width].[hash][extname]"
} }

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,8 @@
"image": { "image": {
"default": "/images/default-image.png", "default": "/images/default-image.png",
"error": "/images/error-image.png", "error": "/images/error-image.png",
"alt": "Astrofront" "alt": "Astrofront",
"src": "https://assets.osr-plastic.org/machines//assets/newsletter/common/products/extruders/overview-3.jpg"
} }
}, },
"footer_left": [ "footer_left": [
@ -25,6 +26,10 @@
{ {
"href": "/infopages/contact", "href": "/infopages/contact",
"text": "Contact" "text": "Contact"
} ,
{
"href": "/newsletter/newsletter_2024_09_en-hugo-release.html",
"text": "Newsletter"
} }
], ],
"footer_right": [ "footer_right": [

View File

@ -20,25 +20,22 @@ export const items = async (opts: { locale: string }) => {
} }
] ]
} }
export const footer_left = async ( locale: string ) => { const isAbsoluteUrl = (url: string): boolean => /^[a-zA-Z]+:/.test(url);
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale)
return await pMap(config.footer_left, async (item) => { const createFooterLinks = async (items: any[], locale: string) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale);
return await pMap(items, async (item) => {
const translatedText = await _T(item.text); // Single translation call
return { return {
"href": `/${locale}${item.href}`, "href": isAbsoluteUrl(item.href) ? item.href : `/${locale}${item.href}`,
"title": await _T(item.text), "title": translatedText, // Use cached translation
"ariaLabel": item.text, "ariaLabel": translatedText, // Use cached translation
"class": "hover:text-orange-600" "class": "hover:text-orange-600"
} };
}); });
} };
export const footer_right = async ( locale: string ) => {
const _T = async (text: string) => await translate(text, I18N_SOURCE_LANGUAGE, locale) export const footer_left = (locale: string) => createFooterLinks(config.footer_left, locale);
return await pMap(config.footer_right, async (item) => { export const footer_right = (locale: string) => createFooterLinks(config.footer_right, locale);
return {
"href": `/${item.href}`,
"title": await _T(item.text),
"ariaLabel": item.text,
"class": "hover:text-orange-600"
}
});
}

View File

@ -16,10 +16,6 @@ import StructuredData from './head/ArticleStructuredData.astro'
import Hreflang from '@/components/polymech/hreflang.astro' import Hreflang from '@/components/polymech/hreflang.astro'
import { IComponentConfig } from "@polymech/commons" import { IComponentConfig } from "@polymech/commons"
// Determine the path to your compiled Tailwind CSS.
// Assuming your built Tailwind CSS ends up in 'global.css' in your public directory after Astro build.
const tailwindCSSPath = "/global.css"; // <- **Important: Verify this path after your build process**
export interface Props { export interface Props {
title?: string; title?: string;
meta_title?: string; meta_title?: string;
@ -51,7 +47,7 @@ const hreflangs = LANGUAGES_PROD.filter((lang)=>lang!==Astro.currentLocale).map(
})) }))
const image = item?.image || config.site.image const image = item?.image || config.site.image
const image_url = image.url const image_url = image.src
const image_alt = image.alt const image_alt = image.alt
const title = item?.title as string || config.site.title || "" const title = item?.title as string || config.site.title || ""

View File

@ -74,11 +74,11 @@ const filteredGroups: Record<
return acc; return acc;
}, {}); }, {});
const extraContent = [data.extra_resources, data.tests] const extraContent = [data.resources, data.tests]
.filter((s) => s && s.length) .filter((s) => s && s.length)
.map(createMarkdownComponent) .map(createMarkdownComponent)
const sharedContent = [data.shared_resources] const sharedContent = [data.shared]
.filter((s) => s && s.length) .filter((s) => s && s.length)
.map(createMarkdownComponent) .map(createMarkdownComponent)
--- ---

View File

@ -2,7 +2,7 @@
import BaseHead from "../components/BaseHead.astro"; import BaseHead from "../components/BaseHead.astro";
import Navigation from "../components/global/Navigation.astro"; import Navigation from "../components/global/Navigation.astro";
import Footer from "../components/global/Footer.astro"; import Footer from "../components/global/Footer.astro";
import { I18N_SOURCE_LANGUAGE, isRTL } from "config/config.js" import { isRTL } from "config/config.js"
const { frontmatter: frontmatter, additionalKeywords, ...rest } = Astro.props; const { frontmatter: frontmatter, additionalKeywords, ...rest } = Astro.props;

View File

@ -43,8 +43,9 @@ import {
} from "config/config.js"; } from "config/config.js";
const { frontmatter: item, ...rest } = Astro.props; const { frontmatter: item, ...rest } = Astro.props;
const content = await translate( const content = await translate(
item.content || "", item.body || "",
I18N_SOURCE_LANGUAGE, I18N_SOURCE_LANGUAGE,
Astro.currentLocale, Astro.currentLocale,
); );

View File

@ -184,22 +184,10 @@ const onItem = async (item: IStoreItem, ctx: ILoaderContextEx) => {
renderings: [], renderings: [],
gallery: [] gallery: []
} }
//////////////////////////////////////////
// data.body = (read(path.join(itemDir, 'templates/shared', 'body.md')) as string) || ""
// Body data.resources = (read(path.join(itemDir, 'templates/shared', 'resources.md')) as string) || ""
//
let contentPath = path.join(itemDir, 'templates/shared', 'body.md')
await getRenderFunction(contentPath)
if (exists(contentPath)) {
data.content = read(contentPath) as string
item.filePath = contentPath
}
//////////////////////////////////////////
//
// Item Extra Resources
//
let resourcesPath = path.join(itemDir, 'templates/shared', 'resources.md')
exists(resourcesPath) && (data.extra_resources = read(resourcesPath) as string || "")
////////////////////////////////////////// //////////////////////////////////////////
// //
// Item Shared Resources // Item Shared Resources
@ -208,15 +196,13 @@ const onItem = async (item: IStoreItem, ctx: ILoaderContextEx) => {
stopAt: PRODUCT_ROOT(), stopAt: PRODUCT_ROOT(),
cwd: itemDir cwd: itemDir
}) || "" }) || ""
exists(resourcesDefaultPath) && (data.shared_resources = read(resourcesDefaultPath) as string || "") data.shared = (read(resourcesDefaultPath) as string) || ""
////////////////////////////////////////// //////////////////////////////////////////
// //
// Readme // Readme
// //
let readmePath = path.join(itemDir, 'Readme.md') let readmePath = path.join(itemDir, 'Readme.md')
if (exists(readmePath)) { data.readme = (read(readmePath) as string) || ""
data.readme = read(readmePath) as string
}
////////////////////////////////////////// //////////////////////////////////////////
// //
// Variables // Variables
@ -252,16 +238,14 @@ const onItem = async (item: IStoreItem, ctx: ILoaderContextEx) => {
data.assets.renderings = await gallery('renderings', data.rel) as [] data.assets.renderings = await gallery('renderings', data.rel) as []
data.assets.renderings.length && (data.thumbnail = data.assets.renderings.length && (data.thumbnail =
{ {
alt: '', alt: data.assets.renderings[0].alt,
url: data.assets.renderings[0].thumb, url: data.assets.renderings[0].url,
src: data.assets.renderings[0].thumb src: data.assets.renderings[0].url
}) })
data.assets.gallery = await gallery('media/gallery', data.rel) as [] data.assets.gallery = await gallery('media/gallery', data.rel) as []
data.image = data.assets.renderings[0] || {} data.image = data.assets.renderings[0] || {}
data.assets.showcase = await gallery('media/showcase', data.rel) as [] data.assets.showcase = await gallery('media/showcase', data.rel) as []
data.assets.samples = await gallery('media/samples', data.rel) as [] data.assets.samples = await gallery('media/samples', data.rel) as []
} }
export function loader(branch: string): Loader { export function loader(branch: string): Loader {
@ -281,12 +265,13 @@ export function loader(branch: string): Loader {
const id = product.slug; const id = product.slug;
const data = { const data = {
rel: item.rel, rel: item.rel,
title: product.name,
slug: id, slug: id,
id,
title: product.name,
type: 'product', type: 'product',
highlights: [], highlights: [],
components: [], components: [],
...product ...product,
} }
//const parsedData = await parseData({ id, data: data }); //const parsedData = await parseData({ id, data: data });
const storeItem = { const storeItem = {
@ -304,9 +289,11 @@ export function loader(branch: string): Loader {
generateDigest, generateDigest,
entryTypes entryTypes
} as any) } as any)
storeItem.data['config'] = JSON.stringify({ storeItem.data['config'] = JSON.stringify({
...storeItem.data ...storeItem.data
}, null, 2) }, null, 2)
store.set(storeItem) store.set(storeItem)
} }
} }

View File

@ -59,11 +59,15 @@ export const get = async (node: IComponentNode, component: IComponentConfig, opt
url?: string url?: string
}): Promise<ProductJsonLD> => { }): Promise<ProductJsonLD> => {
if(!component.price || !component.body){
return {} as any
}
const jsonLD: ProductJsonLD = { const jsonLD: ProductJsonLD = {
'@context': 'https://schema.org', '@context': 'https://schema.org',
'@type': 'Product', '@type': 'Product',
name: component.name, name: component.name,
description: component.keywords, description: component.body || component.keywords,
sku: component.code, sku: component.code,
brand: { brand: {
'@type': 'Brand', '@type': 'Brand',

View File

@ -3,6 +3,7 @@ import BaseLayout from "@/layouts/BaseLayout.astro";
import Wrapper from "@/components/containers/Wrapper.astro"; import Wrapper from "@/components/containers/Wrapper.astro";
import { LANGUAGES_PROD } from "config/config.js"; import { LANGUAGES_PROD } from "config/config.js";
import config from "config/config.json";
import { getCollection } from "astro:content"; import { getCollection } from "astro:content";
import StoreEntries from "@/components/store/StoreEntries.astro"; import StoreEntries from "@/components/store/StoreEntries.astro";
import CtaOne from "@/components/cta/CtaOne.astro"; import CtaOne from "@/components/cta/CtaOne.astro";
@ -26,9 +27,19 @@ export function getStaticPaths() {
return all; return all;
} }
const groups = await group_by_path(items, locale); const groups = await group_by_path(items, locale);
const frontmatter = {
title: "Store",
description: "Store",
keywords: "Store",
image:{
src: config.pages.home.hero,
url: config.pages.home.hero,
alt: config.metadata.keywords
}
};
--- ---
<BaseLayout> <BaseLayout frontmatter={frontmatter}>
<Wrapper variant="standard" class="py-4"> <Wrapper variant="standard" class="py-4">
<CtaOne /> <CtaOne />
<section> <section>

View File

@ -31,5 +31,13 @@ const locale = Astro.currentLocale || "en"
</div> </div>
</section> </section>
{ <script>
const currentPath = window.location.pathname;
if (!/^\/[a-z]{2}(\/|$)/i.test(currentPath)) {
let language = navigator.language
language = language.split('-')[0]
language = "en"
window.location.href = `/${language}`;
}
</script>
</BaseLayout> </BaseLayout>

View File

@ -0,0 +1 @@
TEST,TEST
1 TEST TEST

View File

@ -0,0 +1,10 @@
{
"glossaryId": "94f02b66-2ee8-4119-a8d7-e0a11dd8992d",
"name": "OSR-en-pt",
"ready": true,
"sourceLang": "en",
"targetLang": "pt",
"creationTime": "2025-03-11T22:17:00.006Z",
"entryCount": 1,
"hash": "zDrlayXO43sB98wNoqof0g=="
}