inlaycms 0.5.0 → 0.6.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/assets/admin/admin.css +1 -1
- package/assets/admin/admin.js +1 -1
- package/dist/adapters/admin/publish.js +2 -2
- package/dist/adapters/admin/screens/editor.js +4 -2
- package/dist/adapters/admin/screens/releases.js +8 -3
- package/dist/adapters/admin/views/data-table.js +1 -1
- package/dist/adapters/admin/views/layout.d.ts +1 -1
- package/dist/adapters/admin/views/layout.js +12 -2
- package/dist/adapters/cli/main.js +12 -2
- package/dist/adapters/mcp/agent-refs.d.ts +2 -1
- package/dist/adapters/mcp/agent-refs.js +4 -4
- package/dist/adapters/mcp/tools/publish.js +1 -1
- package/dist/adapters/mcp/tools/read.js +2 -2
- package/dist/adapters/mcp/tools/write.js +1 -1
- package/dist/adapters/site/context.d.ts +4 -1
- package/dist/adapters/site/context.js +9 -7
- package/dist/adapters/site/head.d.ts +2 -0
- package/dist/adapters/site/head.js +6 -6
- package/dist/adapters/site/plugin.js +15 -7
- package/dist/adapters/site/preview.d.ts +2 -0
- package/dist/adapters/site/preview.js +10 -5
- package/dist/adapters/site/render.js +7 -2
- package/dist/adapters/site/routes.js +4 -3
- package/dist/adapters/site/sitemap.d.ts +2 -1
- package/dist/adapters/site/sitemap.js +3 -3
- package/dist/core/messages/en.d.ts +10 -2
- package/dist/core/messages/en.js +10 -2
- package/dist/core/registry/define.d.ts +5 -0
- package/dist/core/registry/define.js +1 -0
- package/dist/core/registry/render.d.ts +6 -1
- package/dist/core/release/manifest.d.ts +0 -5
- package/dist/core/release/manifest.js +0 -24
- package/dist/core/release/read.d.ts +2 -2
- package/dist/core/release/read.js +11 -12
- package/dist/core/release/window.d.ts +11 -0
- package/dist/core/release/window.js +34 -0
- package/dist/core/site/paths.d.ts +5 -0
- package/dist/core/site/paths.js +32 -0
- package/dist/core/site/resolve.js +17 -6
- package/dist/core/version.d.ts +4 -0
- package/dist/core/version.js +4 -0
- package/dist/host/activate.js +2 -1
- package/dist/host/push.d.ts +5 -1
- package/dist/host/push.js +17 -5
- package/dist/host/worker.js +9 -3
- package/dist/site.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "inlaycms/jsx-runtime";
|
|
2
2
|
import { t } from '../../../core/messages/index.js';
|
|
3
3
|
import { raw, renderToString } from '../../../jsx/html.js';
|
|
4
|
+
import { NOTICES } from '../context.js';
|
|
4
5
|
import { Icon } from './icons.js';
|
|
5
6
|
import { Badge, badgeClass } from './status.js';
|
|
6
7
|
const HTMX_CONFIG = JSON.stringify({
|
|
@@ -16,6 +17,15 @@ function Head({ ctx, title, scripts }) {
|
|
|
16
17
|
const { theme, name } = ctx.branding;
|
|
17
18
|
return (_jsxs("head", { children: [_jsx("meta", { charset: "utf-8" }), _jsx("meta", { name: "viewport", content: "width=device-width, initial-scale=1" }), _jsx("meta", { name: "robots", content: "noindex" }), _jsx("meta", { name: "htmx-config", content: HTMX_CONFIG }), _jsx("title", { children: t('admin.pageTitle', { title, name }) }), _jsx("link", { rel: "stylesheet", href: ctx.assets.url('admin.css') }), theme.css !== '' && _jsx("style", { children: raw(theme.css) }), scripts.map((script) => (_jsx("script", { type: "module", src: ctx.assets.url(script) })))] }));
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* What a redirect asked to say (`?notice=`), as a toast over the page rather than a bar in it, so the page doesn't
|
|
22
|
+
* move. `client/admin/notice.ts` hides it after a while, puts the scroll back where the form was sent from and takes
|
|
23
|
+
* `data-notice-query` out of the address, so reloading doesn't show it again.
|
|
24
|
+
*/
|
|
25
|
+
function Notice({ text }) {
|
|
26
|
+
const query = ['notice', ...new Set(Object.values(NOTICES).flatMap((n) => n.params ?? []))];
|
|
27
|
+
return (_jsxs("div", { id: "admin-notice", "data-notice-query": query.join(' '), class: "alert alert-success fixed left-4 right-4 top-18 z-50 shadow-lg transition-opacity duration-300 motion-reduce:transition-none sm:left-auto sm:max-w-sm", children: [_jsx(Icon, { name: "check-circle" }), _jsx("span", { role: "status", children: text }), _jsxs("button", { type: "button", class: "btn btn-ghost btn-xs btn-square", "data-notice-dismiss": true, children: [_jsx(Icon, { name: "x" }), _jsx("span", { class: "sr-only", children: t('admin.notice.dismiss') })] })] }));
|
|
28
|
+
}
|
|
19
29
|
function SkipLink() {
|
|
20
30
|
return (_jsx("a", { href: "#main", class: "sr-only focus:not-sr-only focus:absolute focus:left-4 focus:top-4 focus:z-50 btn btn-primary", children: t('admin.skipLink') }));
|
|
21
31
|
}
|
|
@@ -108,7 +118,7 @@ function PrivateBadge({ owner }) {
|
|
|
108
118
|
}
|
|
109
119
|
/** The bar along the top: the menu button on small screens, the search box, the private-site badge, View site and Publish. */
|
|
110
120
|
function TopBar({ pending, locked, owner }) {
|
|
111
|
-
return (_jsxs("div", { class: "sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-base-300 bg-base-100 px-4 lg:px-6", children: [_jsxs("label", { for: "admin-nav-toggle", class: "btn btn-ghost btn-sm btn-square lg:hidden", children: [_jsx(Icon, { name: "menu" }), _jsx("span", { class: "sr-only", children: t('admin.nav.open') })] }), _jsxs("form", { role: "search", action: "/admin/search", method: "get", class: "relative w-full max-w-lg", children: [_jsxs("label", { for: "global-search", class: "input input-sm w-full border-transparent bg-base-200 focus-within:border-base-300 focus-within:bg-base-100", children: [_jsx(Icon, { name: "search", class: "opacity-60" }), _jsx("span", { class: "sr-only", children: t('admin.search.label') }), _jsx("input", { id: "global-search", name: "q", type: "search", class: "grow", placeholder: t('admin.search.placeholder'), autocomplete: "off", role: "combobox", "aria-expanded": "false", "aria-controls": "global-search-results", "aria-autocomplete": "list", "hx-get": "/admin/search", "hx-trigger": "input changed delay:250ms, focus", "hx-target": "#global-search-results", "hx-select": "#global-search-results", "hx-swap": "outerHTML" }), _jsx("kbd", { "aria-hidden": "true", class: "kbd kbd-sm", children: "/" })] }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only focus:absolute focus:right-0 focus:top-0", children: t('admin.search.submit') }), _jsx("div", { id: "global-search-results" })] }), _jsxs("div", { class: "ml-auto flex items-center gap-2", children: [locked && _jsx(PrivateBadge, { owner: owner }), _jsxs("a", { href: "/", class: "btn btn-ghost btn-sm hidden sm:inline-flex", children: [_jsx(Icon, { name: "external" }), t('admin.topbar.viewSite')] }), _jsxs("a", { id: "topbar-publish", href: "/admin/publish", "data-publish-dialog": true, "data-refresh": true, class: "btn btn-primary btn-sm", children: [_jsx(Icon, { name: "send" }), t('admin.topbar.publish'), pending > 0 && (_jsx("span", { "aria-hidden": "true", class: "badge badge-sm border-0 bg-primary-content/20 text-primary-content tabular-nums", children: pending })), pending > 0 && _jsx("span", { class: "sr-only", children: t('admin.topbar.pending', { count: pending }) })] })] })] }));
|
|
121
|
+
return (_jsxs("div", { id: "admin-top", class: "sticky top-0 z-30 flex h-14 items-center gap-3 border-b border-base-300 bg-base-100 px-4 lg:px-6", children: [_jsxs("label", { for: "admin-nav-toggle", class: "btn btn-ghost btn-sm btn-square lg:hidden", children: [_jsx(Icon, { name: "menu" }), _jsx("span", { class: "sr-only", children: t('admin.nav.open') })] }), _jsxs("form", { role: "search", action: "/admin/search", method: "get", class: "relative w-full max-w-lg", children: [_jsxs("label", { for: "global-search", class: "input input-sm w-full border-transparent bg-base-200 focus-within:border-base-300 focus-within:bg-base-100", children: [_jsx(Icon, { name: "search", class: "opacity-60" }), _jsx("span", { class: "sr-only", children: t('admin.search.label') }), _jsx("input", { id: "global-search", name: "q", type: "search", class: "grow", placeholder: t('admin.search.placeholder'), autocomplete: "off", role: "combobox", "aria-expanded": "false", "aria-controls": "global-search-results", "aria-autocomplete": "list", "hx-get": "/admin/search", "hx-trigger": "input changed delay:250ms, focus", "hx-target": "#global-search-results", "hx-select": "#global-search-results", "hx-swap": "outerHTML" }), _jsx("kbd", { "aria-hidden": "true", class: "kbd kbd-sm", children: "/" })] }), _jsx("button", { type: "submit", class: "btn btn-sm sr-only focus:not-sr-only focus:absolute focus:right-0 focus:top-0", children: t('admin.search.submit') }), _jsx("div", { id: "global-search-results" })] }), _jsxs("div", { class: "ml-auto flex items-center gap-2", children: [locked && _jsx(PrivateBadge, { owner: owner }), _jsxs("a", { href: "/", class: "btn btn-ghost btn-sm hidden sm:inline-flex", children: [_jsx(Icon, { name: "external" }), t('admin.topbar.viewSite')] }), _jsxs("a", { id: "topbar-publish", href: "/admin/publish", "data-publish-dialog": true, "data-refresh": true, class: "btn btn-primary btn-sm", children: [_jsx(Icon, { name: "send" }), t('admin.topbar.publish'), pending > 0 && (_jsx("span", { "aria-hidden": "true", class: "badge badge-sm border-0 bg-primary-content/20 text-primary-content tabular-nums", children: pending })), pending > 0 && _jsx("span", { class: "sr-only", children: t('admin.topbar.pending', { count: pending }) })] })] })] }));
|
|
112
122
|
}
|
|
113
123
|
function Breadcrumbs({ items, compact }) {
|
|
114
124
|
if (items.length === 0)
|
|
@@ -145,7 +155,7 @@ export async function adminPage(ctx, opts, body) {
|
|
|
145
155
|
const workspace = opts.layout === 'workspace';
|
|
146
156
|
const page = (_jsxs("html", { lang: "en", "data-theme": ctx.branding.theme.name, children: [_jsx(Head, { ctx: ctx, title: opts.title, scripts: scripts }), _jsxs("body", { class: "min-h-screen bg-base-200 text-base-content", children: [_jsx(SkipLink, {}), _jsxs("div", { class: "drawer lg:drawer-open", children: [_jsx("input", { id: "admin-nav-toggle", type: "checkbox", class: "drawer-toggle lg:hidden", "aria-label": t('admin.nav.open') }), _jsxs("div", { class: workspace ? 'drawer-content flex h-screen flex-col' : 'drawer-content flex min-h-screen flex-col', children: [_jsx(TopBar, { pending: pending.length, locked: lock.enabled, owner: opts.actor.role === 'owner' }), _jsxs("main", { id: "main", tabindex: "-1", class: workspace ? 'flex min-h-0 w-full flex-1 flex-col focus:outline-none' : 'w-full flex-1 px-4 py-4 focus:outline-none lg:px-6 lg:py-5', children: [_jsxs("div", { class: workspace
|
|
147
157
|
? 'flex shrink-0 flex-wrap items-center gap-x-4 gap-y-2 border-b border-base-300 bg-base-100 px-4 py-2.5'
|
|
148
|
-
: 'mb-5 flex flex-wrap items-end justify-between gap-4', children: [_jsxs("div", { class: "min-w-0", children: [_jsx(Breadcrumbs, { items: opts.breadcrumbs ?? [], compact: workspace }), _jsx("h1", { class: workspace ? 'truncate text-lg font-semibold tracking-tight' : 'text-2xl font-semibold tracking-tight', children: opts.title }), opts.description !== undefined && _jsx("p", { class: "text-sm text-base-content/70", children: opts.description })] }), opts.actions !== undefined && (_jsx("div", { class: workspace ? 'flex min-w-0 flex-1 flex-wrap items-center gap-2' : 'flex flex-wrap items-center gap-2', children: opts.actions }))] }), ctx.readOnly && (_jsx("div", { role: "status", class: workspace ? `alert alert-info ${BAR}` : 'alert alert-info mb-4', children: ctx.release ? t('admin.readOnly', { name: ctx.release.name }) : t('admin.readOnly.unnamed') })), _jsx("noscript", { children: _jsx("p", { class: workspace ? `alert alert-warning ${BAR}` : 'alert alert-warning mb-4', children: t('admin.noscript') }) }),
|
|
158
|
+
: 'mb-5 flex flex-wrap items-end justify-between gap-4', children: [_jsxs("div", { class: "min-w-0", children: [_jsx(Breadcrumbs, { items: opts.breadcrumbs ?? [], compact: workspace }), _jsx("h1", { class: workspace ? 'truncate text-lg font-semibold tracking-tight' : 'text-2xl font-semibold tracking-tight', children: opts.title }), opts.description !== undefined && _jsx("p", { class: "text-sm text-base-content/70", children: opts.description })] }), opts.actions !== undefined && (_jsx("div", { class: workspace ? 'flex min-w-0 flex-1 flex-wrap items-center gap-2' : 'flex flex-wrap items-center gap-2', children: opts.actions }))] }), ctx.readOnly && (_jsx("div", { role: "status", class: workspace ? `alert alert-info ${BAR}` : 'alert alert-info mb-4', children: ctx.release ? t('admin.readOnly', { name: ctx.release.name }) : t('admin.readOnly.unnamed') })), _jsx("noscript", { children: _jsx("p", { class: workspace ? `alert alert-warning ${BAR}` : 'alert alert-warning mb-4', children: t('admin.noscript') }) }), workspace ? _jsx("div", { class: "flex min-h-0 flex-1 flex-col", children: body }) : body] })] }), _jsxs("div", { class: "drawer-side z-40", children: [_jsx("label", { for: "admin-nav-toggle", "aria-label": t('admin.nav.close'), class: "drawer-overlay", children: _jsx("span", { class: "sr-only", children: t('admin.nav.close') }) }), _jsxs("aside", { class: "flex min-h-full w-64 flex-col border-r border-base-300 bg-base-100 lg:w-full lg:border-r-0", children: [_jsx("header", { class: "flex h-14 shrink-0 items-center border-b border-base-300 px-4", children: _jsx("a", { href: "/admin", class: "inline-flex min-w-0 items-center", children: _jsx(Brand, { ctx: ctx, size: "h-7 max-w-40" }) }) }), _jsx(Nav, { ctx: ctx, actor: opts.actor, section: opts.section, counts: counts })] })] })] }), _jsx(PickerDialog, {}), _jsx(PublishDialog, {}), notice !== undefined && _jsx(Notice, { text: notice })] })] }));
|
|
149
159
|
return `<!doctype html>${await renderToString(page)}`;
|
|
150
160
|
}
|
|
151
161
|
/** A page for someone who isn't signed in (setup, login, consent, uploads): a centered card with the brand, no navigation. */
|
|
@@ -31,6 +31,7 @@ import { EMPTY_SITE } from '../../host/app.js';
|
|
|
31
31
|
import { ensureDataDir, hostPaths, readDataDir, readHostConfig, readTrustedKeys } from '../../host/config.js';
|
|
32
32
|
import { dev } from '../../host/dev.js';
|
|
33
33
|
import { formatDiff } from '../../host/diff.js';
|
|
34
|
+
import { releaseInfo } from '../../host/push.js';
|
|
34
35
|
import { serve } from '../../host/serve.js';
|
|
35
36
|
import { currentRelease, getRelease, listReleases, releaseDir, storeRelease } from '../../host/store.js';
|
|
36
37
|
import { activateRemote, checkTransport, isRemote, listRemoteReleases, pushFile } from './remote.js';
|
|
@@ -355,11 +356,18 @@ async function releases(io, flags) {
|
|
|
355
356
|
await db.destroy();
|
|
356
357
|
}
|
|
357
358
|
}
|
|
358
|
-
printReleases(io, rows, flags.json);
|
|
359
|
+
printReleases(io, rows.map(releaseInfo), flags.json);
|
|
359
360
|
return 0;
|
|
360
361
|
}
|
|
361
362
|
function printReleases(io, rows, json) {
|
|
362
|
-
const listed = rows.map((r) => ({
|
|
363
|
+
const listed = rows.map((r) => ({
|
|
364
|
+
id: r.id,
|
|
365
|
+
name: r.name,
|
|
366
|
+
state: r.state,
|
|
367
|
+
pushedAt: r.pushed_at,
|
|
368
|
+
activatedAt: r.activated_at,
|
|
369
|
+
...(r.warning !== undefined && { warning: r.warning }),
|
|
370
|
+
}));
|
|
363
371
|
if (json)
|
|
364
372
|
return io.out(JSON.stringify(listed, null, 2));
|
|
365
373
|
if (listed.length === 0)
|
|
@@ -372,6 +380,8 @@ function printReleases(io, rows, json) {
|
|
|
372
380
|
pushedAt: r.pushedAt,
|
|
373
381
|
activatedAt: r.activatedAt ?? t('cli.releaseNeverLive'),
|
|
374
382
|
}));
|
|
383
|
+
if (r.warning !== undefined)
|
|
384
|
+
io.out(t('cli.releaseWarning', { warning: r.warning }));
|
|
375
385
|
}
|
|
376
386
|
}
|
|
377
387
|
/** The push token: `--token`, or INLAY_PUSH_TOKEN. Answers exit code 2, having said so, when there is neither. */
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type AgentRefs } from '../../core/agent/format.js';
|
|
2
|
+
import { type TrailingSlash } from '../../core/site/paths.js';
|
|
2
3
|
import type { DocumentData } from '../../core/types.js';
|
|
3
4
|
import type { McpDeps } from './server.js';
|
|
4
5
|
/** The absolute URL of a decoded site path, or `null` for a document without a page. */
|
|
5
|
-
export declare function pageUrl(baseUrl: string, path: string | null): string | null;
|
|
6
|
+
export declare function pageUrl(baseUrl: string, path: string | null, trailingSlash: TrailingSlash): string | null;
|
|
6
7
|
/** The absolute URL of a media file. */
|
|
7
8
|
export declare function mediaUrl(baseUrl: string, id: string): string;
|
|
8
9
|
/** Everything `toAgent` and `agentLinks` look up for `data`, read up front in `locale` (drafts included). */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { agentRefsNeeded } from '../../core/agent/format.js';
|
|
2
|
-
import { encodePath } from '../../core/site/paths.js';
|
|
2
|
+
import { encodePath, presentHref } from '../../core/site/paths.js';
|
|
3
3
|
/** The absolute URL of a decoded site path, or `null` for a document without a page. */
|
|
4
|
-
export function pageUrl(baseUrl, path) {
|
|
5
|
-
return path === null ? null : `${baseUrl}${encodePath(path)}`;
|
|
4
|
+
export function pageUrl(baseUrl, path, trailingSlash) {
|
|
5
|
+
return path === null ? null : `${baseUrl}${presentHref(encodePath(path), trailingSlash)}`;
|
|
6
6
|
}
|
|
7
7
|
/** The absolute URL of a media file. */
|
|
8
8
|
export function mediaUrl(baseUrl, id) {
|
|
@@ -17,7 +17,7 @@ export async function loadAgentRefs(deps, type, locale, data) {
|
|
|
17
17
|
return {
|
|
18
18
|
document(groupId) {
|
|
19
19
|
const doc = documents.get(groupId);
|
|
20
|
-
return doc ? { title: doc.title, url: pageUrl(baseUrl, doc.path) } : null;
|
|
20
|
+
return doc ? { title: doc.title, url: pageUrl(baseUrl, doc.path, core.registry.site.trailingSlash) } : null;
|
|
21
21
|
},
|
|
22
22
|
media: (id) => media.get(id) ?? { status: 'unknown' },
|
|
23
23
|
mediaUrl: (id) => mediaUrl(baseUrl, id),
|
|
@@ -71,7 +71,7 @@ async function describeDone(deps, action, ids) {
|
|
|
71
71
|
out.push(item);
|
|
72
72
|
continue;
|
|
73
73
|
}
|
|
74
|
-
out.push({ ...item, url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published')) });
|
|
74
|
+
out.push({ ...item, url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash) });
|
|
75
75
|
}
|
|
76
76
|
return out;
|
|
77
77
|
}
|
|
@@ -70,7 +70,7 @@ async function describeSite(deps) {
|
|
|
70
70
|
for (const locale of locales) {
|
|
71
71
|
const path = singletonPath(def, locale, defaultLocale);
|
|
72
72
|
if (path !== null)
|
|
73
|
-
urls[locale] = pageUrl(baseUrl, withLocale(registry, locale, path));
|
|
73
|
+
urls[locale] = pageUrl(baseUrl, withLocale(registry, locale, path), registry.site.trailingSlash);
|
|
74
74
|
}
|
|
75
75
|
singletons.push({
|
|
76
76
|
type: def.name,
|
|
@@ -225,7 +225,7 @@ async function getDocument(deps, args) {
|
|
|
225
225
|
revisionId: doc.revision.id,
|
|
226
226
|
publishedRevisionId: doc.publishedRev,
|
|
227
227
|
hasUnpublishedChanges: doc.publishedRev !== doc.headRev,
|
|
228
|
-
url: pageUrl(baseUrl, await livePath(deps, doc, 'published')),
|
|
228
|
+
url: pageUrl(baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash),
|
|
229
229
|
previewUrl: previewLink(deps, path ?? '/'),
|
|
230
230
|
content: toAgent(registry, doc.type, doc.data, refs),
|
|
231
231
|
links: agentLinks(registry, doc.type, doc.data, refs),
|
|
@@ -54,7 +54,7 @@ async function created(deps, doc) {
|
|
|
54
54
|
groupId: doc.groupId,
|
|
55
55
|
revisionId: doc.headRev,
|
|
56
56
|
title: doc.title,
|
|
57
|
-
url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published')),
|
|
57
|
+
url: pageUrl(deps.baseUrl, await livePath(deps, doc, 'published'), deps.core.registry.site.trailingSlash),
|
|
58
58
|
previewUrl: previewLink(deps, path ?? '/'),
|
|
59
59
|
};
|
|
60
60
|
}
|
|
@@ -2,16 +2,19 @@ import type { Core } from '../../core/core.js';
|
|
|
2
2
|
import type { TemplateDef } from '../../core/registry/define.js';
|
|
3
3
|
import type { RenderContext } from '../../core/registry/render.js';
|
|
4
4
|
import type { QueryApi } from '../../core/registry/route.js';
|
|
5
|
+
import { type TrailingSlash } from '../../core/site/paths.js';
|
|
5
6
|
import type { DocumentData, LiveDocument, LiveState } from '../../core/types.js';
|
|
6
7
|
import { type PublicAssets } from './assets.js';
|
|
7
8
|
import { type CollectedHead } from './head.js';
|
|
8
9
|
import { type CodeFiles } from './code-files.js';
|
|
10
|
+
/** The encoded URL of the decoded site path `path`, in the form the site presents; `''` for `''`. */
|
|
11
|
+
export declare const pageUrl: (path: string, mode: TrailingSlash) => string;
|
|
9
12
|
export interface RenderContextOptions {
|
|
10
13
|
locale: string;
|
|
11
14
|
state: LiveState;
|
|
12
15
|
page: number;
|
|
13
16
|
baseUrl: string;
|
|
14
|
-
alternates: RenderContext['alternates']
|
|
17
|
+
alternates: Array<Omit<RenderContext['alternates'][number], 'url'>>;
|
|
15
18
|
assets?: PublicAssets;
|
|
16
19
|
/** Where `markdown` finds its image files; the core's shared index by default. */
|
|
17
20
|
codeFiles?: CodeFiles;
|
|
@@ -10,12 +10,14 @@ import { inlineTextToHtml } from '../../core/richtext/inline.js';
|
|
|
10
10
|
import { markdownImages } from '../../core/richtext/markdown.js';
|
|
11
11
|
import { isMediaTarget, KEY_HREF, NO_DOCUMENT, parseMarkdownText } from '../../core/richtext/markdown-text.js';
|
|
12
12
|
import { richTextRefs } from '../../core/richtext/schema.js';
|
|
13
|
-
import { encodePath } from '../../core/site/paths.js';
|
|
13
|
+
import { encodePath, presentHref } from '../../core/site/paths.js';
|
|
14
14
|
import { publicAssets } from './assets.js';
|
|
15
15
|
import { createHeadCollector } from './head.js';
|
|
16
16
|
import { codeFilesFor } from './code-files.js';
|
|
17
17
|
import { createScriptCollector } from './scripts.js';
|
|
18
18
|
import { escapeHtml, raw } from '../../jsx/html.js';
|
|
19
|
+
/** The encoded URL of the decoded site path `path`, in the form the site presents; `''` for `''`. */
|
|
20
|
+
export const pageUrl = (path, mode) => presentHref(encodePath(path), mode);
|
|
19
21
|
/** Rich text images get this width as `src` when the original is at least as wide. */
|
|
20
22
|
const RICH_TEXT_SRC_WIDTH = 1280;
|
|
21
23
|
const nonEmpty = (s) => typeof s === 'string' && s !== '';
|
|
@@ -75,13 +77,13 @@ function richTextImage(img) {
|
|
|
75
77
|
const width = Math.min(img.width ?? RICH_TEXT_SRC_WIDTH, RICH_TEXT_SRC_WIDTH);
|
|
76
78
|
return { src: img.src(width), srcset: img.srcset(), alt: img.alt, width: img.width, height: img.height };
|
|
77
79
|
}
|
|
78
|
-
function toEntry(doc) {
|
|
80
|
+
function toEntry(doc, mode) {
|
|
79
81
|
return {
|
|
80
82
|
id: doc.groupId,
|
|
81
83
|
type: doc.type,
|
|
82
84
|
locale: doc.contentLocale,
|
|
83
85
|
fallback: doc.fallback,
|
|
84
|
-
url: doc.path === null ? null : encodePath(doc.path),
|
|
86
|
+
url: doc.path === null ? null : presentHref(encodePath(doc.path), mode),
|
|
85
87
|
title: doc.title,
|
|
86
88
|
slug: doc.slug,
|
|
87
89
|
updatedAt: doc.updatedAt,
|
|
@@ -220,7 +222,7 @@ export function createRenderContext(core, opts) {
|
|
|
220
222
|
const doc = docs.get(groupId);
|
|
221
223
|
if (!doc || doc.path === null)
|
|
222
224
|
return null;
|
|
223
|
-
return { href: encodePath(doc.path), title: doc.title };
|
|
225
|
+
return { href: presentHref(encodePath(doc.path), registry.site.trailingSlash), title: doc.title };
|
|
224
226
|
}
|
|
225
227
|
function link(v) {
|
|
226
228
|
if (!v)
|
|
@@ -295,7 +297,7 @@ export function createRenderContext(core, opts) {
|
|
|
295
297
|
return doc ? [doc] : [];
|
|
296
298
|
});
|
|
297
299
|
await preload(found);
|
|
298
|
-
return found.map((doc) => toEntry(doc));
|
|
300
|
+
return found.map((doc) => toEntry(doc, registry.site.trailingSlash));
|
|
299
301
|
}
|
|
300
302
|
function liveCollection(name) {
|
|
301
303
|
let pending = collections.get(name);
|
|
@@ -314,7 +316,7 @@ export function createRenderContext(core, opts) {
|
|
|
314
316
|
async function query(collection, queryOpts = {}) {
|
|
315
317
|
const name = typeof collection === 'string' ? collection : collection.name;
|
|
316
318
|
const live = await liveCollection(name);
|
|
317
|
-
const all = live.map((doc) => toEntry(doc));
|
|
319
|
+
const all = live.map((doc) => toEntry(doc, registry.site.trailingSlash));
|
|
318
320
|
const filtered = queryOpts.filter ? all.filter(queryOpts.filter) : all;
|
|
319
321
|
const sorted = sortEntries(filtered, queryOpts.sort);
|
|
320
322
|
const total = sorted.length;
|
|
@@ -357,7 +359,7 @@ export function createRenderContext(core, opts) {
|
|
|
357
359
|
asset: (path) => assets.url(path),
|
|
358
360
|
head: head.api,
|
|
359
361
|
script: scripts.api,
|
|
360
|
-
alternates: opts.alternates,
|
|
362
|
+
alternates: opts.alternates.map((a) => ({ ...a, url: pageUrl(a.path, registry.site.trailingSlash) })),
|
|
361
363
|
image,
|
|
362
364
|
file,
|
|
363
365
|
link,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { OgType } from '../../core/registry/define.js';
|
|
2
2
|
import type { HeadApi, HeadLink } from '../../core/registry/render.js';
|
|
3
|
+
import { type TrailingSlash } from '../../core/site/paths.js';
|
|
3
4
|
import { type SafeHtml } from '../../jsx/html.js';
|
|
4
5
|
export interface HeadInput {
|
|
5
6
|
/** The final `<title>` text. */
|
|
@@ -21,6 +22,7 @@ export interface HeadInput {
|
|
|
21
22
|
}>;
|
|
22
23
|
defaultLocale: string;
|
|
23
24
|
baseUrl: string;
|
|
25
|
+
trailingSlash: TrailingSlash;
|
|
24
26
|
preview: boolean;
|
|
25
27
|
/** What the render added through `ctx.head`. */
|
|
26
28
|
collected?: CollectedHead;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { InlayError } from '../../core/errors.js';
|
|
2
2
|
import { isSafeUrl } from '../../core/fields/define.js';
|
|
3
3
|
import { scriptJson } from '../../core/registry/js.js';
|
|
4
|
-
import { encodePath } from '../../core/site/paths.js';
|
|
4
|
+
import { encodePath, presentHref } from '../../core/site/paths.js';
|
|
5
5
|
import { escapeHtml, raw } from '../../jsx/html.js';
|
|
6
6
|
export const NO_HEAD = { meta: [], links: [], jsonLd: [] };
|
|
7
7
|
const LINK_ATTRS = ['rel', 'hreflang', 'type', 'sizes', 'media', 'as', 'crossorigin', 'href'];
|
|
@@ -33,14 +33,14 @@ export function createHeadCollector() {
|
|
|
33
33
|
};
|
|
34
34
|
return { api, collected: () => ({ meta: [...head.meta], links: [...head.links], jsonLd: [...head.jsonLd] }) };
|
|
35
35
|
}
|
|
36
|
-
function absolute(baseUrl, path) {
|
|
36
|
+
function absolute(baseUrl, path, mode) {
|
|
37
37
|
const [p = '', query] = path.split('?');
|
|
38
|
-
return `${baseUrl}${p === '/' ? '/' : encodePath(p)}${query === undefined ? '' : `?${query}`}`;
|
|
38
|
+
return `${baseUrl}${p === '/' ? '/' : presentHref(encodePath(p), mode)}${query === undefined ? '' : `?${query}`}`;
|
|
39
39
|
}
|
|
40
40
|
const meta = (attr, key, content) => ({ tag: 'meta', attr, key, content });
|
|
41
41
|
/** Inlay's own tags for the page, before any Twitter tags. */
|
|
42
42
|
function inlayTags(input) {
|
|
43
|
-
const url = input.canonical === null ? null : absolute(input.baseUrl, input.canonical);
|
|
43
|
+
const url = input.canonical === null ? null : absolute(input.baseUrl, input.canonical, input.trailingSlash);
|
|
44
44
|
const tags = [{ tag: 'title', text: input.title }];
|
|
45
45
|
if (input.description)
|
|
46
46
|
tags.push(meta('name', 'description', input.description));
|
|
@@ -48,11 +48,11 @@ function inlayTags(input) {
|
|
|
48
48
|
tags.push({ tag: 'link', attrs: { rel: 'canonical', href: url } });
|
|
49
49
|
if (input.alternates.length >= 2) {
|
|
50
50
|
for (const a of input.alternates) {
|
|
51
|
-
tags.push({ tag: 'link', attrs: { rel: 'alternate', hreflang: a.locale, href: absolute(input.baseUrl, a.path) } });
|
|
51
|
+
tags.push({ tag: 'link', attrs: { rel: 'alternate', hreflang: a.locale, href: absolute(input.baseUrl, a.path, input.trailingSlash) } });
|
|
52
52
|
}
|
|
53
53
|
const def = input.alternates.find((a) => a.locale === input.defaultLocale);
|
|
54
54
|
if (def)
|
|
55
|
-
tags.push({ tag: 'link', attrs: { rel: 'alternate', hreflang: 'x-default', href: absolute(input.baseUrl, def.path) } });
|
|
55
|
+
tags.push({ tag: 'link', attrs: { rel: 'alternate', hreflang: 'x-default', href: absolute(input.baseUrl, def.path, input.trailingSlash) } });
|
|
56
56
|
}
|
|
57
57
|
tags.push(meta('property', 'og:type', input.ogType));
|
|
58
58
|
tags.push(meta('property', 'og:title', input.title));
|
|
@@ -9,7 +9,7 @@ import { DEFAULT_MAX_BYTES, DEFAULT_UPLOAD_TYPES } from '../../core/media/detect
|
|
|
9
9
|
import { t } from '../../core/messages/index.js';
|
|
10
10
|
import { externalTarget } from '../../core/redirects/rule.js';
|
|
11
11
|
import { buildRegistry } from '../../core/registry/registry.js';
|
|
12
|
-
import { encodePath, normalizePath, splitLocale } from '../../core/site/paths.js';
|
|
12
|
+
import { encodePath, normalizePath, presentHref, splitLocale } from '../../core/site/paths.js';
|
|
13
13
|
import { loadAdminAssets } from '../admin/assets.js';
|
|
14
14
|
import { registerAdminRoutes } from '../admin/routes.js';
|
|
15
15
|
import { resolveTheme, themeContrastProblems } from '../admin/theme.js';
|
|
@@ -121,7 +121,8 @@ function createApi(core, cache, service, opts) {
|
|
|
121
121
|
}
|
|
122
122
|
function registerSiteRoutes(app, core, cache, integrations, opts) {
|
|
123
123
|
const { registry } = core;
|
|
124
|
-
const { notFound } = registry.site;
|
|
124
|
+
const { notFound, trailingSlash: mode } = registry.site;
|
|
125
|
+
const always = mode === 'always';
|
|
125
126
|
const { baseUrl, cdn, assets } = opts;
|
|
126
127
|
const banner = opts.release === undefined ? {} : { release: opts.release };
|
|
127
128
|
async function notFoundPage(locale, state) {
|
|
@@ -194,7 +195,8 @@ function registerSiteRoutes(app, core, cache, integrations, opts) {
|
|
|
194
195
|
return await missing(request, reply, localeOf(path), state);
|
|
195
196
|
const pageNumber = Number(pageParam ?? 1);
|
|
196
197
|
const normalized = normalizePath(path);
|
|
197
|
-
const
|
|
198
|
+
const presented = normalized === null ? null : presentHref(encodePath(normalized), mode);
|
|
199
|
+
const canonical = presented !== null && presented === path;
|
|
198
200
|
const key = preview || normalized === null || !canonical
|
|
199
201
|
? null
|
|
200
202
|
: pageNumber > 1
|
|
@@ -204,16 +206,22 @@ function registerSiteRoutes(app, core, cache, integrations, opts) {
|
|
|
204
206
|
if (hit)
|
|
205
207
|
return send(request, reply, hit, true);
|
|
206
208
|
const generation = cache?.generation ?? 0;
|
|
207
|
-
|
|
209
|
+
if (always && presented !== null && !canonical && registry.getRoutePaths.has(normalized ?? '')) {
|
|
210
|
+
return reply.redirect(`${presented}${search}`, 301);
|
|
211
|
+
}
|
|
212
|
+
const lookup = always && path.length > 1 && path.endsWith('/') ? path.slice(0, -1) : path;
|
|
213
|
+
const match = await core.resolvePath(lookup, { state });
|
|
208
214
|
if (match.kind === 'redirect') {
|
|
209
215
|
if (match.external === true && externalTarget(match.location) === match.location) {
|
|
210
216
|
return reply.redirect(match.location, match.status);
|
|
211
217
|
}
|
|
212
218
|
if (match.external !== true && match.location.startsWith('/') && !match.location.startsWith('//')) {
|
|
213
|
-
return reply.redirect(`${match.location}${search}`, match.status);
|
|
219
|
+
return reply.redirect(`${presentHref(match.location, mode)}${search}`, match.status);
|
|
214
220
|
}
|
|
215
221
|
}
|
|
216
222
|
if (match.kind === 'page') {
|
|
223
|
+
if (always && !canonical && presented !== null)
|
|
224
|
+
return reply.redirect(`${presented}${search}`, 301);
|
|
217
225
|
const page = await renderPageResult(core, match.document, { state, page: pageNumber, baseUrl, assets, integrations, ...banner });
|
|
218
226
|
if (preview)
|
|
219
227
|
return await sendPreview(reply, 200, page);
|
|
@@ -241,7 +249,7 @@ function registerSiteRoutes(app, core, cache, integrations, opts) {
|
|
|
241
249
|
// A site that is down has no sitemap to give: an empty one would tell search engines its pages are gone.
|
|
242
250
|
app.get('/sitemap.xml', async (request, reply) => opts.noSite === 'unavailable'
|
|
243
251
|
? unavailable(request, reply)
|
|
244
|
-
: cached(request, reply, 'sitemap.xml', async () => response(200, renderSitemap(await core.sitemapEntries(), baseUrl), 'application/xml')));
|
|
252
|
+
: cached(request, reply, 'sitemap.xml', async () => response(200, renderSitemap(await core.sitemapEntries(), baseUrl, core.registry.site.trailingSlash), 'application/xml')));
|
|
245
253
|
app.get('/robots.txt', async (request, reply) => {
|
|
246
254
|
reply.type('text/plain; charset=utf-8');
|
|
247
255
|
if (isLockedRequest(request))
|
|
@@ -472,7 +480,7 @@ const plugin = async (app, opts) => {
|
|
|
472
480
|
if (opts.publicDir !== undefined)
|
|
473
481
|
registerPublicRoutes(app, { dir: opts.publicDir, maxAge: opts.publicMaxAge ?? 3600 });
|
|
474
482
|
registerReleaseRoutes(app, { core, registry, baseUrl, assets: siteAssets, integrations: siteIntegrations, secrets: opts.secrets ?? {}, fetch: opts.fetch ?? ((input, init) => globalThis.fetch(input, init)), log: app.log, preview: opts.preview === 'forced' });
|
|
475
|
-
registerPreviewRoutes(app, { secret, baseUrl, now });
|
|
483
|
+
registerPreviewRoutes(app, { secret, baseUrl, now, trailingSlash: registry.site.trailingSlash });
|
|
476
484
|
registerSiteRoutes(app, core, cache, siteIntegrations, {
|
|
477
485
|
baseUrl,
|
|
478
486
|
secret,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FastifyInstance, FastifyReply, FastifyRequest } from 'fastify';
|
|
2
|
+
import { type TrailingSlash } from '../../core/site/paths.js';
|
|
2
3
|
import type { LiveState } from '../../core/types.js';
|
|
3
4
|
export declare const PREVIEW_COOKIE = "inlay_preview";
|
|
4
5
|
export declare const PREVIEW_PATH = "/_inlay/preview";
|
|
@@ -33,4 +34,5 @@ export declare function registerPreviewRoutes(app: FastifyInstance, opts: {
|
|
|
33
34
|
secret: string;
|
|
34
35
|
baseUrl: string;
|
|
35
36
|
now: () => Date;
|
|
37
|
+
trailingSlash?: TrailingSlash;
|
|
36
38
|
}): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createPreviewToken, verifyPreviewToken } from '../../core/preview.js';
|
|
2
|
-
import { encodePath, normalizePath } from '../../core/site/paths.js';
|
|
2
|
+
import { encodePath, normalizePath, presentHref } from '../../core/site/paths.js';
|
|
3
3
|
import { catalogPage, PREVIEW_EXIT_PATH } from './render.js';
|
|
4
4
|
export const PREVIEW_COOKIE = 'inlay_preview';
|
|
5
5
|
export const PREVIEW_PATH = '/_inlay/preview';
|
|
@@ -37,12 +37,16 @@ export function readPreview(request, secret, now) {
|
|
|
37
37
|
export function previewState(request, secret, now) {
|
|
38
38
|
return readPreview(request, secret, now).state;
|
|
39
39
|
}
|
|
40
|
-
/** `raw` when it's a clean, encoded site-relative path, otherwise `/`. */
|
|
41
|
-
function safeTarget(raw) {
|
|
40
|
+
/** `raw` in its presented form when it's a clean, encoded site-relative path, otherwise `/`. */
|
|
41
|
+
function safeTarget(raw, mode) {
|
|
42
42
|
if (typeof raw !== 'string')
|
|
43
43
|
return '/';
|
|
44
44
|
const normalized = normalizePath(raw);
|
|
45
|
-
|
|
45
|
+
if (normalized === null)
|
|
46
|
+
return '/';
|
|
47
|
+
const encoded = encodePath(normalized);
|
|
48
|
+
const presented = presentHref(encoded, mode);
|
|
49
|
+
return raw === encoded || raw === presented ? presented : '/';
|
|
46
50
|
}
|
|
47
51
|
/** Turns preview off for this browser. */
|
|
48
52
|
export function clearPreviewCookie(reply, baseUrl) {
|
|
@@ -59,6 +63,7 @@ function setCookie(reply, value, maxAge, secure) {
|
|
|
59
63
|
* release a release link previews); `GET /_inlay/preview/exit` turns it off.
|
|
60
64
|
*/
|
|
61
65
|
export function registerPreviewRoutes(app, opts) {
|
|
66
|
+
const mode = opts.trailingSlash ?? 'never';
|
|
62
67
|
const secure = opts.baseUrl.startsWith('https:');
|
|
63
68
|
app.get(PREVIEW_PATH, async (request, reply) => {
|
|
64
69
|
const query = request.query;
|
|
@@ -73,7 +78,7 @@ export function registerPreviewRoutes(app, opts) {
|
|
|
73
78
|
.send(catalogPage('preview.expired.title', 'preview.expired'));
|
|
74
79
|
}
|
|
75
80
|
setCookie(reply, token, Math.ceil((valid.expiresAt.getTime() - now.getTime()) / 1000), secure);
|
|
76
|
-
return reply.redirect(safeTarget(query.path), 302);
|
|
81
|
+
return reply.redirect(safeTarget(query.path, mode), 302);
|
|
77
82
|
});
|
|
78
83
|
app.get(PREVIEW_EXIT_PATH, async (_request, reply) => {
|
|
79
84
|
setCookie(reply, '', 0, secure);
|
|
@@ -2,8 +2,9 @@ import { validateContent } from '../../core/content/validate.js';
|
|
|
2
2
|
import { InlayError } from '../../core/errors.js';
|
|
3
3
|
import { fieldMeta } from '../../core/fields/define.js';
|
|
4
4
|
import { t } from '../../core/messages/index.js';
|
|
5
|
+
import { presentPath } from '../../core/site/paths.js';
|
|
5
6
|
import { escapeHtml, raw, renderToString, toHtml } from '../../jsx/html.js';
|
|
6
|
-
import { createRenderContext } from './context.js';
|
|
7
|
+
import { createRenderContext, pageUrl } from './context.js';
|
|
7
8
|
import { buildHead, injectHead } from './head.js';
|
|
8
9
|
import { injectIntegrations } from './integrations.js';
|
|
9
10
|
import { isHomePath, mediaShareImage, pageTitle, resolveSeoDefaults } from './seo.js';
|
|
@@ -128,6 +129,7 @@ async function renderTemplate(core, doc, opts, internal = {}) {
|
|
|
128
129
|
contentLocale: doc.contentLocale,
|
|
129
130
|
fallback: doc.fallback,
|
|
130
131
|
path: doc.path ?? '',
|
|
132
|
+
url: pageUrl(doc.path ?? '', core.registry.site.trailingSlash),
|
|
131
133
|
publishedAt: doc.publishedAt,
|
|
132
134
|
page: opts.page,
|
|
133
135
|
};
|
|
@@ -148,6 +150,7 @@ async function renderTemplate(core, doc, opts, internal = {}) {
|
|
|
148
150
|
alternates: doc.fallback ? [] : alternates.filter((a) => !a.fallback),
|
|
149
151
|
defaultLocale: core.registry.defaultLocale,
|
|
150
152
|
baseUrl: opts.baseUrl,
|
|
153
|
+
trailingSlash: core.registry.site.trailingSlash,
|
|
151
154
|
preview: opts.state === 'preview',
|
|
152
155
|
collected: ctx.headTags(),
|
|
153
156
|
});
|
|
@@ -156,7 +159,7 @@ async function renderTemplate(core, doc, opts, internal = {}) {
|
|
|
156
159
|
const open = HEAD_OPEN.exec(out);
|
|
157
160
|
if (open) {
|
|
158
161
|
const at = open.index + open[0].length;
|
|
159
|
-
out = `${out.slice(0, at)}<base href="${escapeHtml(doc.path)}">${out.slice(at)}`;
|
|
162
|
+
out = `${out.slice(0, at)}<base href="${escapeHtml(presentPath(doc.path, core.registry.site.trailingSlash))}">${out.slice(at)}`;
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
165
|
if (!internal.pane) {
|
|
@@ -192,6 +195,7 @@ export async function renderTemplateResult(core, template, data, opts) {
|
|
|
192
195
|
contentLocale: opts.locale,
|
|
193
196
|
fallback: false,
|
|
194
197
|
path: opts.path,
|
|
198
|
+
url: pageUrl(opts.path, core.registry.site.trailingSlash),
|
|
195
199
|
publishedAt: null,
|
|
196
200
|
page: 1,
|
|
197
201
|
};
|
|
@@ -208,6 +212,7 @@ export async function renderTemplateResult(core, template, data, opts) {
|
|
|
208
212
|
alternates: [],
|
|
209
213
|
defaultLocale: core.registry.defaultLocale,
|
|
210
214
|
baseUrl: opts.baseUrl,
|
|
215
|
+
trailingSlash: core.registry.site.trailingSlash,
|
|
211
216
|
preview: opts.preview === true,
|
|
212
217
|
collected: ctx.headTags(),
|
|
213
218
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizeContent } from '../../core/content/schema.js';
|
|
2
2
|
import { readData } from '../../core/content/reader.js';
|
|
3
3
|
import { t } from '../../core/messages/index.js';
|
|
4
|
-
import { encodePath } from '../../core/site/paths.js';
|
|
4
|
+
import { encodePath, presentPath } from '../../core/site/paths.js';
|
|
5
5
|
import { publicAssets } from './assets.js';
|
|
6
6
|
import { queryApi } from './context.js';
|
|
7
7
|
import { catalogPage, renderTemplateResult } from './render.js';
|
|
@@ -89,9 +89,10 @@ export function registerReleaseRoutes(app, opts) {
|
|
|
89
89
|
register(scope, route);
|
|
90
90
|
});
|
|
91
91
|
function register(scope, route) {
|
|
92
|
+
const url = route.method === 'GET' ? presentPath(route.path, registry.site.trailingSlash) : route.path;
|
|
92
93
|
scope.route({
|
|
93
94
|
method: route.method,
|
|
94
|
-
url
|
|
95
|
+
url,
|
|
95
96
|
handler: async (request, reply) => {
|
|
96
97
|
const query = plainQuery(request.url);
|
|
97
98
|
const type = request.headers['content-type'] ?? '';
|
|
@@ -112,7 +113,7 @@ export function registerReleaseRoutes(app, opts) {
|
|
|
112
113
|
async render(template, data = {}, o = {}) {
|
|
113
114
|
const read = templateRegistry(registry, template);
|
|
114
115
|
const doc = readData(read, template.name, normalizeContent(read, template.name, data), { fill: true }).data;
|
|
115
|
-
const canonical = route.sitemap === true && request.url.split('?')[0] === encodePath(
|
|
116
|
+
const canonical = route.sitemap === true && request.url.split('?')[0] === encodePath(url) ? route.path : null;
|
|
116
117
|
const rendered = await renderTemplateResult(core, template, doc, { locale, path: route.path, baseUrl, canonical, assets, preview: opts.preview === true, ...(opts.integrations && { integrations: opts.integrations }) });
|
|
117
118
|
const csp = (await opts.integrations?.policy(rendered.scriptHashes)) ?? null;
|
|
118
119
|
const headers = { 'content-type': HTML };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TrailingSlash } from '../../core/site/paths.js';
|
|
1
2
|
interface Item {
|
|
2
3
|
path: string;
|
|
3
4
|
updatedAt?: string;
|
|
@@ -6,5 +7,5 @@ interface Item {
|
|
|
6
7
|
path: string;
|
|
7
8
|
}>;
|
|
8
9
|
}
|
|
9
|
-
export declare function renderSitemap(entries: readonly Item[], baseUrl: string): string;
|
|
10
|
+
export declare function renderSitemap(entries: readonly Item[], baseUrl: string, trailingSlash: TrailingSlash): string;
|
|
10
11
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { escapeHtml } from '../../jsx/html.js';
|
|
2
|
-
import { encodePath } from '../../core/site/paths.js';
|
|
3
|
-
export function renderSitemap(entries, baseUrl) {
|
|
4
|
-
const url = (path) => escapeHtml(`${baseUrl}${path === '/' ? '/' : encodePath(path)}`);
|
|
2
|
+
import { encodePath, presentHref } from '../../core/site/paths.js';
|
|
3
|
+
export function renderSitemap(entries, baseUrl, trailingSlash) {
|
|
4
|
+
const url = (path) => escapeHtml(`${baseUrl}${path === '/' ? '/' : presentHref(encodePath(path), trailingSlash)}`);
|
|
5
5
|
const items = entries.map((e) => {
|
|
6
6
|
const links = e.alternates.map((a) => `<xhtml:link rel="alternate" hreflang="${escapeHtml(a.locale)}" href="${url(a.path)}"/>`);
|
|
7
7
|
return `<url><loc>${url(e.path)}</loc>${e.updatedAt === undefined ? '' : `<lastmod>${escapeHtml(e.updatedAt.slice(0, 10))}</lastmod>`}${links.join('')}</url>`;
|
|
@@ -312,7 +312,8 @@ export declare const en: {
|
|
|
312
312
|
readonly 'error.markdownRenderImage': "This page's Markdown couldn't be shown. Line {line}: the image {src} can't be used. Use an image from the media library, or put the Markdown in a .md file the site imports and name the picture by its path from there.";
|
|
313
313
|
readonly 'error.releaseSignature': "This release isn't signed by a trusted key, so it wasn't opened.";
|
|
314
314
|
readonly 'error.releaseInvalid': "This release file is damaged or wasn't made by inlaycms pack.";
|
|
315
|
-
readonly 'error.
|
|
315
|
+
readonly 'error.releaseTooOld': 'This release was packed with Inlay {packed}. Inlay {version} runs releases packed with Inlay {oldest} or later. Pack the site again with this version and push it.';
|
|
316
|
+
readonly 'error.releaseTooNew': 'This release was packed with Inlay {packed}, which is newer than the Inlay {version} on this server. Upgrade Inlay on the server, then push it again.';
|
|
316
317
|
readonly 'error.releaseNoSite': "The site code in this release doesn't export a site as its default export.";
|
|
317
318
|
readonly 'error.releaseDirNotEmpty': 'The folder {dir} to open the release into must be empty.';
|
|
318
319
|
readonly 'error.releaseDirMissing': "The folder {dir} to open the release into doesn't exist.";
|
|
@@ -343,6 +344,8 @@ export declare const en: {
|
|
|
343
344
|
readonly 'error.pushContentType': 'Send the release file as the request body, with the content type application/gzip.';
|
|
344
345
|
readonly 'error.pushTooLarge': 'This release file is larger than {mb} MB, so it wasn\'t accepted.';
|
|
345
346
|
readonly 'error.pushFailed': 'The release couldn\'t be received: {problem}';
|
|
347
|
+
readonly 'release.packAgain': 'Packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version and push it.';
|
|
348
|
+
readonly 'push.packAgain': 'This release was packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version.';
|
|
346
349
|
readonly 'push.diffUnavailable': "What this release would change in your existing content couldn't be worked out: {reason} The rest of the report is complete.";
|
|
347
350
|
readonly 'error.pushDiffTimeout': 'The preview of the release took more than {seconds} seconds to answer.';
|
|
348
351
|
readonly 'error.pushDiffAnswer': 'The preview of the release answered with an error (status {status}).';
|
|
@@ -418,6 +421,7 @@ export declare const en: {
|
|
|
418
421
|
readonly 'cli.activateNotFound': "There's no release file at {path} and no release with the ID {id}.";
|
|
419
422
|
readonly 'cli.activateName': '--name names a release file as it is stored. Leave it out when activating a stored release by its ID.';
|
|
420
423
|
readonly 'cli.releasesNone': 'There are no releases on this server yet.';
|
|
424
|
+
readonly 'cli.releaseWarning': ' {warning}';
|
|
421
425
|
readonly 'cli.releaseLine': '{id} {name} {state} pushed {pushedAt} made live {activatedAt}';
|
|
422
426
|
readonly 'cli.releaseNeverLive': 'never';
|
|
423
427
|
readonly 'cli.releaseState.staged': 'not live yet';
|
|
@@ -613,6 +617,7 @@ export declare const en: {
|
|
|
613
617
|
readonly 'admin.error.tooLarge': 'What you sent is too large for the site to accept. Go back, make it smaller (for example, fewer or smaller images, or less text), and try again.';
|
|
614
618
|
readonly 'admin.error.badRequest.title': "This couldn't be sent";
|
|
615
619
|
readonly 'admin.error.badRequest': "The site couldn't read what your browser sent. Go back, reload the page and try again.";
|
|
620
|
+
readonly 'admin.notice.dismiss': 'Dismiss';
|
|
616
621
|
readonly 'admin.notice.saved': 'Your changes are saved.';
|
|
617
622
|
readonly 'admin.notice.unchanged': 'Nothing had changed, so there was nothing to save.';
|
|
618
623
|
readonly 'admin.notice.created': 'Created.';
|
|
@@ -702,6 +707,7 @@ export declare const en: {
|
|
|
702
707
|
readonly 'admin.notice.releaseDeleted': 'The release is deleted.';
|
|
703
708
|
readonly 'admin.releases.title': 'Releases';
|
|
704
709
|
readonly 'admin.releases.intro': 'A release is a version of the site\'s design and code. Upload or push a new one, check what it changes, then activate it to make it live.';
|
|
710
|
+
readonly 'admin.releases.packAgainBadge': 'Pack again';
|
|
705
711
|
readonly 'admin.releases.table': 'Releases';
|
|
706
712
|
readonly 'admin.releases.empty': 'No releases yet. Push one from the command line or upload a release file.';
|
|
707
713
|
readonly 'admin.releases.name': 'Name';
|
|
@@ -1402,7 +1408,9 @@ export declare const en: {
|
|
|
1402
1408
|
readonly 'host.workerGaveUp': 'The site kept stopping, so visitors now see the "temporarily unavailable" page. The admin still works. Look at the messages above for the cause, then make a release live again or restart the server.';
|
|
1403
1409
|
readonly 'host.noSiteFailed': 'Even the page shown while the site is down kept stopping, so the server has stopped. Look at the messages above for the cause.';
|
|
1404
1410
|
readonly 'host.releaseMissing': 'The live release {name} is missing from this server, so visitors see the "temporarily unavailable" page. Make it live again with inlaycms activate <file> to bring the site back.';
|
|
1405
|
-
readonly 'host.
|
|
1411
|
+
readonly 'host.releaseTooOld': 'The live release {name} was packed with Inlay {packed}, and Inlay {version} runs releases packed with Inlay {oldest} or later, so visitors see the "temporarily unavailable" page. Pack the site again with this version and push it, or make another release live.';
|
|
1412
|
+
readonly 'host.releasePackAgain': 'The live release {name} was packed with Inlay {packed}. The next version of Inlay that changes what sites use won\'t run it: pack the site again with this version and push it.';
|
|
1413
|
+
readonly 'host.releaseTooNew': 'The live release {name} was packed with Inlay {packed}, which is newer than the Inlay {version} on this server, so visitors see the "temporarily unavailable" page. Upgrade Inlay on the server, or make another release live.';
|
|
1406
1414
|
readonly 'host.servingUnavailable': 'The site is running at {url}, but visitors see the "temporarily unavailable" page until the problem above is fixed.';
|
|
1407
1415
|
readonly 'host.pointerRepaired': 'The note of which release is live was out of date. It now names {name} again, as the database does.';
|
|
1408
1416
|
readonly 'host.pointerUnreadable': "The note of which release is live couldn't be read: {problem}";
|