@zeropress/build-pages 0.5.4 → 0.5.6
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/README.md +74 -22
- package/action.yml +4 -0
- package/dist/action.js +676 -58
- package/dist/prebuild.js +23 -6
- package/package.json +2 -2
- package/schemas/zeropress-build-pages.config.v0.1.schema.json +9 -2
- package/src/action.js +5 -0
- package/src/index.js +13 -0
- package/src/prebuild.js +22 -4
- package/schemas/zeropress-build-pages.config.schema.json +0 -5
package/dist/prebuild.js
CHANGED
|
@@ -3531,6 +3531,7 @@ var buildPagesConfigPath = path.join(outDir, "build-pages-config.json");
|
|
|
3531
3531
|
var previewDataPath = path.join(outDir, "preview-data.json");
|
|
3532
3532
|
var buildReportPath = path.join(outDir, "build-report.json");
|
|
3533
3533
|
var skipUntitledMarkdown = readBooleanEnv("ZEROPRESS_SKIP_UNTITLED_MARKDOWN");
|
|
3534
|
+
var copyMarkdownSource = readBooleanEnv("ZEROPRESS_COPY_MARKDOWN_SOURCE", true);
|
|
3534
3535
|
var FRONT_PAGE_TYPES = /* @__PURE__ */ new Set(["theme_index", "markdown", "html"]);
|
|
3535
3536
|
var BUILD_PAGES_CONFIG_SCHEMA_URL = "https://zeropress.dev/schemas/zeropress-build-pages.config.v0.1.schema.json";
|
|
3536
3537
|
var PREVIEW_DATA_SCHEMA_URL = "https://zeropress.dev/schemas/preview-data.v0.5.schema.json";
|
|
@@ -3605,7 +3606,7 @@ async function main() {
|
|
|
3605
3606
|
path: route.path,
|
|
3606
3607
|
meta: {
|
|
3607
3608
|
...frontMatter.meta,
|
|
3608
|
-
source_markdown_url: buildSourceMarkdownUrl(sourcePath)
|
|
3609
|
+
...copyMarkdownSource ? { source_markdown_url: buildSourceMarkdownUrl(sourcePath) } : {}
|
|
3609
3610
|
},
|
|
3610
3611
|
content: rewriteMarkdownLinks(bodyMarkdown, sourcePath, routeBySourcePath),
|
|
3611
3612
|
document_type: "markdown",
|
|
@@ -3729,7 +3730,8 @@ function buildSiteData(config, frontPage) {
|
|
|
3729
3730
|
post_index: {
|
|
3730
3731
|
enabled: false
|
|
3731
3732
|
},
|
|
3732
|
-
disallowComments: true
|
|
3733
|
+
disallowComments: true,
|
|
3734
|
+
indexing: configuredSite.indexing !== false
|
|
3733
3735
|
};
|
|
3734
3736
|
if (configuredSite.footer) {
|
|
3735
3737
|
site.footer = configuredSite.footer;
|
|
@@ -3757,11 +3759,12 @@ function normalizeSiteConfig(value) {
|
|
|
3757
3759
|
);
|
|
3758
3760
|
}
|
|
3759
3761
|
const configuredSite = isPlainObject(value) ? value : {};
|
|
3760
|
-
assertKnownConfigKeys(configuredSite, ["title", "description", "url", "footer"], "site");
|
|
3762
|
+
assertKnownConfigKeys(configuredSite, ["title", "description", "url", "indexing", "footer"], "site");
|
|
3761
3763
|
const site = {
|
|
3762
3764
|
title: readConfigString(configuredSite.title, "Documentation"),
|
|
3763
3765
|
description: readConfigString(configuredSite.description, "A documentation site."),
|
|
3764
|
-
url: readEnv("ZEROPRESS_SITE_URL", readConfigString(configuredSite.url, ""))
|
|
3766
|
+
url: readEnv("ZEROPRESS_SITE_URL", readConfigString(configuredSite.url, "")),
|
|
3767
|
+
indexing: readConfigBoolean(configuredSite.indexing, true, "site.indexing")
|
|
3765
3768
|
};
|
|
3766
3769
|
const footer = normalizeFooter(configuredSite.footer);
|
|
3767
3770
|
if (footer) {
|
|
@@ -3798,6 +3801,15 @@ function normalizeFooter(value) {
|
|
|
3798
3801
|
}
|
|
3799
3802
|
return Object.keys(footer).length ? footer : void 0;
|
|
3800
3803
|
}
|
|
3804
|
+
function readConfigBoolean(value, fallback, pathName) {
|
|
3805
|
+
if (value === void 0) {
|
|
3806
|
+
return fallback;
|
|
3807
|
+
}
|
|
3808
|
+
if (typeof value !== "boolean") {
|
|
3809
|
+
throw new PrebuildConfigError(`${pathName} must be a boolean when provided.`);
|
|
3810
|
+
}
|
|
3811
|
+
return value;
|
|
3812
|
+
}
|
|
3801
3813
|
async function buildFrontPageData(frontPageConfig, pageInputs, config) {
|
|
3802
3814
|
if (frontPageConfig.type === "theme_index") {
|
|
3803
3815
|
return {
|
|
@@ -4161,6 +4173,7 @@ function buildPrebuildReport({
|
|
|
4161
4173
|
preview_data_path: formatSourcePath(previewDataPath),
|
|
4162
4174
|
report_path: formatSourcePath(buildReportPath),
|
|
4163
4175
|
skip_untitled_markdown: skipUntitledMarkdown,
|
|
4176
|
+
copy_markdown_source: copyMarkdownSource,
|
|
4164
4177
|
markdown: {
|
|
4165
4178
|
discovered: sourceFiles.length,
|
|
4166
4179
|
generated_pages: pageInputs.length,
|
|
@@ -4588,8 +4601,12 @@ function readEnv(name, fallback) {
|
|
|
4588
4601
|
function readConfigString(value, fallback) {
|
|
4589
4602
|
return typeof value === "string" && value.trim() ? value.trim() : fallback;
|
|
4590
4603
|
}
|
|
4591
|
-
function readBooleanEnv(name) {
|
|
4592
|
-
|
|
4604
|
+
function readBooleanEnv(name, fallback = false) {
|
|
4605
|
+
const value = process.env[name]?.trim();
|
|
4606
|
+
if (!value) {
|
|
4607
|
+
return fallback;
|
|
4608
|
+
}
|
|
4609
|
+
return value.toLowerCase() === "true";
|
|
4593
4610
|
}
|
|
4594
4611
|
function resolveEnvPath(names, fallback) {
|
|
4595
4612
|
const rawValue = names.map((name) => process.env[name]?.trim()).find(Boolean) || fallback;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeropress/build-pages",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "ZeroPress Markdown build action and CLI for static hosting",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=18.18.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@zeropress/build": "0.5.
|
|
43
|
+
"@zeropress/build": "0.5.2",
|
|
44
44
|
"gray-matter": "4.0.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -50,6 +50,12 @@
|
|
|
50
50
|
"description": "Canonical site URL. Use an empty string or omit this field for local builds without canonical output.",
|
|
51
51
|
"markdownDescription": "Canonical site URL. Use an empty string or omit this field for local builds without canonical output."
|
|
52
52
|
},
|
|
53
|
+
"indexing": {
|
|
54
|
+
"type": "boolean",
|
|
55
|
+
"default": true,
|
|
56
|
+
"description": "Fallback robots.txt indexing policy. Missing or true allows indexing; false writes a fallback robots.txt that disallows all agents unless the source directory provides robots.txt.",
|
|
57
|
+
"markdownDescription": "Fallback `robots.txt` indexing policy. Missing or `true` allows indexing; `false` writes a fallback `robots.txt` that disallows all agents unless the source directory provides `robots.txt`."
|
|
58
|
+
},
|
|
53
59
|
"footer": {
|
|
54
60
|
"$ref": "#/$defs/siteFooter"
|
|
55
61
|
}
|
|
@@ -273,12 +279,13 @@
|
|
|
273
279
|
},
|
|
274
280
|
"examples": [
|
|
275
281
|
{
|
|
276
|
-
"$schema": "
|
|
282
|
+
"$schema": "https://zeropress.dev/schemas/zeropress-build-pages.config.v0.1.schema.json",
|
|
277
283
|
"version": "0.1",
|
|
278
284
|
"site": {
|
|
279
285
|
"title": "ZeroPress Public Docs",
|
|
280
286
|
"description": "Public documentation.",
|
|
281
|
-
"url": "https://zeropress.dev"
|
|
287
|
+
"url": "https://zeropress.dev",
|
|
288
|
+
"indexing": true
|
|
282
289
|
},
|
|
283
290
|
"front_page": {
|
|
284
291
|
"type": "markdown"
|
package/src/action.js
CHANGED
|
@@ -9,6 +9,7 @@ const options = {
|
|
|
9
9
|
siteUrl: input('site-url'),
|
|
10
10
|
skipUntitledMarkdown: booleanInput('skip-untitled-markdown', false),
|
|
11
11
|
skipLinkCheck: booleanInput('skip-link-check', false),
|
|
12
|
+
copyMarkdownSource: falseOnlyInput('copy-markdown-source'),
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
try {
|
|
@@ -30,3 +31,7 @@ function booleanInput(name, fallback) {
|
|
|
30
31
|
}
|
|
31
32
|
return value.toLowerCase() === 'true';
|
|
32
33
|
}
|
|
34
|
+
|
|
35
|
+
function falseOnlyInput(name) {
|
|
36
|
+
return input(name).toLowerCase() !== 'false';
|
|
37
|
+
}
|
package/src/index.js
CHANGED
|
@@ -37,6 +37,7 @@ export async function runCli(argv = process.argv.slice(2)) {
|
|
|
37
37
|
|
|
38
38
|
export async function runBuildPages(options) {
|
|
39
39
|
const cwd = path.resolve(options.cwd || process.cwd());
|
|
40
|
+
const copyMarkdownSource = options.copyMarkdownSource !== false;
|
|
40
41
|
const sourceDir = path.resolve(cwd, options.source);
|
|
41
42
|
const destinationDir = path.resolve(cwd, options.destination);
|
|
42
43
|
const generatedDir = path.join(cwd, '.zeropress');
|
|
@@ -60,6 +61,7 @@ export async function runBuildPages(options) {
|
|
|
60
61
|
ZEROPRESS_BUILD_PAGES_SOURCE: sourceDir,
|
|
61
62
|
ZEROPRESS_PUBLIC_DIR: sourceDir,
|
|
62
63
|
ZEROPRESS_SKIP_UNTITLED_MARKDOWN: String(Boolean(options.skipUntitledMarkdown)),
|
|
64
|
+
ZEROPRESS_COPY_MARKDOWN_SOURCE: String(copyMarkdownSource),
|
|
63
65
|
};
|
|
64
66
|
if (options.config) {
|
|
65
67
|
env.ZEROPRESS_BUILD_PAGES_CONFIG = path.resolve(cwd, options.config);
|
|
@@ -85,6 +87,7 @@ export async function runBuildPages(options) {
|
|
|
85
87
|
await fs.mkdir(stagingDir, { recursive: true });
|
|
86
88
|
await copyPublicStaging(sourceDir, stagingDir, {
|
|
87
89
|
excludePaths: [destinationDir, themeDir, generatedDir],
|
|
90
|
+
copyMarkdownSource,
|
|
88
91
|
});
|
|
89
92
|
|
|
90
93
|
const previousPublicDir = process.env.ZEROPRESS_PUBLIC_DIR;
|
|
@@ -127,6 +130,10 @@ export function parseArgs(argv) {
|
|
|
127
130
|
flags.skipLinkCheck = true;
|
|
128
131
|
continue;
|
|
129
132
|
}
|
|
133
|
+
if (arg === '--no-copy-markdown-source') {
|
|
134
|
+
flags.copyMarkdownSource = false;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
130
137
|
|
|
131
138
|
const valueOptions = new Set([
|
|
132
139
|
'--source',
|
|
@@ -167,6 +174,7 @@ export function parseArgs(argv) {
|
|
|
167
174
|
siteUrl: flags['site-url'] || '',
|
|
168
175
|
skipUntitledMarkdown: flags.skipUntitledMarkdown === true,
|
|
169
176
|
skipLinkCheck: flags.skipLinkCheck === true,
|
|
177
|
+
copyMarkdownSource: flags.copyMarkdownSource !== false,
|
|
170
178
|
};
|
|
171
179
|
}
|
|
172
180
|
|
|
@@ -185,6 +193,7 @@ Options:
|
|
|
185
193
|
--site-url <url> Canonical site URL override
|
|
186
194
|
--skip-untitled-markdown Skip Markdown files without a page title
|
|
187
195
|
--skip-link-check Skip internal link checking
|
|
196
|
+
--no-copy-markdown-source Do not copy original Markdown files to output
|
|
188
197
|
--help, -h Show help
|
|
189
198
|
--version, -v Show version`);
|
|
190
199
|
}
|
|
@@ -264,6 +273,10 @@ async function copyPublicStaging(sourceDir, targetDir, options) {
|
|
|
264
273
|
continue;
|
|
265
274
|
}
|
|
266
275
|
|
|
276
|
+
if (options.copyMarkdownSource === false && entry.name.toLowerCase().endsWith('.md')) {
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
|
|
267
280
|
await fs.mkdir(path.dirname(targetPath), { recursive: true });
|
|
268
281
|
await fs.copyFile(sourcePath, targetPath);
|
|
269
282
|
}
|
package/src/prebuild.js
CHANGED
|
@@ -13,6 +13,7 @@ const buildPagesConfigPath = path.join(outDir, 'build-pages-config.json');
|
|
|
13
13
|
const previewDataPath = path.join(outDir, 'preview-data.json');
|
|
14
14
|
const buildReportPath = path.join(outDir, 'build-report.json');
|
|
15
15
|
const skipUntitledMarkdown = readBooleanEnv('ZEROPRESS_SKIP_UNTITLED_MARKDOWN');
|
|
16
|
+
const copyMarkdownSource = readBooleanEnv('ZEROPRESS_COPY_MARKDOWN_SOURCE', true);
|
|
16
17
|
const FRONT_PAGE_TYPES = new Set(['theme_index', 'markdown', 'html']);
|
|
17
18
|
const BUILD_PAGES_CONFIG_SCHEMA_URL = 'https://zeropress.dev/schemas/zeropress-build-pages.config.v0.1.schema.json';
|
|
18
19
|
const PREVIEW_DATA_SCHEMA_URL = 'https://zeropress.dev/schemas/preview-data.v0.5.schema.json';
|
|
@@ -96,7 +97,7 @@ async function main() {
|
|
|
96
97
|
path: route.path,
|
|
97
98
|
meta: {
|
|
98
99
|
...frontMatter.meta,
|
|
99
|
-
source_markdown_url: buildSourceMarkdownUrl(sourcePath),
|
|
100
|
+
...(copyMarkdownSource ? { source_markdown_url: buildSourceMarkdownUrl(sourcePath) } : {}),
|
|
100
101
|
},
|
|
101
102
|
content: rewriteMarkdownLinks(bodyMarkdown, sourcePath, routeBySourcePath),
|
|
102
103
|
document_type: 'markdown',
|
|
@@ -233,6 +234,7 @@ function buildSiteData(config, frontPage) {
|
|
|
233
234
|
enabled: false,
|
|
234
235
|
},
|
|
235
236
|
disallowComments: true,
|
|
237
|
+
indexing: configuredSite.indexing !== false,
|
|
236
238
|
};
|
|
237
239
|
|
|
238
240
|
if (configuredSite.footer) {
|
|
@@ -267,11 +269,12 @@ function normalizeSiteConfig(value) {
|
|
|
267
269
|
}
|
|
268
270
|
|
|
269
271
|
const configuredSite = isPlainObject(value) ? value : {};
|
|
270
|
-
assertKnownConfigKeys(configuredSite, ['title', 'description', 'url', 'footer'], 'site');
|
|
272
|
+
assertKnownConfigKeys(configuredSite, ['title', 'description', 'url', 'indexing', 'footer'], 'site');
|
|
271
273
|
const site = {
|
|
272
274
|
title: readConfigString(configuredSite.title, 'Documentation'),
|
|
273
275
|
description: readConfigString(configuredSite.description, 'A documentation site.'),
|
|
274
276
|
url: readEnv('ZEROPRESS_SITE_URL', readConfigString(configuredSite.url, '')),
|
|
277
|
+
indexing: readConfigBoolean(configuredSite.indexing, true, 'site.indexing'),
|
|
275
278
|
};
|
|
276
279
|
|
|
277
280
|
const footer = normalizeFooter(configuredSite.footer);
|
|
@@ -315,6 +318,16 @@ function normalizeFooter(value) {
|
|
|
315
318
|
return Object.keys(footer).length ? footer : undefined;
|
|
316
319
|
}
|
|
317
320
|
|
|
321
|
+
function readConfigBoolean(value, fallback, pathName) {
|
|
322
|
+
if (value === undefined) {
|
|
323
|
+
return fallback;
|
|
324
|
+
}
|
|
325
|
+
if (typeof value !== 'boolean') {
|
|
326
|
+
throw new PrebuildConfigError(`${pathName} must be a boolean when provided.`);
|
|
327
|
+
}
|
|
328
|
+
return value;
|
|
329
|
+
}
|
|
330
|
+
|
|
318
331
|
async function buildFrontPageData(frontPageConfig, pageInputs, config) {
|
|
319
332
|
if (frontPageConfig.type === 'theme_index') {
|
|
320
333
|
return {
|
|
@@ -733,6 +746,7 @@ function buildPrebuildReport({
|
|
|
733
746
|
preview_data_path: formatSourcePath(previewDataPath),
|
|
734
747
|
report_path: formatSourcePath(buildReportPath),
|
|
735
748
|
skip_untitled_markdown: skipUntitledMarkdown,
|
|
749
|
+
copy_markdown_source: copyMarkdownSource,
|
|
736
750
|
markdown: {
|
|
737
751
|
discovered: sourceFiles.length,
|
|
738
752
|
generated_pages: pageInputs.length,
|
|
@@ -1305,8 +1319,12 @@ function readConfigInteger(value, fallback) {
|
|
|
1305
1319
|
return Number.isInteger(value) && value > 0 ? value : fallback;
|
|
1306
1320
|
}
|
|
1307
1321
|
|
|
1308
|
-
function readBooleanEnv(name) {
|
|
1309
|
-
|
|
1322
|
+
function readBooleanEnv(name, fallback = false) {
|
|
1323
|
+
const value = process.env[name]?.trim();
|
|
1324
|
+
if (!value) {
|
|
1325
|
+
return fallback;
|
|
1326
|
+
}
|
|
1327
|
+
return value.toLowerCase() === 'true';
|
|
1310
1328
|
}
|
|
1311
1329
|
|
|
1312
1330
|
function resolveEnvPath(names, fallback) {
|