@aravindc26/velu 0.11.13 โ 0.11.14
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/package.json +1 -1
- package/src/build.ts +41 -13
package/package.json
CHANGED
package/src/build.ts
CHANGED
|
@@ -137,6 +137,9 @@ interface VeluRedirect {
|
|
|
137
137
|
|
|
138
138
|
interface VeluConfig {
|
|
139
139
|
$schema?: string;
|
|
140
|
+
name?: string;
|
|
141
|
+
title?: string;
|
|
142
|
+
description?: string;
|
|
140
143
|
theme?: string;
|
|
141
144
|
variables?: Record<string, string>;
|
|
142
145
|
colors?: VeluColors;
|
|
@@ -587,7 +590,7 @@ const STATIC_EXTENSIONS = new Set([
|
|
|
587
590
|
".zip",
|
|
588
591
|
]);
|
|
589
592
|
|
|
590
|
-
function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
593
|
+
function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
591
594
|
function walk(dir: string) {
|
|
592
595
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
593
596
|
for (const entry of entries) {
|
|
@@ -611,12 +614,35 @@ function copyStaticAssets(docsDir: string, publicDir: string) {
|
|
|
611
614
|
}
|
|
612
615
|
}
|
|
613
616
|
|
|
614
|
-
walk(docsDir);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
function
|
|
618
|
-
|
|
619
|
-
|
|
617
|
+
walk(docsDir);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function resolveProjectName(config: VeluConfig): string {
|
|
621
|
+
const fromName = typeof config.name === "string" ? config.name.trim() : "";
|
|
622
|
+
if (fromName) return fromName;
|
|
623
|
+
const fromTitle = typeof config.title === "string" ? config.title.trim() : "";
|
|
624
|
+
if (fromTitle) return fromTitle;
|
|
625
|
+
return "Documentation";
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function resolveProjectDescription(config: VeluConfig): string {
|
|
629
|
+
if (typeof config.description === "string") return config.description.trim();
|
|
630
|
+
return "";
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
function writeProjectConstFile(config: VeluConfig, outDir: string) {
|
|
634
|
+
const constPayload = {
|
|
635
|
+
name: resolveProjectName(config),
|
|
636
|
+
description: resolveProjectDescription(config),
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
const constPath = join(outDir, "public", "const.json");
|
|
640
|
+
writeFileSync(constPath, `${JSON.stringify(constPayload, null, 2)}\n`, "utf-8");
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
function toPosixPath(value: string): string {
|
|
644
|
+
return value.replace(/\\/g, "/");
|
|
645
|
+
}
|
|
620
646
|
|
|
621
647
|
function isInsideDocsRoot(docsDir: string, targetPath: string): boolean {
|
|
622
648
|
const relPath = relative(docsDir, targetPath);
|
|
@@ -1167,12 +1193,14 @@ function build(docsDir: string, outDir: string) {
|
|
|
1167
1193
|
console.log(`๐ Copied ${configName} as ${PRIMARY_CONFIG_NAME} (and legacy ${LEGACY_CONFIG_NAME})`);
|
|
1168
1194
|
|
|
1169
1195
|
// โโ 3b. Copy static assets from docs project into public/ โโโโโโโโโโโโโโโโโ
|
|
1170
|
-
copyStaticAssets(docsDir, join(outDir, "public"));
|
|
1171
|
-
writeRedirectArtifacts(config, outDir);
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1196
|
+
copyStaticAssets(docsDir, join(outDir, "public"));
|
|
1197
|
+
writeRedirectArtifacts(config, outDir);
|
|
1198
|
+
writeProjectConstFile(rawConfig, outDir);
|
|
1199
|
+
if ((config.redirects ?? []).length > 0) {
|
|
1200
|
+
console.log("โช๏ธ Generated redirect artifacts");
|
|
1201
|
+
}
|
|
1202
|
+
console.log("๐งพ Generated const.json");
|
|
1203
|
+
console.log("๐ผ๏ธ Copied static assets");
|
|
1176
1204
|
|
|
1177
1205
|
// โโ 4. Build content + metadata artifacts โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
1178
1206
|
const contentDir = join(outDir, "content", "docs");
|