@zeropress/build-core 0.6.6 → 0.6.10
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 +4 -1
- package/package.json +1 -1
- package/src/api/build-site.js +12 -2
- package/src/index.d.ts +1 -0
- package/src/render/content-renderer.js +7 -3
package/README.md
CHANGED
|
@@ -120,7 +120,8 @@ Notes:
|
|
|
120
120
|
- `writer` is required
|
|
121
121
|
- `previewData` must already satisfy the canonical preview-data contract
|
|
122
122
|
- `themePackage` must already be a validated in-memory theme package
|
|
123
|
-
- `sitemap.xml`
|
|
123
|
+
- `sitemap.xml` is emitted only when `site.url` is a non-empty canonical URL
|
|
124
|
+
- `feed.xml` is emitted only when `site.url` is a non-empty canonical URL and `generateFeed` is not `false`
|
|
124
125
|
- callers may pass `sitemapStylesheetHref` to add an XML stylesheet processing instruction to generated `sitemap.xml`
|
|
125
126
|
- fallback `robots.txt` is emitted when `generateSpecialFiles` is enabled and `generateRobotsTxt` is not `false`
|
|
126
127
|
- fallback `robots.txt` uses `site.indexing`; `false` emits `Disallow: /`, while missing or `true` emits `Allow: /`
|
|
@@ -229,6 +230,7 @@ Supported options:
|
|
|
229
230
|
- `favicon`
|
|
230
231
|
- `sitemapStylesheetHref`
|
|
231
232
|
- `generateSpecialFiles`
|
|
233
|
+
- `generateFeed`
|
|
232
234
|
- `generateRobotsTxt`
|
|
233
235
|
- `writeManifest`
|
|
234
236
|
|
|
@@ -238,6 +240,7 @@ Defaults:
|
|
|
238
240
|
|
|
239
241
|
- `assetHashing: true`
|
|
240
242
|
- `generateSpecialFiles: true`
|
|
243
|
+
- `generateFeed: true`
|
|
241
244
|
- `generateRobotsTxt: true`
|
|
242
245
|
- `writeManifest: false`
|
|
243
246
|
|
package/package.json
CHANGED
package/src/api/build-site.js
CHANGED
|
@@ -9,6 +9,7 @@ import { ZeroPressEngine } from '../render/zeropress-engine.js';
|
|
|
9
9
|
const DEFAULT_OPTIONS = {
|
|
10
10
|
assetHashing: true,
|
|
11
11
|
generateSpecialFiles: true,
|
|
12
|
+
generateFeed: true,
|
|
12
13
|
generateRobotsTxt: true,
|
|
13
14
|
writeManifest: false,
|
|
14
15
|
};
|
|
@@ -115,7 +116,9 @@ export async function buildSite(input) {
|
|
|
115
116
|
buildSitemapXml(state.previewData.site, state.emitted, state.generatedAt, options.sitemapStylesheetHref),
|
|
116
117
|
'application/xml',
|
|
117
118
|
);
|
|
118
|
-
|
|
119
|
+
if (shouldGenerateFeed(options)) {
|
|
120
|
+
await writeOutput(state.writer, state.summaries, 'feed.xml', buildFeedXml(state.previewData.site, state.emitted, state.generatedAt), 'application/rss+xml');
|
|
121
|
+
}
|
|
119
122
|
}
|
|
120
123
|
if (shouldGenerateRobotsTxt(options)) {
|
|
121
124
|
await writeOutput(state.writer, state.summaries, 'robots.txt', buildRobotsTxt(state.previewData.site), 'text/plain');
|
|
@@ -2429,7 +2432,10 @@ function assertPlannedOutputPathsSafe(state) {
|
|
|
2429
2432
|
plannedPaths.push('robots.txt');
|
|
2430
2433
|
}
|
|
2431
2434
|
if (hasCanonicalSiteUrl(state.previewData.site.url)) {
|
|
2432
|
-
plannedPaths.push('sitemap.xml'
|
|
2435
|
+
plannedPaths.push('sitemap.xml');
|
|
2436
|
+
if (shouldGenerateFeed(state.options)) {
|
|
2437
|
+
plannedPaths.push('feed.xml');
|
|
2438
|
+
}
|
|
2433
2439
|
}
|
|
2434
2440
|
}
|
|
2435
2441
|
|
|
@@ -3158,6 +3164,10 @@ function shouldGenerateRobotsTxt(options) {
|
|
|
3158
3164
|
return options.generateSpecialFiles && options.generateRobotsTxt !== false;
|
|
3159
3165
|
}
|
|
3160
3166
|
|
|
3167
|
+
function shouldGenerateFeed(options) {
|
|
3168
|
+
return options.generateSpecialFiles && options.generateFeed !== false;
|
|
3169
|
+
}
|
|
3170
|
+
|
|
3161
3171
|
function shouldGenerateSearchArtifacts(state, options) {
|
|
3162
3172
|
return options.generateSpecialFiles && state.previewData.site.search === true;
|
|
3163
3173
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -329,6 +329,7 @@ function sanitizeHtml(html) {
|
|
|
329
329
|
'ul', 'ol', 'li',
|
|
330
330
|
'blockquote', 'aside',
|
|
331
331
|
'figure', 'figcaption', 'picture', 'source',
|
|
332
|
+
'video', 'audio', 'track',
|
|
332
333
|
'table', 'thead', 'tbody', 'tr', 'th', 'td',
|
|
333
334
|
'div', 'span', 'nav',
|
|
334
335
|
'iframe', 'input',
|
|
@@ -338,9 +339,12 @@ function sanitizeHtml(html) {
|
|
|
338
339
|
a: new Set(['href', 'title', 'class', 'id']),
|
|
339
340
|
aside: new Set(['role', 'class', 'id']),
|
|
340
341
|
img: new Set(['src', 'srcset', 'sizes', 'alt', 'title', 'class', 'id', 'width', 'height', 'loading', 'decoding']),
|
|
341
|
-
iframe: new Set(['src', 'width', 'height', 'frameborder', 'allowfullscreen', 'class']),
|
|
342
|
+
iframe: new Set(['src', 'width', 'height', 'frameborder', 'allowfullscreen', 'class', 'title']),
|
|
342
343
|
input: new Set(['type', 'checked', 'disabled', 'class', 'id', 'aria-label']),
|
|
343
344
|
source: new Set(['src', 'srcset', 'sizes', 'type', 'media', 'width', 'height', 'class', 'id']),
|
|
345
|
+
video: new Set(['src', 'controls', 'autoplay', 'loop', 'muted', 'playsinline', 'poster', 'preload', 'width', 'height', 'class', 'id', 'title']),
|
|
346
|
+
audio: new Set(['src', 'controls', 'autoplay', 'loop', 'muted', 'preload', 'class', 'id', 'title']),
|
|
347
|
+
track: new Set(['src', 'kind', 'srclang', 'label', 'default', 'class', 'id']),
|
|
344
348
|
'*': new Set(['class', 'id']),
|
|
345
349
|
};
|
|
346
350
|
|
|
@@ -377,7 +381,7 @@ function sanitizeHtml(html) {
|
|
|
377
381
|
continue;
|
|
378
382
|
}
|
|
379
383
|
|
|
380
|
-
if ((attributeName === 'href' || attributeName === 'src') && !safeUriPattern.test(attributeValue)) {
|
|
384
|
+
if ((attributeName === 'href' || attributeName === 'src' || attributeName === 'poster') && !safeUriPattern.test(attributeValue)) {
|
|
381
385
|
continue;
|
|
382
386
|
}
|
|
383
387
|
|
|
@@ -393,7 +397,7 @@ function sanitizeHtml(html) {
|
|
|
393
397
|
}
|
|
394
398
|
}
|
|
395
399
|
|
|
396
|
-
const isSelfClosing = match.endsWith('/>') || normalizedTag === 'br' || normalizedTag === 'hr' || normalizedTag === 'img' || normalizedTag === 'input' || normalizedTag === 'source';
|
|
400
|
+
const isSelfClosing = match.endsWith('/>') || normalizedTag === 'br' || normalizedTag === 'hr' || normalizedTag === 'img' || normalizedTag === 'input' || normalizedTag === 'source' || normalizedTag === 'track';
|
|
397
401
|
const attributeSuffix = filteredAttributes.length > 0 ? ` ${filteredAttributes.join(' ')}` : '';
|
|
398
402
|
return isSelfClosing ? `<${normalizedTag}${attributeSuffix} />` : `<${normalizedTag}${attributeSuffix}>`;
|
|
399
403
|
});
|