@sarimarcus/content-sites-core 0.41.0 → 0.41.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/CHANGELOG.md +4 -0
- package/dist/eras/index.d.ts +2 -0
- package/dist/eras/index.js +11 -0
- package/package.json +1 -1
- package/src/eras/index.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.41.1 (2026-10-21)
|
|
6
|
+
|
|
7
|
+
- `eras`: new `formatYearRange(yearStart, yearEnd)`, the display form of an item's years in the historians' count (`929`, `206–100 BCE`, `206 BCE–500 CE`), `undefined` without a start. No change to existing exports (SLA-3274).
|
|
8
|
+
|
|
5
9
|
## 0.41.0 (2026-10-20)
|
|
6
10
|
|
|
7
11
|
- New `./eras` export for per-site historical-era classification: `EraDefinition` (the era data a site supplies), `eraHref`, `findEra`, `eraSchemaFields(z, eraValues)` (optional `era`, `yearStart`, `yearEnd` for a content collection), `eraYearIssues` (no year 0, `yearStart <= yearEnd`, for a superRefine), `eraFieldIssues`, `formatTemporalCoverage` and `temporalCoverageOf`. Years use the historians' count (`-206` = 206 BCE) and are written to ISO 8601 astronomically (`-0205`). `schema`: `renderSchemaPolicy` adds `temporalCoverage` to an entry's `Article` node when its data has `yearStart` (a single year, or an interval with `yearEnd`); JSON-LD is unchanged for every entry without it (SLA-3251).
|
package/dist/eras/index.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare function eraSchemaFields(z: ZodBuilders, eraValues: readonly stri
|
|
|
37
37
|
export declare function eraYearIssues(data: unknown): EraIssue[];
|
|
38
38
|
/** Every era-field issue for an item's data, for factory scripts. Pure; never throws on malformed input. */
|
|
39
39
|
export declare function eraFieldIssues(data: unknown, eraValues: readonly string[]): EraIssue[];
|
|
40
|
+
/** Display form of an item's years: 929 → "929", -206..-100 → "206–100 BCE", -206..500 → "206 BCE–500 CE"; no start → undefined. */
|
|
41
|
+
export declare function formatYearRange(yearStart?: number, yearEnd?: number): string | undefined;
|
|
40
42
|
/** ISO 8601: 929..1031 → "0929/1031", -206..500 → "-0205/0500", a single year → "1236", null end (to present) → "0929/..". */
|
|
41
43
|
export declare function formatTemporalCoverage(yearStart: number, yearEnd?: number | null): string;
|
|
42
44
|
/** The item's temporalCoverage, or undefined without an integer `yearStart`. */
|
package/dist/eras/index.js
CHANGED
|
@@ -53,6 +53,17 @@ const isoYear = (year) => {
|
|
|
53
53
|
const astronomical = year < 0 ? year + 1 : year;
|
|
54
54
|
return `${astronomical < 0 ? '-' : ''}${String(Math.abs(astronomical)).padStart(4, '0')}`;
|
|
55
55
|
};
|
|
56
|
+
/** Display form of an item's years: 929 → "929", -206..-100 → "206–100 BCE", -206..500 → "206 BCE–500 CE"; no start → undefined. */
|
|
57
|
+
export function formatYearRange(yearStart, yearEnd) {
|
|
58
|
+
if (yearStart === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
const year = (y) => (y < 0 ? `${-y} BCE` : `${y}`);
|
|
61
|
+
if (yearEnd === undefined || yearEnd === yearStart)
|
|
62
|
+
return year(yearStart);
|
|
63
|
+
if (yearStart < 0 && yearEnd < 0)
|
|
64
|
+
return `${-yearStart}–${-yearEnd} BCE`;
|
|
65
|
+
return `${year(yearStart)}–${yearEnd}${yearStart < 0 ? ' CE' : ''}`;
|
|
66
|
+
}
|
|
56
67
|
/** ISO 8601: 929..1031 → "0929/1031", -206..500 → "-0205/0500", a single year → "1236", null end (to present) → "0929/..". */
|
|
57
68
|
export function formatTemporalCoverage(yearStart, yearEnd) {
|
|
58
69
|
if (yearEnd === undefined)
|
package/package.json
CHANGED
package/src/eras/index.ts
CHANGED
|
@@ -82,6 +82,15 @@ const isoYear = (year: number): string => {
|
|
|
82
82
|
return `${astronomical < 0 ? '-' : ''}${String(Math.abs(astronomical)).padStart(4, '0')}`;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
/** Display form of an item's years: 929 → "929", -206..-100 → "206–100 BCE", -206..500 → "206 BCE–500 CE"; no start → undefined. */
|
|
86
|
+
export function formatYearRange(yearStart?: number, yearEnd?: number): string | undefined {
|
|
87
|
+
if (yearStart === undefined) return undefined;
|
|
88
|
+
const year = (y: number) => (y < 0 ? `${-y} BCE` : `${y}`);
|
|
89
|
+
if (yearEnd === undefined || yearEnd === yearStart) return year(yearStart);
|
|
90
|
+
if (yearStart < 0 && yearEnd < 0) return `${-yearStart}–${-yearEnd} BCE`;
|
|
91
|
+
return `${year(yearStart)}–${yearEnd}${yearStart < 0 ? ' CE' : ''}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
/** ISO 8601: 929..1031 → "0929/1031", -206..500 → "-0205/0500", a single year → "1236", null end (to present) → "0929/..". */
|
|
86
95
|
export function formatTemporalCoverage(yearStart: number, yearEnd?: number | null): string {
|
|
87
96
|
if (yearEnd === undefined) return isoYear(yearStart);
|