@cntrl-site/sdk 1.27.0 → 1.27.1
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/lib/cli.js
CHANGED
|
@@ -69,14 +69,14 @@ commander_1.program
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const indexable = project.pages.filter(isIndexablePage);
|
|
72
|
-
const
|
|
72
|
+
const fallbackLastmod = formatLastmod(new Date().toISOString());
|
|
73
73
|
const outputDir = path_1.default.resolve(process.cwd(), options.output);
|
|
74
74
|
if (!fs_1.default.existsSync(outputDir)) {
|
|
75
75
|
fs_1.default.mkdirSync(outputDir, { recursive: true });
|
|
76
76
|
}
|
|
77
77
|
const sitemapPath = path_1.default.resolve(outputDir, 'sitemap.xml');
|
|
78
78
|
const robotsPath = path_1.default.resolve(outputDir, 'robots.txt');
|
|
79
|
-
fs_1.default.writeFileSync(sitemapPath, renderSitemap(indexable, siteUrl,
|
|
79
|
+
fs_1.default.writeFileSync(sitemapPath, renderSitemap(indexable, siteUrl, fallbackLastmod));
|
|
80
80
|
fs_1.default.writeFileSync(robotsPath, renderRobots(siteUrl));
|
|
81
81
|
console.log(`Generated sitemap.xml at ${sitemapPath} (${indexable.length} of ${project.pages.length} pages)`);
|
|
82
82
|
console.log(`Generated robots.txt at ${robotsPath}`);
|
|
@@ -101,9 +101,10 @@ function isIndexablePage(page) {
|
|
|
101
101
|
return false;
|
|
102
102
|
return true;
|
|
103
103
|
}
|
|
104
|
-
function renderSitemap(pages, siteUrl,
|
|
104
|
+
function renderSitemap(pages, siteUrl, fallbackLastmod) {
|
|
105
105
|
const entries = pages.map(page => {
|
|
106
106
|
const loc = escapeXml(buildPageUrl(siteUrl, page.slug));
|
|
107
|
+
const lastmod = page.lastModified ? formatLastmod(page.lastModified) : fallbackLastmod;
|
|
107
108
|
const priority = page.slug === '' ? '1.00' : '0.80';
|
|
108
109
|
return [
|
|
109
110
|
' <url>',
|
|
@@ -121,6 +122,10 @@ function renderSitemap(pages, siteUrl, lastmod) {
|
|
|
121
122
|
''
|
|
122
123
|
].join('\n');
|
|
123
124
|
}
|
|
125
|
+
function formatLastmod(iso) {
|
|
126
|
+
// YYYY-MM-DD is sitemap-spec valid and avoids hour-of-rebuild noise.
|
|
127
|
+
return iso.slice(0, 10);
|
|
128
|
+
}
|
|
124
129
|
function renderRobots(siteUrl) {
|
|
125
130
|
const sitemapUrl = new URL('/sitemap.xml', siteUrl.origin).toString();
|
|
126
131
|
return [
|
|
@@ -76,6 +76,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
76
76
|
id: z.ZodString;
|
|
77
77
|
isPublished: z.ZodOptional<z.ZodBoolean>;
|
|
78
78
|
isAuthProtected: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
lastModified: z.ZodOptional<z.ZodString>;
|
|
79
80
|
}, "strip", z.ZodTypeAny, {
|
|
80
81
|
id: string;
|
|
81
82
|
title: string;
|
|
@@ -90,6 +91,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
90
91
|
} | undefined;
|
|
91
92
|
isPublished?: boolean | undefined;
|
|
92
93
|
isAuthProtected?: boolean | undefined;
|
|
94
|
+
lastModified?: string | undefined;
|
|
93
95
|
}, {
|
|
94
96
|
id: string;
|
|
95
97
|
title: string;
|
|
@@ -104,6 +106,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
104
106
|
} | undefined;
|
|
105
107
|
isPublished?: boolean | undefined;
|
|
106
108
|
isAuthProtected?: boolean | undefined;
|
|
109
|
+
lastModified?: string | undefined;
|
|
107
110
|
}>, "many">;
|
|
108
111
|
fonts: z.ZodObject<{
|
|
109
112
|
google: z.ZodString;
|
|
@@ -199,6 +202,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
199
202
|
} | undefined;
|
|
200
203
|
isPublished?: boolean | undefined;
|
|
201
204
|
isAuthProtected?: boolean | undefined;
|
|
205
|
+
lastModified?: string | undefined;
|
|
202
206
|
}[];
|
|
203
207
|
fonts: {
|
|
204
208
|
custom: {
|
|
@@ -248,6 +252,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
248
252
|
} | undefined;
|
|
249
253
|
isPublished?: boolean | undefined;
|
|
250
254
|
isAuthProtected?: boolean | undefined;
|
|
255
|
+
lastModified?: string | undefined;
|
|
251
256
|
}[];
|
|
252
257
|
fonts: {
|
|
253
258
|
custom: {
|
|
@@ -32,7 +32,8 @@ exports.ProjectSchema = zod_1.z.object({
|
|
|
32
32
|
}).optional(),
|
|
33
33
|
id: zod_1.z.string().min(1),
|
|
34
34
|
isPublished: zod_1.z.boolean().optional(),
|
|
35
|
-
isAuthProtected: zod_1.z.boolean().optional()
|
|
35
|
+
isAuthProtected: zod_1.z.boolean().optional(),
|
|
36
|
+
lastModified: zod_1.z.string().optional()
|
|
36
37
|
})),
|
|
37
38
|
fonts: zod_1.z.object({
|
|
38
39
|
google: zod_1.z.string(),
|