@sarimarcus/content-sites-core 0.37.0 → 0.38.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 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.38.1 (2026-10-15)
6
+
7
+ - No changes; lockstep release with tourism (SLA-3125).
8
+
9
+ ## 0.38.0 (2026-10-15)
10
+
11
+ - `articles`: new `selectRecentlyUpdated(articles, {datesOf, now, exclude?, windowDays?, max?})` (60-day window, max 3, newest update first), `isUpdatedAfterPublication` and the `RECENT_UPDATE_*` defaults, for the articles hub "Recently updated" shelf; the window is counted in calendar days, so a build-day rewrite stays in (SLA-3120).
12
+
5
13
  ## 0.37.0 (2026-10-14)
6
14
 
7
15
  - `llms`: new export with `renderLlmsTxt(siteUrl, input)`, `llmsLine`, `trimDescription` and `llmsTxtResponse`, the llms.txt renderer darkskies kept as a local `llms.txt.ts`. Sections take an intro, links, bullets and prose, and a link can override the trim length; each site still selects its own items (SLA-3083).
@@ -20,6 +20,7 @@ export interface FeaturedSelection<T> {
20
20
  }
21
21
  export declare const FEATURED_SHELF_SIZE = 3;
22
22
  export declare const FEATURED_MAX_AGE_DAYS = 21;
23
+ export declare const DAY_MS = 86400000;
23
24
  /**
24
25
  * Split newest-first articles into the hero, the trending shelf and the rest.
25
26
  * Pass `buildNow()` as `now` so two pages of one build agree.
@@ -7,7 +7,7 @@
7
7
  */
8
8
  export const FEATURED_SHELF_SIZE = 3;
9
9
  export const FEATURED_MAX_AGE_DAYS = 21;
10
- const DAY_MS = 86_400_000;
10
+ export const DAY_MS = 86_400_000;
11
11
  function snapshotAgeDays(snapshot, now) {
12
12
  const generated = Date.parse(`${snapshot.generatedAt}T00:00:00Z`);
13
13
  return Number.isNaN(generated) ? Infinity : Math.floor((now.getTime() - generated) / DAY_MS);
@@ -1,4 +1,6 @@
1
1
  export { selectFeaturedArticles, FEATURED_SHELF_SIZE, FEATURED_MAX_AGE_DAYS } from './featured.ts';
2
2
  export type { FeaturedSnapshot, FeaturedSelection } from './featured.ts';
3
+ export { selectRecentlyUpdated, isUpdatedAfterPublication, RECENT_UPDATE_WINDOW_DAYS, RECENT_UPDATE_MAX } from './recent.ts';
4
+ export type { ArticleDates } from './recent.ts';
3
5
  export { ARTICLE_FORMATS, ARTICLE_SHAPE_UNION, FORMATS, FORMAT_NAMES, LEGACY_SHAPE, shapeFor, checkFormat, checkCounts, checkKeyFactCount, checkWords, countBodyWords, validateShape, articleShapeIssues, } from './formats.ts';
4
6
  export type { ArticleFormat, ArticleMode, ArticleShape, FormatCard, Range, ShapeIssue, ShapeRanges } from './formats.ts';
@@ -1,3 +1,4 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/articles.
2
2
  export { selectFeaturedArticles, FEATURED_SHELF_SIZE, FEATURED_MAX_AGE_DAYS } from "./featured.js";
3
+ export { selectRecentlyUpdated, isUpdatedAfterPublication, RECENT_UPDATE_WINDOW_DAYS, RECENT_UPDATE_MAX } from "./recent.js";
3
4
  export { ARTICLE_FORMATS, ARTICLE_SHAPE_UNION, FORMATS, FORMAT_NAMES, LEGACY_SHAPE, shapeFor, checkFormat, checkCounts, checkKeyFactCount, checkWords, countBodyWords, validateShape, articleShapeIssues, } from "./formats.js";
@@ -0,0 +1,23 @@
1
+ export interface ArticleDates {
2
+ datePublished?: string;
3
+ dateModified?: string;
4
+ }
5
+ export declare const RECENT_UPDATE_WINDOW_DAYS = 60;
6
+ export declare const RECENT_UPDATE_MAX = 3;
7
+ /** The one "Updated" test: calendar days, not raw strings. The cards, the byline and the shelf share it. */
8
+ export declare function isUpdatedAfterPublication({ datePublished, dateModified }: ArticleDates): boolean;
9
+ /**
10
+ * Up to `max` articles updated within `windowDays` calendar days of `now`, newest update first.
11
+ * Days are the stamp's own calendar date, as in `isUpdatedAfterPublication`, so a date-only value and a
12
+ * timestamp on the same date fall on the same side of the window. The window runs from the UTC day of `now`
13
+ * back `windowDays` days, inclusive; a date after that day never qualifies, so a build-day rewrite stays in
14
+ * even though `buildNow()` is midnight UTC. `exclude` drops articles already shown elsewhere on the page, and
15
+ * an unparseable `dateModified` never qualifies.
16
+ */
17
+ export declare function selectRecentlyUpdated<T>(articles: readonly T[], options: {
18
+ datesOf: (article: T) => ArticleDates;
19
+ now: Date;
20
+ exclude?: Iterable<T>;
21
+ windowDays?: number;
22
+ max?: number;
23
+ }): T[];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * "Recently updated" selection for the articles hub (SLA-3120).
3
+ *
4
+ * Listings sort by `datePublished` (SLA-2436), so a rewrite is invisible there. This picks the
5
+ * articles whose last update fell on another calendar day than publication and is recent enough.
6
+ */
7
+ import { DAY_MS } from "./featured.js";
8
+ export const RECENT_UPDATE_WINDOW_DAYS = 60;
9
+ export const RECENT_UPDATE_MAX = 3;
10
+ /** The one "Updated" test: calendar days, not raw strings. The cards, the byline and the shelf share it. */
11
+ export function isUpdatedAfterPublication({ datePublished, dateModified }) {
12
+ return Boolean(dateModified && (!datePublished || dateModified.slice(0, 10) !== datePublished.slice(0, 10)));
13
+ }
14
+ function utcDay(ms) {
15
+ return new Date(ms).toISOString().slice(0, 10);
16
+ }
17
+ /**
18
+ * Up to `max` articles updated within `windowDays` calendar days of `now`, newest update first.
19
+ * Days are the stamp's own calendar date, as in `isUpdatedAfterPublication`, so a date-only value and a
20
+ * timestamp on the same date fall on the same side of the window. The window runs from the UTC day of `now`
21
+ * back `windowDays` days, inclusive; a date after that day never qualifies, so a build-day rewrite stays in
22
+ * even though `buildNow()` is midnight UTC. `exclude` drops articles already shown elsewhere on the page, and
23
+ * an unparseable `dateModified` never qualifies.
24
+ */
25
+ export function selectRecentlyUpdated(articles, options) {
26
+ const { datesOf, now, exclude = [], windowDays = RECENT_UPDATE_WINDOW_DAYS, max = RECENT_UPDATE_MAX } = options;
27
+ const skip = new Set(exclude);
28
+ const today = utcDay(now.getTime());
29
+ const oldest = utcDay(now.getTime() - windowDays * DAY_MS);
30
+ return articles
31
+ .map((article, index) => ({ article, index, dates: datesOf(article) }))
32
+ .filter(({ article, dates }) => !skip.has(article) && isUpdatedAfterPublication(dates))
33
+ .map((e) => {
34
+ const raw = e.dates.dateModified;
35
+ return { ...e, day: raw.slice(0, 10), at: Date.parse(raw.includes('T') ? raw : `${raw}T12:00:00Z`) };
36
+ })
37
+ .filter(({ day, at }) => !Number.isNaN(at) && day >= oldest && day <= today)
38
+ .sort((a, b) => b.at - a.at || a.index - b.index)
39
+ .slice(0, Math.max(0, max))
40
+ .map(({ article }) => article);
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarimarcus/content-sites-core",
3
- "version": "0.37.0",
3
+ "version": "0.38.1",
4
4
  "description": "Non-visual utilities, Astro config builders and SEO schema assembly shared by the content sites.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -22,7 +22,7 @@ export interface FeaturedSelection<T> {
22
22
  export const FEATURED_SHELF_SIZE = 3;
23
23
  export const FEATURED_MAX_AGE_DAYS = 21;
24
24
 
25
- const DAY_MS = 86_400_000;
25
+ export const DAY_MS = 86_400_000;
26
26
 
27
27
  function snapshotAgeDays(snapshot: FeaturedSnapshot, now: Date): number {
28
28
  const generated = Date.parse(`${snapshot.generatedAt}T00:00:00Z`);
@@ -1,6 +1,8 @@
1
1
  // Public surface of @sarimarcus/content-sites-core/articles.
2
2
  export { selectFeaturedArticles, FEATURED_SHELF_SIZE, FEATURED_MAX_AGE_DAYS } from './featured.ts';
3
3
  export type { FeaturedSnapshot, FeaturedSelection } from './featured.ts';
4
+ export { selectRecentlyUpdated, isUpdatedAfterPublication, RECENT_UPDATE_WINDOW_DAYS, RECENT_UPDATE_MAX } from './recent.ts';
5
+ export type { ArticleDates } from './recent.ts';
4
6
  export {
5
7
  ARTICLE_FORMATS, ARTICLE_SHAPE_UNION, FORMATS, FORMAT_NAMES, LEGACY_SHAPE,
6
8
  shapeFor, checkFormat, checkCounts, checkKeyFactCount, checkWords, countBodyWords, validateShape, articleShapeIssues,
@@ -0,0 +1,59 @@
1
+ /**
2
+ * "Recently updated" selection for the articles hub (SLA-3120).
3
+ *
4
+ * Listings sort by `datePublished` (SLA-2436), so a rewrite is invisible there. This picks the
5
+ * articles whose last update fell on another calendar day than publication and is recent enough.
6
+ */
7
+ import { DAY_MS } from './featured.ts';
8
+
9
+ export interface ArticleDates {
10
+ datePublished?: string;
11
+ dateModified?: string;
12
+ }
13
+
14
+ export const RECENT_UPDATE_WINDOW_DAYS = 60;
15
+ export const RECENT_UPDATE_MAX = 3;
16
+
17
+ /** The one "Updated" test: calendar days, not raw strings. The cards, the byline and the shelf share it. */
18
+ export function isUpdatedAfterPublication({ datePublished, dateModified }: ArticleDates): boolean {
19
+ return Boolean(dateModified && (!datePublished || dateModified.slice(0, 10) !== datePublished.slice(0, 10)));
20
+ }
21
+
22
+ function utcDay(ms: number): string {
23
+ return new Date(ms).toISOString().slice(0, 10);
24
+ }
25
+
26
+ /**
27
+ * Up to `max` articles updated within `windowDays` calendar days of `now`, newest update first.
28
+ * Days are the stamp's own calendar date, as in `isUpdatedAfterPublication`, so a date-only value and a
29
+ * timestamp on the same date fall on the same side of the window. The window runs from the UTC day of `now`
30
+ * back `windowDays` days, inclusive; a date after that day never qualifies, so a build-day rewrite stays in
31
+ * even though `buildNow()` is midnight UTC. `exclude` drops articles already shown elsewhere on the page, and
32
+ * an unparseable `dateModified` never qualifies.
33
+ */
34
+ export function selectRecentlyUpdated<T>(
35
+ articles: readonly T[],
36
+ options: {
37
+ datesOf: (article: T) => ArticleDates;
38
+ now: Date;
39
+ exclude?: Iterable<T>;
40
+ windowDays?: number;
41
+ max?: number;
42
+ },
43
+ ): T[] {
44
+ const { datesOf, now, exclude = [], windowDays = RECENT_UPDATE_WINDOW_DAYS, max = RECENT_UPDATE_MAX } = options;
45
+ const skip = new Set<T>(exclude);
46
+ const today = utcDay(now.getTime());
47
+ const oldest = utcDay(now.getTime() - windowDays * DAY_MS);
48
+ return articles
49
+ .map((article, index) => ({ article, index, dates: datesOf(article) }))
50
+ .filter(({ article, dates }) => !skip.has(article) && isUpdatedAfterPublication(dates))
51
+ .map((e) => {
52
+ const raw = e.dates.dateModified as string;
53
+ return { ...e, day: raw.slice(0, 10), at: Date.parse(raw.includes('T') ? raw : `${raw}T12:00:00Z`) };
54
+ })
55
+ .filter(({ day, at }) => !Number.isNaN(at) && day >= oldest && day <= today)
56
+ .sort((a, b) => b.at - a.at || a.index - b.index)
57
+ .slice(0, Math.max(0, max))
58
+ .map(({ article }) => article);
59
+ }