qarpeo 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import 'drizzle-orm/node-sqlite';
|
|
|
19
19
|
import 'node:process';
|
|
20
20
|
import 'node:readline/promises';
|
|
21
21
|
|
|
22
|
-
const version = "0.1.
|
|
22
|
+
const version = "0.1.3";
|
|
23
23
|
|
|
24
24
|
function ensureDevEnv(rootDir) {
|
|
25
25
|
const envPath = join(rootDir, ".env");
|
|
@@ -279,7 +279,7 @@ async function resolveAllCmsSources(options) {
|
|
|
279
279
|
await downloadTemplate(src.from, {
|
|
280
280
|
dir: targetDir,
|
|
281
281
|
preferOffline: true,
|
|
282
|
-
auth: process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
282
|
+
auth: src.token || process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
283
283
|
});
|
|
284
284
|
resolvedDir = targetDir;
|
|
285
285
|
} catch (err) {
|
|
@@ -323,7 +323,7 @@ async function resolveAllCmsSources(options) {
|
|
|
323
323
|
await downloadTemplate(src.from, {
|
|
324
324
|
dir: targetDir,
|
|
325
325
|
preferOffline: true,
|
|
326
|
-
auth: process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
326
|
+
auth: src.token || process.env.GITHUB_TOKEN || process.env.GH_TOKEN
|
|
327
327
|
});
|
|
328
328
|
resolvedDir = targetDir;
|
|
329
329
|
} catch (err) {
|
|
@@ -439,14 +439,17 @@ async function scanContentEntries(options) {
|
|
|
439
439
|
if (navMeta.private === true || navMeta.draft === true || navMeta.exclude === true) {
|
|
440
440
|
return;
|
|
441
441
|
}
|
|
442
|
-
const
|
|
443
|
-
const
|
|
444
|
-
|
|
442
|
+
const relSegments = relBase ? relBase.split("/").filter(Boolean) : [];
|
|
443
|
+
const isTopLevelSection = Boolean(
|
|
444
|
+
relSegments.length === 1 || relSegments.length === 2 && (relSegments[0].includes("docs") || collectionsConfig[stripOrderPrefix(relSegments[0])])
|
|
445
|
+
);
|
|
446
|
+
const currentSectionNavMeta = isTopLevelSection ? {
|
|
447
|
+
title: navMeta.title || stripOrderPrefix(relSegments[relSegments.length - 1]).charAt(0).toUpperCase() + stripOrderPrefix(relSegments[relSegments.length - 1]).slice(1).replace(/-/g, " "),
|
|
445
448
|
icon: navMeta.icon,
|
|
446
|
-
order: navMeta.order ?? extractOrderPrefix(
|
|
449
|
+
order: navMeta.order ?? extractOrderPrefix(relSegments[relSegments.length - 1]),
|
|
447
450
|
navigation: navMeta.navigation,
|
|
448
451
|
hidden: navMeta.hidden
|
|
449
|
-
} :
|
|
452
|
+
} : sectionNavMeta;
|
|
450
453
|
for (const item of dirItems) {
|
|
451
454
|
if (item.name.startsWith(".") || item.name.startsWith("_")) continue;
|
|
452
455
|
const subRel = relBase ? `${relBase}/${item.name}` : item.name;
|
|
@@ -526,7 +529,7 @@ async function scanContentEntries(options) {
|
|
|
526
529
|
const itemOrder = typeof fm.order === "number" ? fm.order : isIndex ? 0 : fileNum != null ? fileNum : 100 + orderCounter++;
|
|
527
530
|
const groupOrderOffset = typeof groupMeta?.order === "number" ? groupMeta.order * 100 : 0;
|
|
528
531
|
const finalOrder = folderOrder + subfolderOffset + groupOrderOffset + itemOrder;
|
|
529
|
-
const itemTitle = fm.title || (isIndex ? navMeta.title || title : title);
|
|
532
|
+
const itemTitle = fm.navigation?.title || fm.title || (isIndex ? navMeta.title || title : title);
|
|
530
533
|
const effectiveSection = currentSectionNavMeta?.title ? { title: currentSectionNavMeta.title, icon: currentSectionNavMeta.icon } : navMeta.title ? { title: navMeta.title, icon: navMeta.icon } : void 0;
|
|
531
534
|
const isDraft = Boolean(
|
|
532
535
|
fm.draft === true || fm.private === true || fm.status === "draft" || navMeta.draft === true || navMeta.private === true
|
|
@@ -570,6 +573,54 @@ async function scanContentEntries(options) {
|
|
|
570
573
|
created_at: now,
|
|
571
574
|
updated_at: now
|
|
572
575
|
});
|
|
576
|
+
} else if (item.isFile() && (item.name.endsWith(".json") || item.name.endsWith(".yaml") || item.name.endsWith(".yml"))) {
|
|
577
|
+
if (item.name.startsWith(".navigation.") || item.name === ".sources.json") continue;
|
|
578
|
+
const filePath = `${dir}/${item.name}`;
|
|
579
|
+
let rawContent = "";
|
|
580
|
+
try {
|
|
581
|
+
rawContent = await readFile(filePath, "utf8");
|
|
582
|
+
} catch {
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
const fileHash = computeContentHash(rawContent);
|
|
586
|
+
let parsed = {};
|
|
587
|
+
if (item.name.endsWith(".json")) {
|
|
588
|
+
try {
|
|
589
|
+
parsed = JSON.parse(rawContent);
|
|
590
|
+
} catch {
|
|
591
|
+
}
|
|
592
|
+
} else {
|
|
593
|
+
try {
|
|
594
|
+
parsed = parse(rawContent) || {};
|
|
595
|
+
} catch {
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) continue;
|
|
599
|
+
const colId = item.name.replace(/\.(json|ya?ml)$/, "").toLowerCase();
|
|
600
|
+
const slug = parsed.slug || colId;
|
|
601
|
+
const entryPath = `/${colId}`;
|
|
602
|
+
const title = parsed.title || colId.charAt(0).toUpperCase() + colId.slice(1);
|
|
603
|
+
const description = parsed.description || null;
|
|
604
|
+
entries.push({
|
|
605
|
+
collection_id: colId,
|
|
606
|
+
slug,
|
|
607
|
+
path: entryPath,
|
|
608
|
+
title,
|
|
609
|
+
description,
|
|
610
|
+
cover_image: parsed.coverImage || parsed.cover_image || null,
|
|
611
|
+
tags: Array.isArray(parsed.tags) ? parsed.tags.join(",") : parsed.tags || null,
|
|
612
|
+
order: typeof parsed.order === "number" ? parsed.order : 0,
|
|
613
|
+
content_md: "",
|
|
614
|
+
content_html: "",
|
|
615
|
+
metadata_json: JSON.stringify(parsed),
|
|
616
|
+
status: "published",
|
|
617
|
+
source: "file",
|
|
618
|
+
file_path: filePath,
|
|
619
|
+
content_hash: fileHash,
|
|
620
|
+
published_at: now,
|
|
621
|
+
created_at: now,
|
|
622
|
+
updated_at: now
|
|
623
|
+
});
|
|
573
624
|
}
|
|
574
625
|
}
|
|
575
626
|
};
|
|
@@ -135,7 +135,7 @@ export function queryCollection(collection) {
|
|
|
135
135
|
_path = p;
|
|
136
136
|
if (_targetCollection === "content") {
|
|
137
137
|
const parts = p.replace(/^\//, "").split("/");
|
|
138
|
-
if (parts.length
|
|
138
|
+
if (parts.length >= 1 && parts[0]) {
|
|
139
139
|
_targetCollection = parts[0];
|
|
140
140
|
}
|
|
141
141
|
}
|
|
@@ -3013,8 +3013,9 @@ export async function getCMSNavigationTree(event, collectionId, options) {
|
|
|
3013
3013
|
const sectionPath = segments.length >= 2 ? `/${segments[0]}/${segments[1]}` : entryPath;
|
|
3014
3014
|
const defaultSectionTitle = segments.length >= 2 ? segments[1].charAt(0).toUpperCase() + segments[1].slice(1).replace(/-/g, " ") : r.title;
|
|
3015
3015
|
if (!sectionsMap.has(sectionPath)) {
|
|
3016
|
+
const initialTitle = sectionMeta.title && sectionMeta.title !== "Docs" ? sectionMeta.title : defaultSectionTitle;
|
|
3016
3017
|
sectionsMap.set(sectionPath, {
|
|
3017
|
-
title:
|
|
3018
|
+
title: initialTitle,
|
|
3018
3019
|
path: sectionPath,
|
|
3019
3020
|
icon: sectionMeta.icon,
|
|
3020
3021
|
children: [],
|
|
@@ -3022,8 +3023,17 @@ export async function getCMSNavigationTree(event, collectionId, options) {
|
|
|
3022
3023
|
});
|
|
3023
3024
|
}
|
|
3024
3025
|
const section = sectionsMap.get(sectionPath);
|
|
3025
|
-
const itemTitle = meta._itemTitle || r.title;
|
|
3026
|
-
if (
|
|
3026
|
+
const itemTitle = meta.navigation?.title || meta._itemTitle || r.title;
|
|
3027
|
+
if (entryPath === sectionPath) {
|
|
3028
|
+
const explicitNavTitle = meta.navigation?.title || meta._nav?.title;
|
|
3029
|
+
if (explicitNavTitle) {
|
|
3030
|
+
section.title = explicitNavTitle;
|
|
3031
|
+
}
|
|
3032
|
+
const explicitIcon = meta.navigation?.icon || meta._nav?.icon;
|
|
3033
|
+
if (explicitIcon) {
|
|
3034
|
+
section.icon = explicitIcon;
|
|
3035
|
+
}
|
|
3036
|
+
} else if (sectionMeta.title && sectionMeta.title !== "Docs" && !meta._group && (!section.title || section.title === defaultSectionTitle)) {
|
|
3027
3037
|
section.title = sectionMeta.title;
|
|
3028
3038
|
if (sectionMeta.icon) section.icon = sectionMeta.icon;
|
|
3029
3039
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1846,6 +1846,8 @@ export interface CMSSourceConfig {
|
|
|
1846
1846
|
include?: string;
|
|
1847
1847
|
/** Glob exclude pattern (e.g. "_drafts/*") */
|
|
1848
1848
|
exclude?: string;
|
|
1849
|
+
/** GitHub / Git provider auth token for private repositories */
|
|
1850
|
+
token?: string;
|
|
1849
1851
|
/** Human-readable label for debugging / devtools display */
|
|
1850
1852
|
label?: string;
|
|
1851
1853
|
}
|