@geekity/cms 0.12.0 → 0.13.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/README.md +170 -4
- package/admin/pages/account/login.njk +3 -0
- package/admin/pages/documents/editor.njk +7 -0
- package/admin/pages/indieauth/consent.njk +51 -0
- package/admin/pages/indieauth/refused.njk +11 -0
- package/admin/pages/settings/general.njk +9 -0
- package/admin/pages/settings/reading.njk +93 -0
- package/admin/pages/users/apps.njk +74 -0
- package/admin/pages/users/edit.njk +12 -0
- package/admin/static/admin.css +27 -0
- package/dist/admin/accounts.d.ts +3 -0
- package/dist/admin/accounts.d.ts.map +1 -1
- package/dist/admin/accounts.js +5 -0
- package/dist/admin/accounts.js.map +1 -1
- package/dist/admin/documents.d.ts +2 -0
- package/dist/admin/documents.d.ts.map +1 -1
- package/dist/admin/documents.js +17 -1
- package/dist/admin/documents.js.map +1 -1
- package/dist/admin/headers.d.ts +5 -1
- package/dist/admin/headers.d.ts.map +1 -1
- package/dist/admin/headers.js +7 -3
- package/dist/admin/headers.js.map +1 -1
- package/dist/admin/menu.d.ts.map +1 -1
- package/dist/admin/menu.js +2 -1
- package/dist/admin/menu.js.map +1 -1
- package/dist/admin/routes.d.ts.map +1 -1
- package/dist/admin/routes.js +48 -5
- package/dist/admin/routes.js.map +1 -1
- package/dist/admin/settings-general.js +1 -1
- package/dist/admin/settings-general.js.map +1 -1
- package/dist/admin/settings-reading.d.ts.map +1 -1
- package/dist/admin/settings-reading.js +15 -1
- package/dist/admin/settings-reading.js.map +1 -1
- package/dist/admin/settings.d.ts +79 -2
- package/dist/admin/settings.d.ts.map +1 -1
- package/dist/admin/settings.js +168 -2
- package/dist/admin/settings.js.map +1 -1
- package/dist/admin/templates.d.ts +3 -0
- package/dist/admin/templates.d.ts.map +1 -1
- package/dist/admin/templates.js +3 -0
- package/dist/admin/templates.js.map +1 -1
- package/dist/admin/users.d.ts +8 -0
- package/dist/admin/users.d.ts.map +1 -1
- package/dist/admin/users.js +9 -0
- package/dist/admin/users.js.map +1 -1
- package/dist/config.d.ts +30 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/env.d.ts +14 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/federation/article.d.ts.map +1 -1
- package/dist/federation/article.js +18 -5
- package/dist/federation/article.js.map +1 -1
- package/dist/images/icons.d.ts +44 -25
- package/dist/images/icons.d.ts.map +1 -1
- package/dist/images/icons.js +205 -60
- package/dist/images/icons.js.map +1 -1
- package/dist/images/index.d.ts +2 -2
- package/dist/images/index.d.ts.map +1 -1
- package/dist/images/index.js +1 -1
- package/dist/images/index.js.map +1 -1
- package/dist/images/markup.d.ts +14 -0
- package/dist/images/markup.d.ts.map +1 -1
- package/dist/images/markup.js +16 -11
- package/dist/images/markup.js.map +1 -1
- package/dist/images/variants.d.ts.map +1 -1
- package/dist/images/variants.js +3 -4
- package/dist/images/variants.js.map +1 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/indexnow.d.ts +34 -0
- package/dist/indexnow.d.ts.map +1 -0
- package/dist/indexnow.js +141 -0
- package/dist/indexnow.js.map +1 -0
- package/dist/indieauth/bearer.d.ts +39 -0
- package/dist/indieauth/bearer.d.ts.map +1 -0
- package/dist/indieauth/bearer.js +63 -0
- package/dist/indieauth/bearer.js.map +1 -0
- package/dist/indieauth/client.d.ts +61 -0
- package/dist/indieauth/client.d.ts.map +1 -0
- package/dist/indieauth/client.js +139 -0
- package/dist/indieauth/client.js.map +1 -0
- package/dist/indieauth/connected-apps.d.ts +23 -0
- package/dist/indieauth/connected-apps.d.ts.map +1 -0
- package/dist/indieauth/connected-apps.js +73 -0
- package/dist/indieauth/connected-apps.js.map +1 -0
- package/dist/indieauth/consent.d.ts +28 -0
- package/dist/indieauth/consent.d.ts.map +1 -0
- package/dist/indieauth/consent.js +185 -0
- package/dist/indieauth/consent.js.map +1 -0
- package/dist/indieauth/discovery.d.ts +87 -0
- package/dist/indieauth/discovery.d.ts.map +1 -0
- package/dist/indieauth/discovery.js +127 -0
- package/dist/indieauth/discovery.js.map +1 -0
- package/dist/indieauth/grants.d.ts +57 -0
- package/dist/indieauth/grants.d.ts.map +1 -0
- package/dist/indieauth/grants.js +35 -0
- package/dist/indieauth/grants.js.map +1 -0
- package/dist/indieauth/identity.d.ts +36 -0
- package/dist/indieauth/identity.d.ts.map +1 -0
- package/dist/indieauth/identity.js +78 -0
- package/dist/indieauth/identity.js.map +1 -0
- package/dist/indieauth/redeem.d.ts +47 -0
- package/dist/indieauth/redeem.d.ts.map +1 -0
- package/dist/indieauth/redeem.js +69 -0
- package/dist/indieauth/redeem.js.map +1 -0
- package/dist/indieauth/request.d.ts +47 -0
- package/dist/indieauth/request.d.ts.map +1 -0
- package/dist/indieauth/request.js +104 -0
- package/dist/indieauth/request.js.map +1 -0
- package/dist/indieauth/token.d.ts +19 -0
- package/dist/indieauth/token.d.ts.map +1 -0
- package/dist/indieauth/token.js +110 -0
- package/dist/indieauth/token.js.map +1 -0
- package/dist/indieauth/tokens.d.ts +131 -0
- package/dist/indieauth/tokens.d.ts.map +1 -0
- package/dist/indieauth/tokens.js +205 -0
- package/dist/indieauth/tokens.js.map +1 -0
- package/dist/web/archive.d.ts +1 -1
- package/dist/web/archive.d.ts.map +1 -1
- package/dist/web/archive.js +3 -2
- package/dist/web/archive.js.map +1 -1
- package/dist/web/context.d.ts +25 -0
- package/dist/web/context.d.ts.map +1 -1
- package/dist/web/context.js +18 -0
- package/dist/web/context.js.map +1 -1
- package/dist/web/feed-atom.d.ts.map +1 -1
- package/dist/web/feed-atom.js +3 -1
- package/dist/web/feed-atom.js.map +1 -1
- package/dist/web/feed-item.d.ts +11 -2
- package/dist/web/feed-item.d.ts.map +1 -1
- package/dist/web/feed-item.js +9 -3
- package/dist/web/feed-item.js.map +1 -1
- package/dist/web/feed-json.d.ts +4 -0
- package/dist/web/feed-json.d.ts.map +1 -1
- package/dist/web/feed-json.js +4 -1
- package/dist/web/feed-json.js.map +1 -1
- package/dist/web/feed-rss.d.ts.map +1 -1
- package/dist/web/feed-rss.js +16 -3
- package/dist/web/feed-rss.js.map +1 -1
- package/dist/web/feed-source.d.ts +28 -0
- package/dist/web/feed-source.d.ts.map +1 -1
- package/dist/web/feed-source.js +31 -0
- package/dist/web/feed-source.js.map +1 -1
- package/dist/web/feed-xml.d.ts +2 -0
- package/dist/web/feed-xml.d.ts.map +1 -1
- package/dist/web/feed-xml.js +2 -0
- package/dist/web/feed-xml.js.map +1 -1
- package/dist/web/feeds.d.ts.map +1 -1
- package/dist/web/feeds.js +8 -1
- package/dist/web/feeds.js.map +1 -1
- package/dist/web/index.d.ts +3 -1
- package/dist/web/index.d.ts.map +1 -1
- package/dist/web/index.js +2 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/indexnow.d.ts +9 -0
- package/dist/web/indexnow.d.ts.map +1 -0
- package/dist/web/indexnow.js +27 -0
- package/dist/web/indexnow.js.map +1 -0
- package/dist/web/llms.d.ts +58 -0
- package/dist/web/llms.d.ts.map +1 -0
- package/dist/web/llms.js +91 -0
- package/dist/web/llms.js.map +1 -0
- package/dist/web/locale.d.ts +41 -0
- package/dist/web/locale.d.ts.map +1 -0
- package/dist/web/locale.js +56 -0
- package/dist/web/locale.js.map +1 -0
- package/dist/web/manifest.d.ts +50 -0
- package/dist/web/manifest.d.ts.map +1 -0
- package/dist/web/manifest.js +56 -0
- package/dist/web/manifest.js.map +1 -0
- package/dist/web/negotiate.d.ts.map +1 -1
- package/dist/web/negotiate.js +6 -0
- package/dist/web/negotiate.js.map +1 -1
- package/dist/web/render.d.ts +6 -1
- package/dist/web/render.d.ts.map +1 -1
- package/dist/web/render.js +41 -10
- package/dist/web/render.js.map +1 -1
- package/dist/web/robots.d.ts +89 -0
- package/dist/web/robots.d.ts.map +1 -0
- package/dist/web/robots.js +259 -0
- package/dist/web/robots.js.map +1 -0
- package/dist/web/routes.d.ts.map +1 -1
- package/dist/web/routes.js +105 -6
- package/dist/web/routes.js.map +1 -1
- package/dist/web/share-image.d.ts +51 -0
- package/dist/web/share-image.d.ts.map +1 -0
- package/dist/web/share-image.js +43 -0
- package/dist/web/share-image.js.map +1 -0
- package/dist/web/sitemap.d.ts +0 -26
- package/dist/web/sitemap.d.ts.map +1 -1
- package/dist/web/sitemap.js +0 -44
- package/dist/web/sitemap.js.map +1 -1
- package/dist/web/templates.d.ts +16 -9
- package/dist/web/templates.d.ts.map +1 -1
- package/dist/web/templates.js +83 -55
- package/dist/web/templates.js.map +1 -1
- package/dist/web/themes.d.ts +33 -0
- package/dist/web/themes.d.ts.map +1 -1
- package/dist/web/themes.js +57 -0
- package/dist/web/themes.js.map +1 -1
- package/dist/webmention/discovery.d.ts +4 -2
- package/dist/webmention/discovery.d.ts.map +1 -1
- package/dist/webmention/discovery.js +14 -8
- package/dist/webmention/discovery.js.map +1 -1
- package/dist/webmention/fetch-public.d.ts +2 -0
- package/dist/webmention/fetch-public.d.ts.map +1 -1
- package/dist/webmention/fetch-public.js +1 -1
- package/dist/webmention/fetch-public.js.map +1 -1
- package/package.json +1 -1
- package/themes/default/README.md +119 -29
- package/themes/default/layouts/base.njk +95 -16
- package/themes/default/layouts/front-page.njk +6 -1
- package/themes/default/layouts/home.njk +10 -0
- package/themes/default/layouts/page.njk +4 -3
- package/themes/default/layouts/post.njk +5 -4
- package/themes/default/layouts/search.njk +4 -5
- package/themes/default/partials/archive.njk +3 -1
- package/themes/default/partials/bio.njk +9 -2
- package/themes/default/partials/breadcrumbs.njk +20 -0
- package/themes/default/partials/conversation.njk +4 -1
- package/themes/default/partials/jsonld.njk +19 -4
- package/themes/default/partials/kicker.njk +6 -4
- package/themes/default/partials/lang.njk +7 -0
- package/themes/default/partials/post-list.njk +5 -3
- package/themes/default/partials/reply-context.njk +4 -2
- package/themes/default/src/style.css +14 -0
- package/themes/default/static/style.css +53 -0
- package/themes/default/theme.json +2 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ImageConfig } from '../images/paths.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The picture a link to a page is shown with when somebody posts it: the
|
|
4
|
+
* `og:image` and the Twitter card's image, and everything said about it
|
|
5
|
+
* (TASK-146).
|
|
6
|
+
*/
|
|
7
|
+
export interface ShareImage {
|
|
8
|
+
/** Where it is, as the front matter or the site setting wrote it. */
|
|
9
|
+
readonly url: string;
|
|
10
|
+
/** What it shows, for `og:image:alt`. Never empty: an image is never printed without one. */
|
|
11
|
+
readonly alt: string;
|
|
12
|
+
/** Its size, when the variant sidecar has recorded one. */
|
|
13
|
+
readonly size?: {
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
} | undefined;
|
|
17
|
+
/** The Twitter card it fits: a large picture above the words, or a small one beside them. */
|
|
18
|
+
readonly card: 'summary' | 'summary_large_image';
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* How wide a picture has to be for a large card: the width Open Graph
|
|
22
|
+
* consumers recommend, and the one Google Discover requires before it shows a
|
|
23
|
+
* large preview.
|
|
24
|
+
*/
|
|
25
|
+
export declare const LARGE_CARD_MIN_WIDTH = 1200;
|
|
26
|
+
/**
|
|
27
|
+
* The page's share image, or `undefined` when it has none: the entry's own
|
|
28
|
+
* `image`, else the site's avatar.
|
|
29
|
+
*
|
|
30
|
+
* The alt text is the front matter's `imageAlt` for the entry's own picture,
|
|
31
|
+
* because one picture can need describing differently in two posts; else what
|
|
32
|
+
* the media library says about the upload; else the entry's title for its own
|
|
33
|
+
* picture and the site's author for the avatar, which is a picture of them.
|
|
34
|
+
*
|
|
35
|
+
* The size is read off the variant sidecar, never off the file, so a render
|
|
36
|
+
* never opens an image (decision-10). A picture with no sidecar has no size
|
|
37
|
+
* and gets the small card until one has been derived.
|
|
38
|
+
*/
|
|
39
|
+
export declare function shareImage(input: {
|
|
40
|
+
config: ImageConfig;
|
|
41
|
+
/** The front matter's `image`, whatever type it turned out to be. */
|
|
42
|
+
image: unknown;
|
|
43
|
+
/** The front matter's `imageAlt`. */
|
|
44
|
+
imageAlt: unknown;
|
|
45
|
+
/** What the page is called, for an undescribed picture of its own. */
|
|
46
|
+
title: string;
|
|
47
|
+
/** The site's avatar, and who it is a picture of. */
|
|
48
|
+
avatar: string | undefined;
|
|
49
|
+
owner: string;
|
|
50
|
+
}): ShareImage | undefined;
|
|
51
|
+
//# sourceMappingURL=share-image.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-image.d.ts","sourceRoot":"","sources":["../../src/web/share-image.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,qEAAqE;IACrE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IAChF,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,qBAAqB,CAAC;CAClD;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,MAAM,EAAE,WAAW,CAAC;IACpB,qEAAqE;IACrE,KAAK,EAAE,OAAO,CAAC;IACf,qCAAqC;IACrC,QAAQ,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,UAAU,GAAG,SAAS,CAmBzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { readAltTexts } from '../images/alt-text.js';
|
|
2
|
+
import { siteImageRecord, uploadPath } from '../images/markup.js';
|
|
3
|
+
/**
|
|
4
|
+
* How wide a picture has to be for a large card: the width Open Graph
|
|
5
|
+
* consumers recommend, and the one Google Discover requires before it shows a
|
|
6
|
+
* large preview.
|
|
7
|
+
*/
|
|
8
|
+
export const LARGE_CARD_MIN_WIDTH = 1200;
|
|
9
|
+
/**
|
|
10
|
+
* The page's share image, or `undefined` when it has none: the entry's own
|
|
11
|
+
* `image`, else the site's avatar.
|
|
12
|
+
*
|
|
13
|
+
* The alt text is the front matter's `imageAlt` for the entry's own picture,
|
|
14
|
+
* because one picture can need describing differently in two posts; else what
|
|
15
|
+
* the media library says about the upload; else the entry's title for its own
|
|
16
|
+
* picture and the site's author for the avatar, which is a picture of them.
|
|
17
|
+
*
|
|
18
|
+
* The size is read off the variant sidecar, never off the file, so a render
|
|
19
|
+
* never opens an image (decision-10). A picture with no sidecar has no size
|
|
20
|
+
* and gets the small card until one has been derived.
|
|
21
|
+
*/
|
|
22
|
+
export function shareImage(input) {
|
|
23
|
+
const own = nonEmpty(input.image);
|
|
24
|
+
const url = own ?? nonEmpty(input.avatar);
|
|
25
|
+
if (url === undefined)
|
|
26
|
+
return undefined;
|
|
27
|
+
const source = uploadPath(url);
|
|
28
|
+
const described = source === undefined ? undefined : readAltTexts(input.config.contentDir).get(source);
|
|
29
|
+
const alt = (own === undefined ? undefined : nonEmpty(input.imageAlt)) ??
|
|
30
|
+
(described?.kind === 'described' ? nonEmpty(described.text) : undefined) ??
|
|
31
|
+
(own === undefined ? input.owner : input.title);
|
|
32
|
+
const record = source === undefined ? undefined : siteImageRecord(input.config, source);
|
|
33
|
+
const size = record === undefined ? undefined : { width: record.width, height: record.height };
|
|
34
|
+
const large = size !== undefined && size.width >= LARGE_CARD_MIN_WIDTH && size.width > size.height;
|
|
35
|
+
return { url, alt, size, card: large ? 'summary_large_image' : 'summary' };
|
|
36
|
+
}
|
|
37
|
+
function nonEmpty(value) {
|
|
38
|
+
if (typeof value !== 'string')
|
|
39
|
+
return undefined;
|
|
40
|
+
const trimmed = value.trim();
|
|
41
|
+
return trimmed === '' ? undefined : trimmed;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=share-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"share-image.js","sourceRoot":"","sources":["../../src/web/share-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAmBlE;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU,CAAC,KAW1B;IACC,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,GAAG,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAExC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,SAAS,GACb,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACvF,MAAM,GAAG,GACP,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC1D,CAAC,SAAS,EAAE,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACxE,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxF,MAAM,IAAI,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;IAC/F,MAAM,KAAK,GACT,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,IAAI,oBAAoB,IAAI,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IAEvF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7E,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9C,CAAC"}
|
package/dist/web/sitemap.d.ts
CHANGED
|
@@ -15,8 +15,6 @@ import type { ConditionalHeaders } from './negotiate.ts';
|
|
|
15
15
|
*/
|
|
16
16
|
/** The sitemap's URL. Fixed: it is the one a `robots.txt` names. */
|
|
17
17
|
export declare const SITEMAP_PATH = "/sitemap.xml";
|
|
18
|
-
/** The robots file's URL. Fixed by the standard; nothing else is looked at. */
|
|
19
|
-
export declare const ROBOTS_PATH = "/robots.txt";
|
|
20
18
|
/** The namespace both a `<urlset>` and a `<sitemapindex>` are written in. */
|
|
21
19
|
export declare const SITEMAP_NAMESPACE = "http://www.sitemaps.org/schemas/sitemap/0.9";
|
|
22
20
|
/**
|
|
@@ -64,8 +62,6 @@ export declare function sitemapXml(urls: readonly SitemapUrl[], baseUrl: string)
|
|
|
64
62
|
export declare function sitemapIndexXml(children: readonly SitemapUrl[], baseUrl: string): string;
|
|
65
63
|
/** What a sitemap is served as. */
|
|
66
64
|
export declare const SITEMAP_CONTENT_TYPE = "application/xml; charset=utf-8";
|
|
67
|
-
/** What a robots file is served as. */
|
|
68
|
-
export declare const ROBOTS_CONTENT_TYPE = "text/plain; charset=utf-8";
|
|
69
65
|
/** Everything one sitemap response needs. */
|
|
70
66
|
export interface SitemapResponseOptions {
|
|
71
67
|
/** Every URL the site publishes, in the order the sitemap should list them. */
|
|
@@ -95,26 +91,4 @@ export interface SitemapResponseOptions {
|
|
|
95
91
|
* and the `Last-Modified` on the 304 it mostly receives.
|
|
96
92
|
*/
|
|
97
93
|
export declare function sitemapResponse(options: SitemapResponseOptions): Response | undefined;
|
|
98
|
-
/**
|
|
99
|
-
* The robots file: everything public is crawlable, the admin is not, and the
|
|
100
|
-
* sitemap is named absolutely because that is the only spelling the standard
|
|
101
|
-
* allows for a `Sitemap:` line.
|
|
102
|
-
*
|
|
103
|
-
* Nothing else is disallowed. The ActivityPub routes under `/ap/` are left
|
|
104
|
-
* open deliberately: an actor and an object are documents meant to be
|
|
105
|
-
* fetched, they carry the same content as the pages that link to them, and a
|
|
106
|
-
* crawler that follows one gets JSON it will ignore. Hiding them would only
|
|
107
|
-
* make the fediverse's own view of the site depend on a file written for
|
|
108
|
-
* search engines.
|
|
109
|
-
*/
|
|
110
|
-
export declare function robotsTxt(baseUrl: string): string;
|
|
111
|
-
/**
|
|
112
|
-
* The robots file as an HTTP response.
|
|
113
|
-
*
|
|
114
|
-
* It has a validator but no `Last-Modified`: nothing dates it. Its body is a
|
|
115
|
-
* function of the site's origin alone, so the ETag moves when that does and
|
|
116
|
-
* never otherwise, which is exactly what a crawler's `If-None-Match` should
|
|
117
|
-
* be told.
|
|
118
|
-
*/
|
|
119
|
-
export declare function robotsResponse(baseUrl: string, conditional?: ConditionalHeaders): Response;
|
|
120
94
|
//# sourceMappingURL=sitemap.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/web/sitemap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sitemap.d.ts","sourceRoot":"","sources":["../../src/web/sitemap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;;;;;;;;;;;GAaG;AAEH,oEAAoE;AACpE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,gDAAgD,CAAC;AAE/E;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,+BAA+B,CAAC;AAEhE,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,qEAAqE;AACrE,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;IACZ,kEAAkE;IAClE,OAAO,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAE9C;AAED,yDAAyD;AACzD,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE/E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAExF;AA2BD,mCAAmC;AACnC,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAErE,6CAA6C;AAC7C,MAAM,WAAW,sBAAsB;IACrC,+EAA+E;IAC/E,IAAI,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5B,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,2DAA2D;IAC3D,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,sDAAsD;IACtD,WAAW,CAAC,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,QAAQ,GAAG,SAAS,CA+BrF"}
|
package/dist/web/sitemap.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ADMIN_PREFIX } from '../admin/session.js';
|
|
2
1
|
import { escapeXml } from './feeds.js';
|
|
3
2
|
import { absoluteUrl, contentEtag, isNotModified } from './negotiate.js';
|
|
4
3
|
/**
|
|
@@ -17,8 +16,6 @@ import { absoluteUrl, contentEtag, isNotModified } from './negotiate.js';
|
|
|
17
16
|
*/
|
|
18
17
|
/** The sitemap's URL. Fixed: it is the one a `robots.txt` names. */
|
|
19
18
|
export const SITEMAP_PATH = '/sitemap.xml';
|
|
20
|
-
/** The robots file's URL. Fixed by the standard; nothing else is looked at. */
|
|
21
|
-
export const ROBOTS_PATH = '/robots.txt';
|
|
22
19
|
/** The namespace both a `<urlset>` and a `<sitemapindex>` are written in. */
|
|
23
20
|
export const SITEMAP_NAMESPACE = 'http://www.sitemaps.org/schemas/sitemap/0.9';
|
|
24
21
|
/**
|
|
@@ -84,8 +81,6 @@ function document(root, entries, baseUrl, entryName) {
|
|
|
84
81
|
}
|
|
85
82
|
/** What a sitemap is served as. */
|
|
86
83
|
export const SITEMAP_CONTENT_TYPE = 'application/xml; charset=utf-8';
|
|
87
|
-
/** What a robots file is served as. */
|
|
88
|
-
export const ROBOTS_CONTENT_TYPE = 'text/plain; charset=utf-8';
|
|
89
84
|
/**
|
|
90
85
|
* One sitemap as an HTTP response, or `undefined` when the URL names a child
|
|
91
86
|
* that does not exist and the caller owes a 404.
|
|
@@ -157,43 +152,4 @@ function fingerprint(entries, baseUrl, page) {
|
|
|
157
152
|
...entries.map((entry) => `${entry.loc} ${entry.lastmod?.toISOString() ?? ''}`),
|
|
158
153
|
].join('\n');
|
|
159
154
|
}
|
|
160
|
-
/**
|
|
161
|
-
* The robots file: everything public is crawlable, the admin is not, and the
|
|
162
|
-
* sitemap is named absolutely because that is the only spelling the standard
|
|
163
|
-
* allows for a `Sitemap:` line.
|
|
164
|
-
*
|
|
165
|
-
* Nothing else is disallowed. The ActivityPub routes under `/ap/` are left
|
|
166
|
-
* open deliberately: an actor and an object are documents meant to be
|
|
167
|
-
* fetched, they carry the same content as the pages that link to them, and a
|
|
168
|
-
* crawler that follows one gets JSON it will ignore. Hiding them would only
|
|
169
|
-
* make the fediverse's own view of the site depend on a file written for
|
|
170
|
-
* search engines.
|
|
171
|
-
*/
|
|
172
|
-
export function robotsTxt(baseUrl) {
|
|
173
|
-
return [
|
|
174
|
-
'User-agent: *',
|
|
175
|
-
`Disallow: ${ADMIN_PREFIX}/`,
|
|
176
|
-
'',
|
|
177
|
-
`Sitemap: ${absoluteUrl(SITEMAP_PATH, baseUrl)}`,
|
|
178
|
-
'',
|
|
179
|
-
].join('\n');
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* The robots file as an HTTP response.
|
|
183
|
-
*
|
|
184
|
-
* It has a validator but no `Last-Modified`: nothing dates it. Its body is a
|
|
185
|
-
* function of the site's origin alone, so the ETag moves when that does and
|
|
186
|
-
* never otherwise, which is exactly what a crawler's `If-None-Match` should
|
|
187
|
-
* be told.
|
|
188
|
-
*/
|
|
189
|
-
export function robotsResponse(baseUrl, conditional) {
|
|
190
|
-
const body = robotsTxt(baseUrl);
|
|
191
|
-
const etag = contentEtag('robots', body);
|
|
192
|
-
const headers = new Headers({ etag, 'cache-control': 'no-cache' });
|
|
193
|
-
if (isNotModified(conditional, etag, undefined)) {
|
|
194
|
-
return new Response(null, { status: 304, headers });
|
|
195
|
-
}
|
|
196
|
-
headers.set('content-type', ROBOTS_CONTENT_TYPE);
|
|
197
|
-
return new Response(body, { headers });
|
|
198
|
-
}
|
|
199
155
|
//# sourceMappingURL=sitemap.js.map
|
package/dist/web/sitemap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/web/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../../src/web/sitemap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGzE;;;;;;;;;;;;;GAaG;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,6CAA6C,CAAC;AAE/E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AAEhE,2DAA2D;AAC3D,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,YAAY,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AACxC,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,IAAU;IACpC,OAAO,IAAI,CA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AC1C,IAAI,MAAM,KAAK,SAAS,IAAI,KAAK,CAAC,OAAO,GAAG,MAAM;YAAE,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC;IAC7E,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iEAAiE;AACjE,SAAS,WAAW,CAClB,OAA8B,EAC9B,OAAe,EACf,IAAwB;IAExB,OAAO;QACL,OAAO;QACP,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAC3C,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC;KAChF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/web/templates.d.ts
CHANGED
|
@@ -53,20 +53,27 @@ export declare function createTemplateEnvironment(options: CreateTemplateEnviron
|
|
|
53
53
|
*/
|
|
54
54
|
export declare function useThemeDirs(environment: Environment, dirs: readonly string[]): void;
|
|
55
55
|
/** How `date` renders a value. */
|
|
56
|
-
export type DateFormat = 'readable' | 'iso' | 'html' | 'year' | 'month';
|
|
56
|
+
export type DateFormat = 'readable' | 'full' | 'long' | 'medium' | 'short' | 'iso' | 'html' | 'year' | 'month';
|
|
57
57
|
/**
|
|
58
|
-
* `date` filter. An unparseable value renders as the empty string
|
|
58
|
+
* `date` filter. An unparseable value renders as the empty string, and so
|
|
59
|
+
* does a zone Intl does not know.
|
|
59
60
|
*
|
|
60
61
|
* `iso` is the instant, always in UTC, because that is what a `<time
|
|
61
|
-
* datetime>` and a feed want and it must not move when a setting does.
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
62
|
+
* datetime>` and a feed want and it must not move when a setting does. `html`
|
|
63
|
+
* is the ISO calendar day in `timezone`, for the same attribute. The rest are
|
|
64
|
+
* that calendar day written in `locale` by Intl, which is what makes a post
|
|
65
|
+
* published at half past midnight in Berlin say 1 October rather than the 30
|
|
66
|
+
* September UTC was still on, and a French site say `1 octobre`.
|
|
65
67
|
*
|
|
66
68
|
* `month` is the month that calendar day falls in, "September 2026", which is
|
|
67
69
|
* what heads a group of an archive page (TASK-85). It is a format rather than
|
|
68
|
-
* something the archive works out for itself so that
|
|
69
|
-
*
|
|
70
|
+
* something the archive works out for itself so that a theme can head a group
|
|
71
|
+
* of its own the same way.
|
|
72
|
+
*
|
|
73
|
+
* Bare `en` is written the way `en-GB` writes it, day before month, because
|
|
74
|
+
* that is what the CMS printed before it had locales and `en` names a language
|
|
75
|
+
* rather than a convention. A site that wants `September 2, 2026` says
|
|
76
|
+
* `en-US`.
|
|
70
77
|
*/
|
|
71
|
-
export declare function formatDate(value: unknown, format: string, timezone?: string): string;
|
|
78
|
+
export declare function formatDate(value: unknown, format: string, timezone?: string, locale?: string): string;
|
|
72
79
|
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/web/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/web/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAoB,MAAM,UAAU,CAAC;AASzD,0EAA0E;AAC1E,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAC1C,8DAA8D;IAC9D,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,gCAAgC,GAAG,WAAW,CAahG;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAiBpF;AAED,kCAAkC;AAClC,MAAM,MAAM,UAAU,GACpB,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAgHxF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,GAAE,MAAyB,EACnC,MAAM,GAAE,MAAuB,GAC9B,MAAM,CAwBR"}
|
package/dist/web/templates.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Environment, FileSystemLoader } from 'nunjucks';
|
|
2
2
|
import { calendarDayIn, DEFAULT_TIMEZONE } from '../content/time.js';
|
|
3
3
|
import { themeAssetUrl } from './assets.js';
|
|
4
|
+
import { siteLocale, siteTimezone } from './context.js';
|
|
5
|
+
import { canonicalLocale, DEFAULT_LOCALE, pluralForm } from './locale.js';
|
|
4
6
|
import { themeSearchPath } from './themes.js';
|
|
5
7
|
/**
|
|
6
8
|
* A Nunjucks environment whose loader searches the theme directories in the
|
|
@@ -57,20 +59,34 @@ export function useThemeDirs(environment, dirs) {
|
|
|
57
59
|
* are written against it.
|
|
58
60
|
*
|
|
59
61
|
* Per decision-11 a date in a file is a UTC instant and the site's `timezone`
|
|
60
|
-
* setting is the lens it is read through, so
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* the
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
62
|
+
* setting is the lens it is read through, so every format but `iso` is
|
|
63
|
+
* rendered in the site's zone and `iso` stays the instant; the words are the
|
|
64
|
+
* site's locale (TASK-153), unless a template passes a locale of its own
|
|
65
|
+
* after the zone, as the default theme does for a date inside an article
|
|
66
|
+
* written in another language (TASK-189). Both come from the `site` global of the render in
|
|
67
|
+
* hand — Nunjucks calls a filter with the template context as `this`, so
|
|
68
|
+
* nothing has to be threaded through every template — which is what lets a
|
|
69
|
+
* setting change what every page shows without a file changing. An Eleventy
|
|
70
|
+
* build of the same content applies the same lens and locale with Intl, both
|
|
71
|
+
* read from `site.json` (`docs/eleventy.config.example.js`).
|
|
68
72
|
*/
|
|
69
73
|
function addFilters(environment, baseUrl, loader) {
|
|
70
74
|
const base = new URL(baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`);
|
|
71
75
|
const basePath = base.pathname === '/' ? '' : base.pathname.replace(/\/$/, '');
|
|
72
|
-
environment.addFilter('date', function (value, format = 'readable', timezone) {
|
|
73
|
-
|
|
76
|
+
environment.addFilter('date', function (value, format = 'readable', timezone, locale) {
|
|
77
|
+
const site = renderSite(this);
|
|
78
|
+
return formatDate(value, typeof format === 'string' ? format : 'readable', typeof timezone === 'string' && timezone !== '' ? timezone : siteTimezone(site), (typeof locale === 'string' ? canonicalLocale(locale) : undefined) ?? siteLocale(site));
|
|
79
|
+
});
|
|
80
|
+
// `{{ count | plural({ one: "# reply", other: "# replies" }) }}`: the form
|
|
81
|
+
// for the count's plural category in the site's locale (TASK-153). A theme
|
|
82
|
+
// whose strings are in one language names it, so their grammar is that
|
|
83
|
+
// language's whatever the site's locale.
|
|
84
|
+
environment.addFilter('plural', function (count, forms, locale) {
|
|
85
|
+
if (typeof forms !== 'object' || forms === null)
|
|
86
|
+
return '';
|
|
87
|
+
const tag = (typeof locale === 'string' ? canonicalLocale(locale) : undefined) ??
|
|
88
|
+
siteLocale(renderSite(this));
|
|
89
|
+
return pluralForm(Number(count), forms, tag);
|
|
74
90
|
});
|
|
75
91
|
// Eleventy's `url` filter: make a site-root path absolute against the base
|
|
76
92
|
// path, so a site served from a subdirectory links correctly.
|
|
@@ -99,75 +115,87 @@ function addFilters(environment, baseUrl, loader) {
|
|
|
99
115
|
});
|
|
100
116
|
return environment;
|
|
101
117
|
}
|
|
102
|
-
const MONTHS = [
|
|
103
|
-
'January',
|
|
104
|
-
'February',
|
|
105
|
-
'March',
|
|
106
|
-
'April',
|
|
107
|
-
'May',
|
|
108
|
-
'June',
|
|
109
|
-
'July',
|
|
110
|
-
'August',
|
|
111
|
-
'September',
|
|
112
|
-
'October',
|
|
113
|
-
'November',
|
|
114
|
-
'December',
|
|
115
|
-
];
|
|
116
118
|
/**
|
|
117
|
-
*
|
|
119
|
+
* What Intl is asked for, by format. `full`, `long`, `medium` and `short` are
|
|
120
|
+
* Intl's own date styles, so a theme picks how much it wants said and the
|
|
121
|
+
* locale decides how to say it; `readable` is `long` under the name it had
|
|
122
|
+
* before there were styles.
|
|
123
|
+
*/
|
|
124
|
+
const INTL_FORMATS = {
|
|
125
|
+
full: { dateStyle: 'full' },
|
|
126
|
+
long: { dateStyle: 'long' },
|
|
127
|
+
medium: { dateStyle: 'medium' },
|
|
128
|
+
short: { dateStyle: 'short' },
|
|
129
|
+
readable: { dateStyle: 'long' },
|
|
130
|
+
month: { year: 'numeric', month: 'long' },
|
|
131
|
+
year: { year: 'numeric' },
|
|
132
|
+
};
|
|
133
|
+
/** One formatter per locale, zone and format, since a page prints dozens. */
|
|
134
|
+
const formatters = new Map();
|
|
135
|
+
/**
|
|
136
|
+
* `date` filter. An unparseable value renders as the empty string, and so
|
|
137
|
+
* does a zone Intl does not know.
|
|
118
138
|
*
|
|
119
139
|
* `iso` is the instant, always in UTC, because that is what a `<time
|
|
120
|
-
* datetime>` and a feed want and it must not move when a setting does.
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
140
|
+
* datetime>` and a feed want and it must not move when a setting does. `html`
|
|
141
|
+
* is the ISO calendar day in `timezone`, for the same attribute. The rest are
|
|
142
|
+
* that calendar day written in `locale` by Intl, which is what makes a post
|
|
143
|
+
* published at half past midnight in Berlin say 1 October rather than the 30
|
|
144
|
+
* September UTC was still on, and a French site say `1 octobre`.
|
|
124
145
|
*
|
|
125
146
|
* `month` is the month that calendar day falls in, "September 2026", which is
|
|
126
147
|
* what heads a group of an archive page (TASK-85). It is a format rather than
|
|
127
|
-
* something the archive works out for itself so that
|
|
128
|
-
*
|
|
148
|
+
* something the archive works out for itself so that a theme can head a group
|
|
149
|
+
* of its own the same way.
|
|
150
|
+
*
|
|
151
|
+
* Bare `en` is written the way `en-GB` writes it, day before month, because
|
|
152
|
+
* that is what the CMS printed before it had locales and `en` names a language
|
|
153
|
+
* rather than a convention. A site that wants `September 2, 2026` says
|
|
154
|
+
* `en-US`.
|
|
129
155
|
*/
|
|
130
|
-
export function formatDate(value, format, timezone = DEFAULT_TIMEZONE) {
|
|
156
|
+
export function formatDate(value, format, timezone = DEFAULT_TIMEZONE, locale = DEFAULT_LOCALE) {
|
|
131
157
|
const date = toDate(value);
|
|
132
158
|
if (date === undefined)
|
|
133
159
|
return '';
|
|
134
160
|
if (format === 'iso')
|
|
135
161
|
return date.toISOString();
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
162
|
+
if (format === 'html')
|
|
163
|
+
return calendarDayIn(date, timezone) ?? '';
|
|
164
|
+
const options = INTL_FORMATS[format] ?? INTL_FORMATS['long'];
|
|
165
|
+
const tag = canonicalLocale(locale) ?? DEFAULT_LOCALE;
|
|
166
|
+
const key = `${tag}|${timezone}|${format}`;
|
|
167
|
+
let formatter = formatters.get(key);
|
|
168
|
+
if (formatter === undefined) {
|
|
169
|
+
try {
|
|
170
|
+
formatter = new Intl.DateTimeFormat(tag === 'en' ? 'en-GB' : tag, {
|
|
171
|
+
...options,
|
|
172
|
+
timeZone: timezone,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
return '';
|
|
177
|
+
}
|
|
178
|
+
formatters.set(key, formatter);
|
|
150
179
|
}
|
|
180
|
+
return formatter.format(date);
|
|
151
181
|
}
|
|
152
182
|
/**
|
|
153
|
-
* The
|
|
183
|
+
* The `site` global of the render in hand.
|
|
154
184
|
*
|
|
155
185
|
* Nunjucks calls a filter with the template context as `this`, so the filter
|
|
156
186
|
* can read a per-render value without the environment holding any state of its
|
|
157
187
|
* own — which matters, because one environment serves every request and a zone
|
|
158
|
-
* stored on it would be a race between two of them.
|
|
188
|
+
* or a locale stored on it would be a race between two of them.
|
|
159
189
|
*/
|
|
160
|
-
function
|
|
190
|
+
function renderSite(context) {
|
|
191
|
+
const none = {};
|
|
161
192
|
if (typeof context !== 'object' || context === null)
|
|
162
|
-
return
|
|
193
|
+
return none;
|
|
163
194
|
const lookup = context.lookup;
|
|
164
195
|
if (typeof lookup !== 'function')
|
|
165
|
-
return
|
|
196
|
+
return none;
|
|
166
197
|
const site = lookup.call(context, 'site');
|
|
167
|
-
|
|
168
|
-
return DEFAULT_TIMEZONE;
|
|
169
|
-
const timezone = site['timezone'];
|
|
170
|
-
return typeof timezone === 'string' && timezone !== '' ? timezone : DEFAULT_TIMEZONE;
|
|
198
|
+
return typeof site === 'object' && site !== null ? site : none;
|
|
171
199
|
}
|
|
172
200
|
/**
|
|
173
201
|
* A value as an instant, or `undefined` when it is not one.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/web/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA+B9C;;;;;;;GA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IAAI,CAAC;AAC/E,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IACpF,IAAI,KAAK,KAAK,KAAK;QAAE,OAAO,IAAI,IAAI,EAAE,CAAC;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3D,MAAM,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;IAC7D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/web/themes.d.ts
CHANGED
|
@@ -47,6 +47,35 @@ export interface ThemeArea {
|
|
|
47
47
|
/** What the Navigation screen calls this place, for a person to read. */
|
|
48
48
|
readonly label: string;
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* What the `color-scheme` meta may say (TASK-146): the schemes a theme draws,
|
|
52
|
+
* the one it prefers first. `only dark` is not among them because the HTML
|
|
53
|
+
* standard does not allow it.
|
|
54
|
+
*/
|
|
55
|
+
export declare const COLOR_SCHEMES: readonly ['normal', 'light', 'dark', 'light dark', 'dark light', 'only light'];
|
|
56
|
+
/** One of {@link COLOR_SCHEMES}. */
|
|
57
|
+
export type ColorScheme = (typeof COLOR_SCHEMES)[number];
|
|
58
|
+
/**
|
|
59
|
+
* The colours a theme declares for the browser to use before its stylesheet
|
|
60
|
+
* has loaded, as its `theme.json` writes them:
|
|
61
|
+
*
|
|
62
|
+
* "colorScheme": "light dark",
|
|
63
|
+
* "themeColor": { "light": "#faf7f2", "dark": "#171412" }
|
|
64
|
+
*
|
|
65
|
+
* `colorScheme` is the `<meta name="color-scheme">`, which keeps a dark-mode
|
|
66
|
+
* reader from a white flash while the stylesheet is on its way. `themeColor`
|
|
67
|
+
* is the browser chrome around the page, one colour per scheme, and should be
|
|
68
|
+
* the page's own background so the two meet without a seam. A theme colour is
|
|
69
|
+
* a six- or three-digit hex colour, without an alpha channel, which a browser
|
|
70
|
+
* would ignore.
|
|
71
|
+
*/
|
|
72
|
+
export interface ThemeColors {
|
|
73
|
+
readonly colorScheme?: ColorScheme | undefined;
|
|
74
|
+
readonly themeColor: {
|
|
75
|
+
readonly light?: string | undefined;
|
|
76
|
+
readonly dark?: string | undefined;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
50
79
|
/** One theme directory, read and validated. */
|
|
51
80
|
export interface Theme {
|
|
52
81
|
/** The directory name, which is the theme's id and what a site.json names. */
|
|
@@ -65,6 +94,8 @@ export interface Theme {
|
|
|
65
94
|
* areas existed and every theme that renders no menu at all.
|
|
66
95
|
*/
|
|
67
96
|
readonly areas: readonly ThemeArea[];
|
|
97
|
+
/** The colours the manifest declares, each one absent when it declares none. */
|
|
98
|
+
readonly colors: ThemeColors;
|
|
68
99
|
}
|
|
69
100
|
/** A theme, or the reason the directory is not one. */
|
|
70
101
|
export type ThemeRead = {
|
|
@@ -157,6 +188,8 @@ export interface ChosenTheme {
|
|
|
157
188
|
* packaged theme on purpose and for one whose choice is working.
|
|
158
189
|
*/
|
|
159
190
|
readonly problem: string | undefined;
|
|
191
|
+
/** The colours the page declares: {@link ThemeColors}, the packaged theme's where this one is silent. */
|
|
192
|
+
readonly colors: ThemeColors;
|
|
160
193
|
}
|
|
161
194
|
/**
|
|
162
195
|
* The theme one site has chosen, resolved against its themes directory.
|
package/dist/web/themes.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../../src/web/themes.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;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