mdorigin 0.7.1 → 0.7.3

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.
@@ -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
- /** Only ISO calendar dates or timestamps with an explicit timezone are accepted. */
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
- /** Only ISO calendar dates or timestamps with an explicit timezone are accepted. */
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
- const match = /^(\d{4})-(\d{2})-(\d{2})(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2}))?$/.exec(value);
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) !== value.slice(0, 10))
80
+ if (Number.isNaN(day.getTime()) || day.toISOString().slice(0, 10) !== spelling.slice(0, 10))
74
81
  return undefined;
75
- const timestamp = Date.parse(value);
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 value.length === 10 ? value : new Date(timestamp).toISOString();
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)) {
@@ -141,7 +141,8 @@ export async function buildManagedIndexBlock(directoryPath, plugins = [], exclud
141
141
  kind: 'article',
142
142
  title: entry.title,
143
143
  href: entry.link,
144
- detail: [entry.date, entry.summary].filter(Boolean).join(' · ') || undefined,
144
+ detail: [formatIndexEntryDate(entry.date), entry.summary].filter(Boolean).join(' · ') ||
145
+ undefined,
145
146
  })),
146
147
  ], plugins, {
147
148
  mode: 'build',
@@ -166,6 +167,19 @@ export function upsertManagedIndexBlock(source, block, options = {}) {
166
167
  }
167
168
  return `${trimmed}\n\n${block}\n`;
168
169
  }
170
+ /**
171
+ * Managed index lines are human-facing. Date-only values keep their authored
172
+ * spelling, while normalized UTC timestamps render as `YYYY-MM-DD HH:mm`
173
+ * instead of raw ISO. Sorting still compares the normalized meta.date values.
174
+ */
175
+ function formatIndexEntryDate(value) {
176
+ if (!value)
177
+ return undefined;
178
+ if (/^\d{4}-\d{2}-\d{2}$/.test(value))
179
+ return value;
180
+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(value);
181
+ return match ? `${match[1]} ${match[2]}` : value;
182
+ }
169
183
  function renderManagedIndexBlock(entries) {
170
184
  const lines = [INDEX_START_MARKER, ''];
171
185
  if (entries.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mdorigin",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "description": "Markdown-first publishing for humans and agents.",
6
6
  "repository": {