generated from polymech/site-template
cleanup
This commit is contained in:
parent
529d754e0a
commit
3c98cdebb9
@ -23,7 +23,7 @@
|
||||
"format": "unix-time"
|
||||
}
|
||||
],
|
||||
"default": "2025-03-22T23:21:27.575Z"
|
||||
"default": "2025-03-23T09:17:59.161Z"
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -20,6 +20,7 @@ import {
|
||||
HOWTO_FILES_WEB,
|
||||
HOWTO_FILES_ABS,
|
||||
I18N_SOURCE_LANGUAGE,
|
||||
HOWTO_COMPLETE_RESOURCES,
|
||||
} from "config/config.js";
|
||||
|
||||
interface Props {
|
||||
@ -27,16 +28,12 @@ interface Props {
|
||||
}
|
||||
const { howto } = Astro.props;
|
||||
const howto_abs = HOWTO_FILES_ABS(howto.slug);
|
||||
const howto_resources_default = `# Resources`;
|
||||
const howto_resources_path = path.join(howto_abs, "resources.md");
|
||||
let howto_resources = exists(howto_resources_path)
|
||||
? read(howto_resources_path, "string") || howto_resources_default
|
||||
: howto_resources_default;
|
||||
|
||||
let model_files: any = [...files(howto_abs, "**/**/*.(step|stp)")];
|
||||
model_files = model_files.map((f) =>
|
||||
forward_slash(`${howto.slug}/${path.relative(path.resolve(howto_abs), f)}`),
|
||||
);
|
||||
|
||||
const content = async (str: string) => {
|
||||
const ret = await translate(
|
||||
await applyFilters(str),
|
||||
@ -69,12 +66,25 @@ const authorGeo = howto?.user?.geo || {
|
||||
const authorLinks = (howto?.user?.data.urls || []).filter(
|
||||
(l) => !l.url.includes("one_army") && !l.url.includes("bazar"),
|
||||
);
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Add references from the extracted keywords
|
||||
const contentAll = `${howto.title} \n Description : ${howto.description} \n Steps: ${howto.steps.map((s) => s.text).join("\n")} \n`;
|
||||
const keywords = await extract(contentAll) as string;
|
||||
const references_extra = await references(keywords);
|
||||
howto_resources = `${howto_resources}\n${references_extra}`;
|
||||
//
|
||||
// Resources
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
const howto_resources_default = `# Resources`;
|
||||
const howto_resources_path = path.join(howto_abs, "resources.md");
|
||||
|
||||
let howto_resources = exists(howto_resources_path)
|
||||
? read(howto_resources_path, "string") || howto_resources_default
|
||||
: howto_resources_default;
|
||||
|
||||
if (HOWTO_COMPLETE_RESOURCES) {
|
||||
const contentAll = `${howto.title} \n Description : ${howto.description} \n Steps: ${howto.steps.map((s) => s.text).join("\n")} \n`;
|
||||
const keywords = (await extract(contentAll)) as string;
|
||||
const references_extra = await references(keywords);
|
||||
howto_resources = `${howto_resources}\n${references_extra}`;
|
||||
}
|
||||
const Resources = component(howto_resources);
|
||||
---
|
||||
|
||||
|
||||
@ -23,11 +23,15 @@ export const I18N_ASSET_PATH = "${SRC_DIR}/${SRC_NAME}-${DST_LANG}${SRC_EXT}"
|
||||
export const HOWTO_GLOB = '**/config.json'
|
||||
export const FILES_WEB = 'https://files.polymech.io/files/machines/howtos/'
|
||||
export const HOWTO_FILTER_LLM = false
|
||||
export const HOWTO_ROOT = () => path.resolve(resolve("./public/resources/howtos"))
|
||||
export const HOWTO_COMPLETE_RESOURCES = false
|
||||
|
||||
export const HOWTO_ROOT_INTERN = () => path.resolve(resolve("./public/resources/howtos"))
|
||||
|
||||
export const HOWTO_ROOT = () => path.resolve(resolve("${OSR_ROOT}/osr-machines/howtos"))
|
||||
|
||||
export const HOWTO_FILES_ABS = (id) => `${HOWTO_ROOT()}/${id}`
|
||||
export const HOWTO_FILES_WEB = (id: string) => `${FILES_WEB}/${id}`
|
||||
|
||||
|
||||
// Products
|
||||
export const PRODUCT_ROOT = () => path.resolve(resolve("${OSR_ROOT}/products"))
|
||||
export const PRODUCT_BRANCHES = read(path.join(PRODUCT_ROOT(), 'config/machines.json'), 'json')
|
||||
|
||||
@ -2,9 +2,7 @@ import * as path from 'path'
|
||||
import { findUp } from 'find-up'
|
||||
import { sync as read } from '@polymech/fs/read'
|
||||
import { sync as exists } from '@polymech/fs/exists'
|
||||
import { filesEx, resolveConfig, resolve } from '@polymech/commons'
|
||||
import { ICADNodeSchema, IComponentConfig } from '@polymech/commons/component'
|
||||
import { RenderedContent, DataEntry } from "astro:content"
|
||||
|
||||
import type { Loader, LoaderContext } from 'astro/loaders'
|
||||
import { sanitizeFilename } from "@polymech/fs/utils"
|
||||
import { filter as language } from "@/base/kbot.js";
|
||||
@ -12,31 +10,16 @@ import {
|
||||
HOWTO_FILES_WEB,
|
||||
HOWTO_FILES_ABS,
|
||||
HOWTO_FILTER_LLM,
|
||||
HOWTO_COMPLETE_RESOURCES
|
||||
} from "config/config.js";
|
||||
|
||||
import {
|
||||
CAD_MAIN_MATCH, PRODUCT_BRANCHES,
|
||||
CAD_EXTENSIONS, CAD_MODEL_EXT, PRODUCT_DIR, PRODUCT_GLOB,
|
||||
PRODUCT_ROOT, CAD_EXPORT_CONFIGURATIONS,
|
||||
CAD_DEFAULT_CONFIGURATION,
|
||||
CAD_URL,
|
||||
parseBoolean,
|
||||
DEFAULT_CONTACT,
|
||||
default_image,
|
||||
HOWTO_ROOT,
|
||||
HOWTO_GLOB
|
||||
} from 'config/config.js'
|
||||
|
||||
import { env } from '@/base/index.js'
|
||||
import { gallery } from '@/base/media.js';
|
||||
|
||||
import { PFilterValid } from '@polymech/commons/filter'
|
||||
|
||||
import { IAssemblyData } from '@polymech/cad'
|
||||
import { logger as log } from '@/base/index.js'
|
||||
import { translate } from "@/base/i18n.js"
|
||||
import { I18N_SOURCE_LANGUAGE } from "config/config.js"
|
||||
|
||||
import { slugify } from "@/base/strings.js"
|
||||
import { got } from 'got'
|
||||
import pMap from 'p-map'
|
||||
@ -135,7 +118,7 @@ const onItem = async (store: any, ctx: LoaderContext) => {
|
||||
alt: image.name || ''
|
||||
};
|
||||
}, {
|
||||
concurrency: 3
|
||||
concurrency: 1
|
||||
});
|
||||
return step;
|
||||
}, { concurrency: 1 })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user