@sarimarcus/content-sites-core 0.59.0 → 0.60.0
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 +7 -0
- package/dist/url/feed.d.ts +4 -2
- package/dist/url/feed.js +4 -3
- package/dist/url/index.d.ts +1 -1
- package/dist/url/index.js +1 -1
- package/dist/url/routes.d.ts +6 -0
- package/dist/url/routes.js +12 -0
- package/package.json +1 -1
- package/src/url/feed.ts +5 -3
- package/src/url/index.ts +1 -1
- package/src/url/routes.ts +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All packages in the platform release in lockstep; entries are per release version.
|
|
4
4
|
|
|
5
|
+
## 0.60.0 (2026-11-06)
|
|
6
|
+
|
|
7
|
+
Opt-in nested article URLs. Defaults keep `/articles/<slug>`.
|
|
8
|
+
|
|
9
|
+
- `url`: new `articleItem` route kind (default `articles`) and `articlePath(slug, category, routes)`. A site that sets `routes.articleItem` to `articles/{category}` gets `/articles/<category>/<slug>`; an article with no category falls back to the flat `articles` segment.
|
|
10
|
+
- `articleFeedItem` takes an optional `routes` and `FeedArticle` an optional `category`, so the RSS link follows `articlePath`.
|
|
11
|
+
|
|
5
12
|
## 0.59.0 (2026-11-06)
|
|
6
13
|
|
|
7
14
|
- No changes (lockstep release).
|
package/dist/url/feed.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type SiteRoutes } from './routes.ts';
|
|
1
2
|
export interface FeedArticle {
|
|
2
3
|
title: string;
|
|
3
4
|
description: string;
|
|
4
5
|
/** ISO datetime with offset; a legacy date-only value is read as noon UTC. */
|
|
5
6
|
datePublished: string;
|
|
6
7
|
slug: string;
|
|
8
|
+
category?: string | null;
|
|
7
9
|
}
|
|
8
10
|
export interface FeedItem {
|
|
9
11
|
title: string;
|
|
@@ -14,7 +16,7 @@ export interface FeedItem {
|
|
|
14
16
|
author?: string;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
|
-
* One @astrojs/rss item for an article: a relative
|
|
19
|
+
* One @astrojs/rss item for an article: a relative article link (`articlePath`) (resolved against the feed's `site`) and its
|
|
18
20
|
* 1200×675 OG image as `media:content`, so the feed needs `xmlns: { media: 'http://search.yahoo.com/mrss/' }`.
|
|
19
21
|
*/
|
|
20
|
-
export declare function articleFeedItem(article: FeedArticle, site: URL, author?: string): FeedItem;
|
|
22
|
+
export declare function articleFeedItem(article: FeedArticle, site: URL, author?: string, routes?: SiteRoutes): FeedItem;
|
package/dist/url/feed.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { getOgImagePath } from "./ogImage.js";
|
|
2
|
+
import { articlePath } from "./routes.js";
|
|
2
3
|
/**
|
|
3
|
-
* One @astrojs/rss item for an article: a relative
|
|
4
|
+
* One @astrojs/rss item for an article: a relative article link (`articlePath`) (resolved against the feed's `site`) and its
|
|
4
5
|
* 1200×675 OG image as `media:content`, so the feed needs `xmlns: { media: 'http://search.yahoo.com/mrss/' }`.
|
|
5
6
|
*/
|
|
6
|
-
export function articleFeedItem(article, site, author) {
|
|
7
|
+
export function articleFeedItem(article, site, author, routes = {}) {
|
|
7
8
|
const { datePublished } = article;
|
|
8
9
|
return {
|
|
9
10
|
title: article.title,
|
|
10
11
|
description: article.description,
|
|
11
12
|
pubDate: datePublished.includes('T') ? new Date(datePublished) : new Date(`${datePublished}T12:00:00+00:00`),
|
|
12
|
-
link:
|
|
13
|
+
link: articlePath(article.slug, article.category, routes),
|
|
13
14
|
customData: `<media:content url="${new URL(getOgImagePath('articles', article.slug), site)}" medium="image" type="image/jpeg" width="1200" height="675" />`,
|
|
14
15
|
...(author ? { author } : {}),
|
|
15
16
|
};
|
package/dist/url/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { buildImageMap } from './imageMap.ts';
|
|
|
5
5
|
export { articleFeedItem } from './feed.ts';
|
|
6
6
|
export type { FeedArticle, FeedItem } from './feed.ts';
|
|
7
7
|
export { pageTypeOf } from './pageType.ts';
|
|
8
|
-
export { DEFAULT_ROUTES, routePath, routeSegment } from './routes.ts';
|
|
8
|
+
export { DEFAULT_ROUTES, articlePath, routePath, routeSegment } from './routes.ts';
|
|
9
9
|
export type { RouteKind, SiteRoutes } from './routes.ts';
|
|
10
10
|
export { outboundClassifier, outboundHostKey, applyOutboundRel } from './outbound.ts';
|
|
11
11
|
export type { OutboundDomainStore } from './outbound.ts';
|
package/dist/url/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export { normalizeHref, extractProseHrefs, dedupRelated } from "./relatedDedup.j
|
|
|
5
5
|
export { buildImageMap } from "./imageMap.js";
|
|
6
6
|
export { articleFeedItem } from "./feed.js";
|
|
7
7
|
export { pageTypeOf } from "./pageType.js";
|
|
8
|
-
export { DEFAULT_ROUTES, routePath, routeSegment } from "./routes.js";
|
|
8
|
+
export { DEFAULT_ROUTES, articlePath, routePath, routeSegment } from "./routes.js";
|
|
9
9
|
export { outboundClassifier, outboundHostKey, applyOutboundRel } from "./outbound.js";
|
|
10
10
|
export { RELATED_ZONE_ROLES, closerHeading, featuredInGuides, buildTakenHrefs } from "./relatedZone.js";
|
package/dist/url/routes.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
|
|
2
2
|
export declare const DEFAULT_ROUTES: {
|
|
3
3
|
readonly articles: "articles";
|
|
4
|
+
readonly articleItem: "articles";
|
|
4
5
|
readonly articleTopic: "articles/topic";
|
|
5
6
|
readonly articleTag: "articles/tag";
|
|
6
7
|
readonly author: "author";
|
|
@@ -13,3 +14,8 @@ export type SiteRoutes = Partial<Record<RouteKind, string>>;
|
|
|
13
14
|
export declare function routeSegment(kind: string, routes?: Partial<Record<string, string>>): string;
|
|
14
15
|
/** `/<segment>` for `kind`, or `/<segment>/<slug>`, from `routes` first and then the default. Base path not applied. */
|
|
15
16
|
export declare function routePath(kind: RouteKind, slug?: string, routes?: SiteRoutes): string;
|
|
17
|
+
/**
|
|
18
|
+
* `/<segment>/<slug>` of one article; `articleItem` defaults to the site's `articles` segment. `articleItem` may carry a `{category}` token (`articles/{category}`) that is
|
|
19
|
+
* replaced by the article's category; an article with no category falls back to the flat `articles` segment.
|
|
20
|
+
*/
|
|
21
|
+
export declare function articlePath(slug: string, category?: string | null, routes?: SiteRoutes): string;
|
package/dist/url/routes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
|
|
2
2
|
export const DEFAULT_ROUTES = {
|
|
3
3
|
articles: 'articles',
|
|
4
|
+
articleItem: 'articles',
|
|
4
5
|
articleTopic: 'articles/topic',
|
|
5
6
|
articleTag: 'articles/tag',
|
|
6
7
|
author: 'author',
|
|
@@ -16,3 +17,14 @@ export function routePath(kind, slug, routes = {}) {
|
|
|
16
17
|
const segment = routeSegment(kind, routes);
|
|
17
18
|
return slug === undefined ? `/${segment}` : `/${segment}/${slug}`;
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* `/<segment>/<slug>` of one article; `articleItem` defaults to the site's `articles` segment. `articleItem` may carry a `{category}` token (`articles/{category}`) that is
|
|
22
|
+
* replaced by the article's category; an article with no category falls back to the flat `articles` segment.
|
|
23
|
+
*/
|
|
24
|
+
export function articlePath(slug, category, routes = {}) {
|
|
25
|
+
const segment = routes.articleItem ?? routeSegment('articles', routes);
|
|
26
|
+
if (!segment.includes('{category}'))
|
|
27
|
+
return `/${segment}/${slug}`;
|
|
28
|
+
const resolved = category ? segment.replace('{category}', category) : routeSegment('articles', routes);
|
|
29
|
+
return `/${resolved}/${slug}`;
|
|
30
|
+
}
|
package/package.json
CHANGED
package/src/url/feed.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getOgImagePath } from './ogImage.ts';
|
|
2
|
+
import { articlePath, type SiteRoutes } from './routes.ts';
|
|
2
3
|
|
|
3
4
|
export interface FeedArticle {
|
|
4
5
|
title: string;
|
|
@@ -6,6 +7,7 @@ export interface FeedArticle {
|
|
|
6
7
|
/** ISO datetime with offset; a legacy date-only value is read as noon UTC. */
|
|
7
8
|
datePublished: string;
|
|
8
9
|
slug: string;
|
|
10
|
+
category?: string | null;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export interface FeedItem {
|
|
@@ -18,16 +20,16 @@ export interface FeedItem {
|
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
/**
|
|
21
|
-
* One @astrojs/rss item for an article: a relative
|
|
23
|
+
* One @astrojs/rss item for an article: a relative article link (`articlePath`) (resolved against the feed's `site`) and its
|
|
22
24
|
* 1200×675 OG image as `media:content`, so the feed needs `xmlns: { media: 'http://search.yahoo.com/mrss/' }`.
|
|
23
25
|
*/
|
|
24
|
-
export function articleFeedItem(article: FeedArticle, site: URL, author?: string): FeedItem {
|
|
26
|
+
export function articleFeedItem(article: FeedArticle, site: URL, author?: string, routes: SiteRoutes = {}): FeedItem {
|
|
25
27
|
const { datePublished } = article;
|
|
26
28
|
return {
|
|
27
29
|
title: article.title,
|
|
28
30
|
description: article.description,
|
|
29
31
|
pubDate: datePublished.includes('T') ? new Date(datePublished) : new Date(`${datePublished}T12:00:00+00:00`),
|
|
30
|
-
link:
|
|
32
|
+
link: articlePath(article.slug, article.category, routes),
|
|
31
33
|
customData: `<media:content url="${new URL(getOgImagePath('articles', article.slug), site)}" medium="image" type="image/jpeg" width="1200" height="675" />`,
|
|
32
34
|
...(author ? { author } : {}),
|
|
33
35
|
};
|
package/src/url/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { buildImageMap } from './imageMap.ts';
|
|
|
6
6
|
export { articleFeedItem } from './feed.ts';
|
|
7
7
|
export type { FeedArticle, FeedItem } from './feed.ts';
|
|
8
8
|
export { pageTypeOf } from './pageType.ts';
|
|
9
|
-
export { DEFAULT_ROUTES, routePath, routeSegment } from './routes.ts';
|
|
9
|
+
export { DEFAULT_ROUTES, articlePath, routePath, routeSegment } from './routes.ts';
|
|
10
10
|
export type { RouteKind, SiteRoutes } from './routes.ts';
|
|
11
11
|
export { outboundClassifier, outboundHostKey, applyOutboundRel } from './outbound.ts';
|
|
12
12
|
export type { OutboundDomainStore } from './outbound.ts';
|
package/src/url/routes.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** The site routes package components link to, kind → path segment. A site's `routes` prop overrides any of them. */
|
|
2
2
|
export const DEFAULT_ROUTES = {
|
|
3
3
|
articles: 'articles',
|
|
4
|
+
articleItem: 'articles',
|
|
4
5
|
articleTopic: 'articles/topic',
|
|
5
6
|
articleTag: 'articles/tag',
|
|
6
7
|
author: 'author',
|
|
@@ -21,3 +22,14 @@ export function routePath(kind: RouteKind, slug?: string, routes: SiteRoutes = {
|
|
|
21
22
|
const segment = routeSegment(kind, routes);
|
|
22
23
|
return slug === undefined ? `/${segment}` : `/${segment}/${slug}`;
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* `/<segment>/<slug>` of one article; `articleItem` defaults to the site's `articles` segment. `articleItem` may carry a `{category}` token (`articles/{category}`) that is
|
|
28
|
+
* replaced by the article's category; an article with no category falls back to the flat `articles` segment.
|
|
29
|
+
*/
|
|
30
|
+
export function articlePath(slug: string, category?: string | null, routes: SiteRoutes = {}): string {
|
|
31
|
+
const segment = routes.articleItem ?? routeSegment('articles', routes);
|
|
32
|
+
if (!segment.includes('{category}')) return `/${segment}/${slug}`;
|
|
33
|
+
const resolved = category ? segment.replace('{category}', category) : routeSegment('articles', routes);
|
|
34
|
+
return `/${resolved}/${slug}`;
|
|
35
|
+
}
|