mdorigin 0.7.1 → 0.7.2
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/dist/core/seo.d.ts +6 -1
- package/dist/core/seo.js +15 -5
- package/package.json +1 -1
package/dist/core/seo.d.ts
CHANGED
|
@@ -16,7 +16,12 @@ export interface SiteRobots {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function normalizePageRobots(value: unknown): PageRobots | undefined;
|
|
18
18
|
export declare function serializePageRobots(robots: PageRobots | undefined): string | undefined;
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* ISO calendar dates and timestamps are accepted. Legacy YAML timestamps that spell
|
|
21
|
+
* the date/time separator as a space or a lowercase `t` are normalized to `T`, and
|
|
22
|
+
* timestamps without an explicit timezone are interpreted as UTC so output never
|
|
23
|
+
* depends on the build machine's timezone.
|
|
24
|
+
*/
|
|
20
25
|
export declare function normalizeContentDate(value: unknown): string | undefined;
|
|
21
26
|
export declare function normalizeSiteRobots(value: unknown): SiteRobots | undefined;
|
|
22
27
|
export declare function buildPageStructuredData(input: {
|
package/dist/core/seo.js
CHANGED
|
@@ -56,7 +56,12 @@ export function serializePageRobots(robots) {
|
|
|
56
56
|
parts.push(`max-video-preview:${robots.maxVideoPreview}`);
|
|
57
57
|
return parts.length > 0 ? parts.join(', ') : undefined;
|
|
58
58
|
}
|
|
59
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* ISO calendar dates and timestamps are accepted. Legacy YAML timestamps that spell
|
|
61
|
+
* the date/time separator as a space or a lowercase `t` are normalized to `T`, and
|
|
62
|
+
* timestamps without an explicit timezone are interpreted as UTC so output never
|
|
63
|
+
* depends on the build machine's timezone.
|
|
64
|
+
*/
|
|
60
65
|
export function normalizeContentDate(value) {
|
|
61
66
|
if (value instanceof Date) {
|
|
62
67
|
if (Number.isNaN(value.getTime()))
|
|
@@ -66,16 +71,21 @@ export function normalizeContentDate(value) {
|
|
|
66
71
|
}
|
|
67
72
|
if (typeof value !== 'string')
|
|
68
73
|
return undefined;
|
|
69
|
-
|
|
74
|
+
// Legacy YAML timestamps may spell the ISO date/time separator as a space or a lowercase t.
|
|
75
|
+
const spelling = /^(\d{4}-\d{2}-\d{2})[ t]/.test(value) ? `${value.slice(0, 10)}T${value.slice(11)}` : value;
|
|
76
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(Z|[+-]\d{2}:\d{2})?)?$/.exec(spelling);
|
|
70
77
|
if (!match)
|
|
71
78
|
return undefined;
|
|
72
79
|
const day = new Date(`${match[1]}-${match[2]}-${match[3]}T00:00:00Z`);
|
|
73
|
-
if (Number.isNaN(day.getTime()) || day.toISOString().slice(0, 10) !==
|
|
80
|
+
if (Number.isNaN(day.getTime()) || day.toISOString().slice(0, 10) !== spelling.slice(0, 10))
|
|
74
81
|
return undefined;
|
|
75
|
-
|
|
82
|
+
if (spelling.length === 10)
|
|
83
|
+
return spelling;
|
|
84
|
+
// A timestamp without an explicit timezone is interpreted as UTC, never as local time.
|
|
85
|
+
const timestamp = Date.parse(match[4] ? spelling : `${spelling}Z`);
|
|
76
86
|
if (!Number.isFinite(timestamp))
|
|
77
87
|
return undefined;
|
|
78
|
-
return
|
|
88
|
+
return new Date(timestamp).toISOString();
|
|
79
89
|
}
|
|
80
90
|
export function normalizeSiteRobots(value) {
|
|
81
91
|
if (!value || typeof value !== 'object' || !('rules' in value) || !Array.isArray(value.rules)) {
|