@sarimarcus/content-sites-core 0.41.3 → 0.42.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 +8 -0
- package/dist/people/index.d.ts +12 -0
- package/dist/people/index.js +23 -7
- package/package.json +1 -1
- package/src/people/index.ts +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.42.1 (2026-10-21)
|
|
6
|
+
|
|
7
|
+
- No changes; lockstep release with ui (SLA-3303).
|
|
8
|
+
|
|
9
|
+
## 0.42.0 (2026-10-21)
|
|
10
|
+
|
|
11
|
+
- `people`: new `lifeSpan({ birthYear, deathYear })` returns `{ kind: 'range' | 'born' | 'died' | 'none', years?, age? }` (years through `formatYearRange`, an age that skips the missing year 0 across BCE/CE); `formatLifeDates` is built on it with the same output. No change to existing exports (SLA-3290).
|
|
12
|
+
|
|
5
13
|
## 0.41.3 (2026-10-21)
|
|
6
14
|
|
|
7
15
|
- New `./people` export for the people content collection (historical figures): `peopleSchemaFields(z, { eraValues, roleValues, image })` (name, slug, aliases, `birthYear`/`deathYear`/`circa`, optional `era`, roles, description 150-160, seoTitle 50-60, bio, optional `primaryArticle`, `sameAs` with a required Wikidata URL, image, an `imageAlt` that starts with "Illustration of", `dateModified`), `personYearIssues` (no year 0, `birthYear <= deathYear`, for a superRefine), `personFieldIssues` (those plus the alt prefix, for scripts), `personRefIssues` (an item's `people: [slug]` is an array of known, distinct slugs), `primaryArticleIssues`, `buildPersonBacklinks` (person slug to the distinct linking items), `countInboundRefs` (excludes the person's own `primaryArticle`) and `formatLifeDates`. `schema`: new `historicalPersonSchema()` builder, a deceased figure's Person node with the `@id` of its canonical `/person/<slug>` route, `birthDate`/`deathDate` from the years, `sameAs` and `alternateName`, and no `jobTitle` or `worksFor`; `personBuilder` and the author Person are unchanged. No change to existing exports (SLA-3260).
|
package/dist/people/index.d.ts
CHANGED
|
@@ -81,4 +81,16 @@ export declare function formatLifeDates(data: {
|
|
|
81
81
|
born?: string;
|
|
82
82
|
died?: string;
|
|
83
83
|
}): string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* The years and age behind a "Lived 1138–1204 (about 66 years)" line. `kind` says which years exist; `years` is
|
|
86
|
+
* `formatYearRange` of them; `age` needs both years with death after birth and skips the missing year 0 across BCE/CE.
|
|
87
|
+
*/
|
|
88
|
+
export declare function lifeSpan(data: {
|
|
89
|
+
birthYear?: number;
|
|
90
|
+
deathYear?: number;
|
|
91
|
+
}): {
|
|
92
|
+
kind: 'range' | 'born' | 'died' | 'none';
|
|
93
|
+
years?: string;
|
|
94
|
+
age?: number;
|
|
95
|
+
};
|
|
84
96
|
export {};
|
package/dist/people/index.js
CHANGED
|
@@ -114,14 +114,30 @@ export function countInboundRefs(backlinks, person, articleTypes = ['articles',
|
|
|
114
114
|
* as `4 BCE–65 CE`; undefined with neither year. The marks are replaceable for another language.
|
|
115
115
|
*/
|
|
116
116
|
export function formatLifeDates(data, marks = {}) {
|
|
117
|
-
const {
|
|
117
|
+
const { kind, years } = lifeSpan(data);
|
|
118
118
|
const { circa: c = 'c.', born = 'b.', died = 'd.' } = marks;
|
|
119
|
-
const lead = circa ? `${c} ` : '';
|
|
120
|
-
if (
|
|
121
|
-
return `${lead}${
|
|
119
|
+
const lead = data.circa ? `${c} ` : '';
|
|
120
|
+
if (kind === 'range')
|
|
121
|
+
return `${lead}${years}`;
|
|
122
|
+
if (kind === 'born')
|
|
123
|
+
return `${born} ${lead}${years}`;
|
|
124
|
+
if (kind === 'died')
|
|
125
|
+
return `${died} ${lead}${years}`;
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* The years and age behind a "Lived 1138–1204 (about 66 years)" line. `kind` says which years exist; `years` is
|
|
130
|
+
* `formatYearRange` of them; `age` needs both years with death after birth and skips the missing year 0 across BCE/CE.
|
|
131
|
+
*/
|
|
132
|
+
export function lifeSpan(data) {
|
|
133
|
+
const { birthYear, deathYear } = data;
|
|
134
|
+
if (birthYear !== undefined && deathYear !== undefined) {
|
|
135
|
+
const age = deathYear > birthYear ? deathYear - birthYear - (birthYear < 0 && deathYear > 0 ? 1 : 0) : undefined;
|
|
136
|
+
return { kind: 'range', years: formatYearRange(birthYear, deathYear), age };
|
|
137
|
+
}
|
|
122
138
|
if (birthYear !== undefined)
|
|
123
|
-
return
|
|
139
|
+
return { kind: 'born', years: formatYearRange(birthYear) };
|
|
124
140
|
if (deathYear !== undefined)
|
|
125
|
-
return
|
|
126
|
-
return
|
|
141
|
+
return { kind: 'died', years: formatYearRange(deathYear) };
|
|
142
|
+
return { kind: 'none' };
|
|
127
143
|
}
|
package/package.json
CHANGED
package/src/people/index.ts
CHANGED
|
@@ -161,11 +161,30 @@ export function formatLifeDates(
|
|
|
161
161
|
data: { birthYear?: number; deathYear?: number; circa?: boolean },
|
|
162
162
|
marks: { circa?: string; born?: string; died?: string } = {},
|
|
163
163
|
): string | undefined {
|
|
164
|
-
const {
|
|
164
|
+
const { kind, years } = lifeSpan(data);
|
|
165
165
|
const { circa: c = 'c.', born = 'b.', died = 'd.' } = marks;
|
|
166
|
-
const lead = circa ? `${c} ` : '';
|
|
167
|
-
if (
|
|
168
|
-
if (
|
|
169
|
-
if (
|
|
166
|
+
const lead = data.circa ? `${c} ` : '';
|
|
167
|
+
if (kind === 'range') return `${lead}${years}`;
|
|
168
|
+
if (kind === 'born') return `${born} ${lead}${years}`;
|
|
169
|
+
if (kind === 'died') return `${died} ${lead}${years}`;
|
|
170
170
|
return undefined;
|
|
171
171
|
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The years and age behind a "Lived 1138–1204 (about 66 years)" line. `kind` says which years exist; `years` is
|
|
175
|
+
* `formatYearRange` of them; `age` needs both years with death after birth and skips the missing year 0 across BCE/CE.
|
|
176
|
+
*/
|
|
177
|
+
export function lifeSpan(data: { birthYear?: number; deathYear?: number }): {
|
|
178
|
+
kind: 'range' | 'born' | 'died' | 'none';
|
|
179
|
+
years?: string;
|
|
180
|
+
age?: number;
|
|
181
|
+
} {
|
|
182
|
+
const { birthYear, deathYear } = data;
|
|
183
|
+
if (birthYear !== undefined && deathYear !== undefined) {
|
|
184
|
+
const age = deathYear > birthYear ? deathYear - birthYear - (birthYear < 0 && deathYear > 0 ? 1 : 0) : undefined;
|
|
185
|
+
return { kind: 'range', years: formatYearRange(birthYear, deathYear), age };
|
|
186
|
+
}
|
|
187
|
+
if (birthYear !== undefined) return { kind: 'born', years: formatYearRange(birthYear) };
|
|
188
|
+
if (deathYear !== undefined) return { kind: 'died', years: formatYearRange(deathYear) };
|
|
189
|
+
return { kind: 'none' };
|
|
190
|
+
}
|