@zeropress/build-core 0.6.12 → 0.7.0
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 +136 -42
- package/package.json +7 -7
- package/src/api/build-site.js +891 -305
- package/src/index.d.ts +43 -11
- package/src/render/control-flow-renderer.js +5 -2
- package/src/render/variable-resolver.js +6 -1
- package/src/render/zeropress-engine.js +3 -1
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PreviewDataV07 } from '@zeropress/preview-data-validator';
|
|
2
2
|
import type { ThemeManifest } from '@zeropress/theme-validator';
|
|
3
3
|
|
|
4
4
|
export interface ThemePackage {
|
|
@@ -24,17 +24,55 @@ export interface BuildOptions {
|
|
|
24
24
|
assetHashing?: boolean;
|
|
25
25
|
favicon?: {
|
|
26
26
|
icon?: string;
|
|
27
|
+
icon_dark?: string;
|
|
27
28
|
svg?: string;
|
|
28
29
|
png?: string;
|
|
29
30
|
apple_touch_icon?: string;
|
|
30
31
|
};
|
|
31
32
|
sitemapStylesheetHref?: string;
|
|
32
|
-
generateSpecialFiles?: boolean;
|
|
33
33
|
generateFeed?: boolean;
|
|
34
34
|
generateRobotsTxt?: boolean;
|
|
35
|
-
|
|
35
|
+
reservedOutputPaths?: readonly string[];
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export interface DisabledThemeCommentsContext {
|
|
39
|
+
enabled: false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ThemeCommentsThreadingContext {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
max_depth: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ZeroPressThemeCommentsContext {
|
|
48
|
+
enabled: true;
|
|
49
|
+
target_type: 'post' | 'page';
|
|
50
|
+
target_public_id: number;
|
|
51
|
+
provider: 'zeropress';
|
|
52
|
+
api_base_url: string;
|
|
53
|
+
per_page: number;
|
|
54
|
+
order: 'asc' | 'desc';
|
|
55
|
+
threading: ThemeCommentsThreadingContext;
|
|
56
|
+
request_token: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface WordPressThemeCommentsContext {
|
|
60
|
+
enabled: true;
|
|
61
|
+
target_type: 'post' | 'page';
|
|
62
|
+
target_public_id: number;
|
|
63
|
+
provider: 'wordpress';
|
|
64
|
+
api_base_url: string;
|
|
65
|
+
per_page: number;
|
|
66
|
+
order: 'asc' | 'desc';
|
|
67
|
+
threading: ThemeCommentsThreadingContext;
|
|
68
|
+
request_token?: never;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type ThemeCommentsContext =
|
|
72
|
+
| DisabledThemeCommentsContext
|
|
73
|
+
| ZeroPressThemeCommentsContext
|
|
74
|
+
| WordPressThemeCommentsContext;
|
|
75
|
+
|
|
38
76
|
export interface BuildSummaryFile {
|
|
39
77
|
path: string;
|
|
40
78
|
contentType: string;
|
|
@@ -42,25 +80,19 @@ export interface BuildSummaryFile {
|
|
|
42
80
|
sha256: string;
|
|
43
81
|
}
|
|
44
82
|
|
|
45
|
-
export interface BuildManifest {
|
|
46
|
-
generatedAt: string;
|
|
47
|
-
files: BuildSummaryFile[];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
83
|
export interface BuildSiteResult {
|
|
51
84
|
files: BuildSummaryFile[];
|
|
52
|
-
manifest?: BuildManifest;
|
|
53
85
|
}
|
|
54
86
|
|
|
55
87
|
export function buildSite(input: {
|
|
56
|
-
previewData:
|
|
88
|
+
previewData: PreviewDataV07;
|
|
57
89
|
themePackage: ThemePackage;
|
|
58
90
|
writer: BuildWriter;
|
|
59
91
|
options?: BuildOptions;
|
|
60
92
|
}): Promise<BuildSiteResult>;
|
|
61
93
|
|
|
62
94
|
export function buildSiteFromThemeDir(input: {
|
|
63
|
-
previewData:
|
|
95
|
+
previewData: PreviewDataV07;
|
|
64
96
|
themeDir: string;
|
|
65
97
|
writer: BuildWriter;
|
|
66
98
|
options?: BuildOptions;
|
|
@@ -229,6 +229,9 @@ export class ControlFlowRenderer {
|
|
|
229
229
|
|
|
230
230
|
if (token.startsWith('/')) {
|
|
231
231
|
const tagName = token.slice(1).trim();
|
|
232
|
+
if (COMPARISON_BLOCK_TAGS.has(tagName)) {
|
|
233
|
+
throw new Error(`Named conditional closing tag {{/${tagName}}} is not supported; use {{/if}}`);
|
|
234
|
+
}
|
|
232
235
|
if (!stopTags.has(tagName)) {
|
|
233
236
|
throw new Error(`Unexpected closing tag /${tagName}`);
|
|
234
237
|
}
|
|
@@ -370,8 +373,8 @@ export class ControlFlowRenderer {
|
|
|
370
373
|
let alternate = [];
|
|
371
374
|
let nextIndex = startIndex;
|
|
372
375
|
let currentBranch = initialBranch;
|
|
373
|
-
const comparisonStopTags = new Set(['else', 'if',
|
|
374
|
-
const comparisonCloseTags = new Set(['if'
|
|
376
|
+
const comparisonStopTags = new Set(['else', 'if', ...COMPARISON_ELSE_IF_TAGS]);
|
|
377
|
+
const comparisonCloseTags = new Set(['if']);
|
|
375
378
|
|
|
376
379
|
while (true) {
|
|
377
380
|
const branchResult = this.parseNodes(source, nextIndex, comparisonStopTags, partialArgScope);
|
|
@@ -94,7 +94,12 @@ export class VariableResolver {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
if (
|
|
97
|
+
if (
|
|
98
|
+
variablePath === 'data'
|
|
99
|
+
|| variablePath.startsWith('data.')
|
|
100
|
+
|| variablePath.includes('.data.')
|
|
101
|
+
|| variablePath.includes('.meta.')
|
|
102
|
+
) {
|
|
98
103
|
return false;
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DEFAULT_RUNTIME } from '@zeropress/theme-validator';
|
|
1
2
|
import { SlotResolver } from './slot-resolver.js';
|
|
2
3
|
import { VariableResolver } from './variable-resolver.js';
|
|
3
4
|
import { ControlFlowRenderer } from './control-flow-renderer.js';
|
|
@@ -46,11 +47,12 @@ export class ZeroPressEngine {
|
|
|
46
47
|
site: context.site,
|
|
47
48
|
currentUrl: context.currentUrl,
|
|
48
49
|
language: context.language,
|
|
50
|
+
comments: context.comments,
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
renderTemplate(template, data) {
|
|
53
|
-
if (this.themePackage?.metadata?.runtime !==
|
|
55
|
+
if (this.themePackage?.metadata?.runtime !== DEFAULT_RUNTIME) {
|
|
54
56
|
throw new Error(`Unsupported theme runtime: ${this.themePackage?.metadata?.runtime || 'unknown'}`);
|
|
55
57
|
}
|
|
56
58
|
|