mv site | lib config

This commit is contained in:
babayaga 2025-12-27 16:02:48 +01:00
parent 48458746a7
commit f6728daa6a
10 changed files with 713 additions and 25 deletions

View File

@ -0,0 +1,602 @@
{
"$ref": "#/definitions/library",
"definitions": {
"library": {
"type": "object",
"properties": {
"cart_id": {
"type": "string"
},
"code": {
"type": "string"
},
"price": {
"type": "number"
},
"cscartCats": {
"type": "array",
"items": {
"type": "number"
}
},
"cscartId": {
"type": "number"
},
"vendorId": {
"type": "number"
},
"shipping": {
"type": "object",
"properties": {
"price": {
"type": "number"
},
"transit": {
"type": "number"
},
"handling": {
"type": "number"
}
},
"additionalProperties": false,
"default": {
"price": 0,
"transit": 12,
"handling": 2
}
},
"replaced_by": {
"type": "string"
},
"alternatives": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"url": {
"type": "string"
},
"type": {
"type": "string"
}
},
"required": [
"name",
"url",
"type"
],
"additionalProperties": false
}
},
"used_by": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/alternatives/items"
}
},
"image": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"url": {
"type": "string"
},
"thumb": {
"type": "string"
},
"responsive": {
"type": "string"
},
"meta": {},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
},
"description": {
"type": "string"
},
"alt": {
"type": "string"
},
"title": {
"type": "string"
},
"height": {
"type": "number"
},
"width": {
"type": "number"
},
"order": {
"type": "number"
},
"exif": {
"type": "object",
"properties": {
"file": {},
"jfif": {},
"exif": {},
"gps": {}
},
"additionalProperties": false
}
},
"required": [
"url"
],
"additionalProperties": false
},
"name": {
"type": "string"
},
"edrawings": {
"type": "string"
},
"cad": {
"type": "array",
"items": {
"type": "object",
"properties": {
"file": {
"type": "string"
},
"name": {
"type": "string"
},
"configuration": {
"type": "string"
},
"step": {
"type": "string"
},
"model": {
"type": "string"
},
"html": {
"type": "string"
}
},
"required": [
"file",
"name",
"configuration"
],
"additionalProperties": false
},
"default": []
},
"manufacturing": {
"type": "object",
"properties": {
"lead_time": {
"type": "number"
}
},
"additionalProperties": false
},
"showDimensions": {
"type": "boolean"
},
"showParts": {
"type": "boolean"
},
"Preview3d": {
"type": "boolean"
},
"flags": {
"type": "number",
"default": 0
},
"slug": {
"type": "string"
},
"keywords": {
"type": "string"
},
"meta_keywords": {
"type": "string"
},
"version": {
"type": "string"
},
"versions": {
"type": "object",
"properties": {
"version": {
"type": "string"
},
"up": {
"type": "string"
},
"down": {
"type": "string"
},
"family": {
"type": "string"
},
"sheet": {
"type": "string"
}
},
"additionalProperties": false
},
"status": {
"type": "string"
},
"authors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"name",
"url"
],
"additionalProperties": false
}
},
"assets": {
"type": "object",
"properties": {
"gallery": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
},
"renderings": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
},
"components": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
},
"configurations": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
},
"showcase": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
},
"samples": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/image"
}
}
},
"additionalProperties": false,
"default": {
"gallery": [],
"renderings": [],
"components": [],
"configurations": [],
"showcase": [],
"samples": []
}
},
"resources": {
"type": "string"
},
"tests": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/alternatives/items"
},
"default": []
},
"download": {
"type": "boolean"
},
"gallery": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"glob": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"glob"
],
"additionalProperties": false
},
"default": {
"renderings": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
},
"gallery": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
},
"components": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
},
"configurations": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
},
"showcase": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
},
"samples": {
"glob": [
"*.+(JPG|jpg|png|PNG|gif)"
]
}
}
},
"components": {
"type": "array",
"items": {
"type": "object",
"properties": {
"cart_id": {
"$ref": "#/definitions/library/properties/cart_id"
},
"code": {
"$ref": "#/definitions/library/properties/code"
},
"price": {
"$ref": "#/definitions/library/properties/price"
},
"cscartCats": {
"$ref": "#/definitions/library/properties/cscartCats"
},
"cscartId": {
"$ref": "#/definitions/library/properties/cscartId"
},
"vendorId": {
"$ref": "#/definitions/library/properties/vendorId"
},
"shipping": {
"$ref": "#/definitions/library/properties/shipping"
},
"replaced_by": {
"$ref": "#/definitions/library/properties/replaced_by"
},
"alternatives": {
"$ref": "#/definitions/library/properties/alternatives"
},
"used_by": {
"$ref": "#/definitions/library/properties/used_by"
},
"image": {
"$ref": "#/definitions/library/properties/image"
},
"name": {
"$ref": "#/definitions/library/properties/name"
},
"edrawings": {
"$ref": "#/definitions/library/properties/edrawings"
},
"cad": {
"$ref": "#/definitions/library/properties/cad"
},
"manufacturing": {
"$ref": "#/definitions/library/properties/manufacturing"
},
"showDimensions": {
"$ref": "#/definitions/library/properties/showDimensions"
},
"showParts": {
"$ref": "#/definitions/library/properties/showParts"
},
"Preview3d": {
"$ref": "#/definitions/library/properties/Preview3d"
},
"flags": {
"$ref": "#/definitions/library/properties/flags"
},
"slug": {
"$ref": "#/definitions/library/properties/slug"
},
"keywords": {
"$ref": "#/definitions/library/properties/keywords"
},
"meta_keywords": {
"$ref": "#/definitions/library/properties/meta_keywords"
},
"version": {
"$ref": "#/definitions/library/properties/version"
},
"versions": {
"$ref": "#/definitions/library/properties/versions"
},
"status": {
"$ref": "#/definitions/library/properties/status"
},
"authors": {
"$ref": "#/definitions/library/properties/authors"
},
"assets": {
"$ref": "#/definitions/library/properties/assets"
},
"resources": {
"$ref": "#/definitions/library/properties/resources"
},
"tests": {
"$ref": "#/definitions/library/properties/tests"
},
"download": {
"$ref": "#/definitions/library/properties/download"
},
"gallery": {
"$ref": "#/definitions/library/properties/gallery"
},
"components": {
"$ref": "#/definitions/library/properties/components"
},
"howto_categories": {
"anyOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
"steps": {},
"sourceLanguage": {
"type": "string"
},
"category": {
"type": "string"
},
"product_dimensions": {
"type": "string"
},
"production": {
"type": "object",
"properties": {
"fusion-folder": {
"type": "string"
},
"nc-folder": {
"type": "string"
},
"cam": {
"type": "array",
"items": {
"$ref": "#/definitions/library/properties/authors/items"
}
}
},
"required": [
"fusion-folder",
"nc-folder",
"cam"
],
"additionalProperties": false
},
"score": {
"type": "number"
},
"body": {
"type": "string"
},
"features": {
"type": "string"
},
"highlights": {
"type": "string"
},
"specs": {
"type": "string"
},
"license": {
"type": "string"
},
"readme": {
"type": "string"
},
"shared": {
"type": "string"
}
},
"required": [
"code",
"name",
"manufacturing",
"slug",
"category"
],
"additionalProperties": true
},
"default": []
},
"howto_categories": {
"$ref": "#/definitions/library/properties/components/items/properties/howto_categories"
},
"steps": {
"$ref": "#/definitions/library/properties/components/items/properties/steps"
},
"sourceLanguage": {
"$ref": "#/definitions/library/properties/components/items/properties/sourceLanguage"
},
"category": {
"$ref": "#/definitions/library/properties/components/items/properties/category"
},
"product_dimensions": {
"$ref": "#/definitions/library/properties/components/items/properties/product_dimensions"
},
"production": {
"$ref": "#/definitions/library/properties/components/items/properties/production"
},
"score": {
"$ref": "#/definitions/library/properties/components/items/properties/score"
},
"body": {
"$ref": "#/definitions/library/properties/components/items/properties/body"
},
"features": {
"$ref": "#/definitions/library/properties/components/items/properties/features"
},
"highlights": {
"$ref": "#/definitions/library/properties/components/items/properties/highlights"
},
"specs": {
"$ref": "#/definitions/library/properties/components/items/properties/specs"
},
"license": {
"$ref": "#/definitions/library/properties/components/items/properties/license"
},
"readme": {
"$ref": "#/definitions/library/properties/components/items/properties/readme"
},
"shared": {
"$ref": "#/definitions/library/properties/components/items/properties/shared"
}
},
"required": [
"code",
"name",
"manufacturing",
"slug",
"category"
],
"additionalProperties": true
}
},
"$schema": "http://json-schema.org/draft-07/schema#"
}

View File

@ -23,7 +23,7 @@
"format": "unix-time" "format": "unix-time"
} }
], ],
"default": "2025-12-27T08:18:11.303Z" "default": "2025-12-27T15:01:58.480Z"
}, },
"description": { "description": {
"type": "string", "type": "string",

16
.astro/content.d.ts vendored
View File

@ -181,6 +181,14 @@ declare module 'astro:content' {
rendered?: RenderedContent; rendered?: RenderedContent;
filePath?: string; filePath?: string;
}>; }>;
"library": Record<string, {
id: string;
body?: string;
collection: "library";
data: InferEntrySchema<"library">;
rendered?: RenderedContent;
filePath?: string;
}>;
"resources": Record<string, { "resources": Record<string, {
id: string; id: string;
body?: string; body?: string;
@ -189,14 +197,6 @@ declare module 'astro:content' {
rendered?: RenderedContent; rendered?: RenderedContent;
filePath?: string; filePath?: string;
}>; }>;
"store": Record<string, {
id: string;
body?: string;
collection: "store";
data: InferEntrySchema<"store">;
rendered?: RenderedContent;
filePath?: string;
}>;
}; };

File diff suppressed because one or more lines are too long

91
library.json Normal file
View File

@ -0,0 +1,91 @@
{
"sheetpress": [
"products/sheetpress/cassandra-light",
"products/sheetpress/cassandra-mini",
"products/sheetpress/components/sprcb-650",
"products/sheetpress/components/sprcb-650-rc2",
"products/sheetpress/components/sprcb-650-light",
"products/sheetpress/cassandra-edcsm",
"products/sheetpress/cassandra-edczmax-rc2"
],
"injectors": [
"products/injection/katbot-pro-xl",
"products/injection/katbot-pro-mega-beta",
"products/injection/myriad-spring",
"products/injection/elena-zmax",
"products/injection/elena-zmax-rc1",
"products/injection/elena-zmax-motor-mod3"
],
"systems": [
"products/extrusion/systems/filament",
"products/extrusion/systems/pelletizer"
],
"extruders": [
"products/extrusion/components/202_FilamentHousing",
"products/extrusion/components/1100_Moulds/130x130x90-M10-L36",
"products/extrusion/components/101_lucy",
"products/extrusion/components/102_lucy-mini",
"products/extrusion/lydia-mini",
"products/extrusion/lydia-v3.5",
"products/extrusion/lydia-v4.5",
"products/extrusion/lydia-v4.6-ex",
"products/extrusion/lydia-v4.8",
"products/extrusion/components/102_lucy-mini",
"products/extrusion/lydia-print-head-v3"
],
"extruders-retail": [
"products/extrusion-ext/1600899413061"
],
"shredders": [
"products/shredder-ext/Obelix-XM-300",
"products/shredder-ext/Obelix-XM-500",
"products/shredder/idefix",
"products/shredder/obelix",
"products/shredder/components/shredder_v31-light",
"products/shredder/asterix-pp",
"products/shredder/asterix-sm",
"products/shredder/asterix-sm-morren"
],
"site-dev": [
"products/extrusion/systems/filament",
"products/extrusion/systems/pelletizer",
"products/extrusion/components/202_FilamentHousing",
"products/extrusion/components/1100_Moulds/130x130x90-M10-L36",
"products/extrusion/components/101_lucy",
"products/extrusion/components/102_lucy-mini",
"products/sheetpress/components/sprcb-650-rc2",
"products/sheetpress/components/sprcb-450-rc1",
"products/sheetpress/cassandra-light",
"products/sheetpress/cassandra-mini",
"products/sheetpress/cassandra-edc-450-rc1",
"products/sheetpress/cassandra-edczmax-rc2",
"products/sheetpress/cassandra-edczmax-rc2-1150ex",
"products/injection/elena-zmax-rc1",
"products/injection/katbot-pro-xl",
"products/extrusion/lydia-mini",
"products/extrusion/lydia-v3.5",
"products/extrusion/lydia-v4.5",
"products/shredder/idefix",
"products/shredder/obelix",
"products/shredder/components/shredder_v31-light"
],
"production": [
"products/sheetpress/cassandra-edczmax-rc2-1150ex"
],
"site-prod": [
"products/sheetpress/cassandra-edczmax-rc2",
"products/sheetpress/cassandra-edczmax-rc2-1150ex",
"products/injection/katbot-pro-xl",
"products/extrusion/lydia-v3.5",
"products/extrusion/lydia-v4.5",
"products/injection/elena-zmax-rc1",
"products/components/shared/electronics/enclosures/vintage-vertical-edc"
],
"site": [
"products/sheetpress/cassandra-edczmax-rc2",
"products/injection/katbot-pro-xl",
"products/injection/elena-zmax-rc1",
"products/extrusion/lydia-v3.5",
"products/extrusion/lydia-v4.5"
]
}

View File

@ -8,7 +8,7 @@ import { substitute } from "@polymech/commons/variables";
import { appConfigSchema } from "./config.schema.js"; import { appConfigSchema } from "./config.schema.js";
import type { AppConfig } from "./config.schema.js"; import type { AppConfig } from "./config.schema.js";
import { I18N_SOURCE_LANGUAGE } from "./constants.js" const I18N_SOURCE_LANGUAGE = 'en';
const LIBRARY_CONFIG_PATH = path.resolve("./app-config.json"); const LIBRARY_CONFIG_PATH = path.resolve("./app-config.json");
const USER_CONFIG_DEFAULT_PATH = path.resolve("./app-config.local.json"); const USER_CONFIG_DEFAULT_PATH = path.resolve("./app-config.local.json");
@ -51,8 +51,7 @@ export function loadConfig(
} }
const variables = { const variables = {
LANG: locale, LANG: locale
...process.env
}; };
const substitutedLibraryContent = substitute(false, rawLibraryContent, variables); const substitutedLibraryContent = substitute(false, rawLibraryContent, variables);

View File

@ -4,10 +4,8 @@ import { resolve, template } from '@polymech/commons'
import { sync as read } from '@polymech/fs/read' import { sync as read } from '@polymech/fs/read'
import { sanitizeUri } from 'micromark-util-sanitize-uri' import { sanitizeUri } from 'micromark-util-sanitize-uri'
import { loadConfig } from './config-loader.js' import { loadConfig } from './config-loader.js'
import { I18N_SOURCE_LANGUAGE } from "./constants.js"
export { I18N_SOURCE_LANGUAGE }
export const I18N_SOURCE_LANGUAGE = 'en'
// Load config // Load config
const config = loadConfig(I18N_SOURCE_LANGUAGE) const config = loadConfig(I18N_SOURCE_LANGUAGE)
@ -30,7 +28,7 @@ export const HOWTO_MIGRATION = () => path.resolve(resolve(config.products.howto_
// Products // Products
export const PRODUCT_ROOT = () => path.resolve(resolve(config.products.root)) export const PRODUCT_ROOT = () => path.resolve(resolve(config.products.root))
export const PRODUCT_BRANCHES = read(path.join(PRODUCT_ROOT(), 'config/machines.json'), 'json') export const PRODUCT_BRANCHES = read(path.join('.', 'library.json'), 'json')
export const PRODUCT_GLOB = config.products.glob export const PRODUCT_GLOB = config.products.glob
// Product compiler // Product compiler

View File

@ -25,7 +25,7 @@ const imagesSchema = z.object({
type Images = z.infer<typeof imagesSchema>; type Images = z.infer<typeof imagesSchema>;
import { loadConfig } from './config-loader.js' import { loadConfig } from './config-loader.js'
import { I18N_SOURCE_LANGUAGE } from "./constants.js" import { I18N_SOURCE_LANGUAGE } from "./config.js"
// Load config // Load config
const config = loadConfig(I18N_SOURCE_LANGUAGE) const config = loadConfig(I18N_SOURCE_LANGUAGE)

View File

@ -3,11 +3,8 @@ import { defineCollection, z } from "astro:content"
import { ComponentConfigSchema } from '@polymech/commons/component' import { ComponentConfigSchema } from '@polymech/commons/component'
import { loader } from '@polymech/astro-base/model/component.js' import { loader } from '@polymech/astro-base/model/component.js'
import { loader as howtoLoader } from './model/howto/howto.js' import { loader as howtoLoader } from './model/howto/howto.js'
import { loader as directorLoader } from './model/directory/item.js'
import { LIBARY_BRANCH } from '@/app/config.js'
const library = defineCollection({
const store = defineCollection({
loader: loader('site-dev') as any, loader: loader('site-dev') as any,
schema: ComponentConfigSchema.passthrough(), schema: ComponentConfigSchema.passthrough(),
}) })
@ -48,6 +45,7 @@ const directory = defineCollection({
}).passthrough() }).passthrough()
}) })
*/ */
const resources = defineCollection({ const resources = defineCollection({
loader: glob({ base: './src/content/resources', pattern: '*.{md,mdx}' }), loader: glob({ base: './src/content/resources', pattern: '*.{md,mdx}' }),
schema: z.object({ schema: z.object({
@ -64,7 +62,7 @@ const resources = defineCollection({
}); });
export const collections = { export const collections = {
store, library,
resources, resources,
//helpcenter, //helpcenter,
//infopages, //infopages,

View File

@ -5,7 +5,6 @@ import { LANGUAGES_PROD } from "config/config.js"
import StoreEntries from "@/components/store/StoreEntries.astro"; import StoreEntries from "@/components/store/StoreEntries.astro";
import BaseLayout from "@/layouts/BaseLayout.astro"; import BaseLayout from "@/layouts/BaseLayout.astro";
import Wrapper from "@polymech/astro-base/components/containers/Wrapper.astro"; import Wrapper from "@polymech/astro-base/components/containers/Wrapper.astro";
import Navigation from "@polymech/astro-base/components/global/Navigation.astro";
import Translate from "@polymech/astro-base/components/i18n.astro"; import Translate from "@polymech/astro-base/components/i18n.astro";
import { slugify } from "@polymech/astro-base/base/strings.js" import { slugify } from "@polymech/astro-base/base/strings.js"
@ -13,8 +12,9 @@ const view = 'library'
export async function getStaticPaths() export async function getStaticPaths()
{ {
const view = 'library' const view = 'library'
const allProducts = await getCollection('store') const allProducts = await getCollection(view)
const all: unknown[] = [] const all: unknown[] = []
LANGUAGES_PROD.forEach((lang) => { LANGUAGES_PROD.forEach((lang) => {