feat(tools): complete 12-tool suite across all categories and fluid category listing navigation
This commit is contained in:
+24
-25
@@ -51,32 +51,8 @@ export function getPageConfig(slug: string): PageConfig | null {
|
||||
|
||||
export function getAllTools(): ToolItem[] {
|
||||
toolsCache.clear();
|
||||
// 1. Prioritize management/pages/tools/[slug]/tool.config.json
|
||||
const mgmtToolsDir = path.join(MANAGEMENT_DIR, 'pages', 'tools');
|
||||
if (fs.existsSync(mgmtToolsDir)) {
|
||||
const slugs = fs.readdirSync(mgmtToolsDir);
|
||||
const tools: ToolItem[] = [];
|
||||
for (const slug of slugs) {
|
||||
const configPath = path.join(mgmtToolsDir, slug, 'tool.config.json');
|
||||
if (fs.existsSync(configPath)) {
|
||||
const tool = readJsonFile<any>(configPath);
|
||||
if (tool && tool.status === 'published') {
|
||||
// Normalize media paths so before/after point to live management media
|
||||
if (tool.media?.before && tool.content?.examples?.[0]) {
|
||||
tool.content.examples[0].before = tool.media.before;
|
||||
}
|
||||
if (tool.media?.after && tool.content?.examples?.[0]) {
|
||||
tool.content.examples[0].after = tool.media.after;
|
||||
}
|
||||
tools.push(tool);
|
||||
toolsCache.set(tool.slug, tool);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tools.length > 0) return tools;
|
||||
}
|
||||
|
||||
// 2. Fallback to content/collections/tools
|
||||
// 1. Load baseline from content/collections/tools
|
||||
const toolsDir = path.join(CONTENT_DIR, 'collections', 'tools');
|
||||
if (fs.existsSync(toolsDir)) {
|
||||
const files = fs.readdirSync(toolsDir).filter((f) => f.endsWith('.json'));
|
||||
@@ -87,6 +63,29 @@ export function getAllTools(): ToolItem[] {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Layer management/pages/tools/[slug]/tool.config.json on top
|
||||
const mgmtToolsDir = path.join(MANAGEMENT_DIR, 'pages', 'tools');
|
||||
if (fs.existsSync(mgmtToolsDir)) {
|
||||
const slugs = fs.readdirSync(mgmtToolsDir);
|
||||
for (const slug of slugs) {
|
||||
const configPath = path.join(mgmtToolsDir, slug, 'tool.config.json');
|
||||
if (fs.existsSync(configPath)) {
|
||||
const mgmtTool = readJsonFile<any>(configPath);
|
||||
if (mgmtTool && mgmtTool.status === 'published') {
|
||||
// Normalize media paths so before/after point to live management media
|
||||
if (mgmtTool.media?.before && mgmtTool.content?.examples?.[0]) {
|
||||
mgmtTool.content.examples[0].before = mgmtTool.media.before;
|
||||
}
|
||||
if (mgmtTool.media?.after && mgmtTool.content?.examples?.[0]) {
|
||||
mgmtTool.content.examples[0].after = mgmtTool.media.after;
|
||||
}
|
||||
toolsCache.set(mgmtTool.slug, mgmtTool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(toolsCache.values());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user