@sevenfold/setto-client 0.36.1 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blog/SettoBlog.d.ts +46 -0
- package/dist/index.d.ts +3 -2
- package/dist/lib/language-routing.d.ts +10 -0
- package/dist/lib/nested-resource.d.ts +4 -0
- package/dist/pages/SettoPage.d.ts +7 -1
- package/dist/pages/manifest.d.ts +12 -0
- package/dist/setto-client.js +157 -46
- package/dist/setto-client.js.map +1 -1
- package/dist/vite.js.map +1 -1
- package/package.json +1 -1
package/dist/blog/SettoBlog.d.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The blog's two built-in sections (R24).
|
|
3
|
+
*
|
|
4
|
+
* `blog` lives on the blog page and draws either the list of posts or, at
|
|
5
|
+
* `<page path>/<slug>`, one post. `blog-latest` is a band of the newest posts
|
|
6
|
+
* for the front page. Both read the posts the site's build bundles
|
|
7
|
+
* (`SettoConfig.blog`, from `virtual:setto-blog`). The band draws nothing
|
|
8
|
+
* without them; the blog page says there are none yet.
|
|
9
|
+
*
|
|
10
|
+
* The owner, signed in on their own site, also gets the `blog-owner` chrome
|
|
11
|
+
* slot at the top of the blog page: Pixel's welcome on an empty blog, the
|
|
12
|
+
* article Pixel is writing, and a draft waiting for approval — drawn here, in
|
|
13
|
+
* the site's own blog design, by `BlogDraft`, so what the owner approves is
|
|
14
|
+
* what readers will see.
|
|
15
|
+
*
|
|
16
|
+
* The look is the site's: type and colour are inherited, and the stylesheet
|
|
17
|
+
* below only gives shape — scoped under `.setto-blog` so Tailwind's reset
|
|
18
|
+
* cannot strip it, and at zero specificity for colour so the site always
|
|
19
|
+
* wins. However a redesign restyles these classes, the posts keep rendering:
|
|
20
|
+
* the file contract is what may not change.
|
|
21
|
+
*/
|
|
22
|
+
import { type ComponentType } from 'react';
|
|
23
|
+
import type { RootContent } from 'mdast';
|
|
1
24
|
import { type BuiltinSectionProps } from '../pages/SettoPage.js';
|
|
25
|
+
import { type BlogFrontmatter } from './contract.js';
|
|
2
26
|
export declare function SettoBlogSection({ sectionId, first }: BuiltinSectionProps): import("react/jsx-runtime").JSX.Element;
|
|
3
27
|
/**
|
|
4
28
|
* The blog for a site that routes by hand instead of through `pages.json`
|
|
@@ -11,6 +35,28 @@ export declare function SettoBlog({ basePath, title }: {
|
|
|
11
35
|
basePath?: string;
|
|
12
36
|
title?: string;
|
|
13
37
|
}): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
/** A post not yet published, as setto-server sends it: the frontmatter and the body's tree, each node with `at`. */
|
|
39
|
+
export interface BlogDraftData {
|
|
40
|
+
frontmatter: BlogFrontmatter;
|
|
41
|
+
body: {
|
|
42
|
+
children: RootContent[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** What the chrome's `blog-owner` slot is given. */
|
|
46
|
+
export interface BlogOwnerSlotProps {
|
|
47
|
+
blogPath: string;
|
|
48
|
+
language: string;
|
|
49
|
+
/** Published posts in this language, as of the site's last build. */
|
|
50
|
+
posts: number;
|
|
51
|
+
/** Draws a draft in the site's own blog design; title, lead and cover carry `data-setto-field`. */
|
|
52
|
+
Draft: ComponentType<{
|
|
53
|
+
draft: BlogDraftData;
|
|
54
|
+
}>;
|
|
55
|
+
}
|
|
56
|
+
/** A draft, as it will read once published. Given to the chrome's `blog-owner` slot. */
|
|
57
|
+
export declare function BlogDraft({ draft }: {
|
|
58
|
+
draft: BlogDraftData;
|
|
59
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
60
|
export declare function SettoBlogLatest({ sectionId, first }: BuiltinSectionProps): import("react/jsx-runtime").JSX.Element | null;
|
|
15
61
|
/**
|
|
16
62
|
* Shape is scoped `.setto-blog :where(…)` (one class: beats Preflight's
|
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export { SettoImage } from './SettoImage.js';
|
|
|
14
14
|
export type { SettoImageProps, ImageToolsProps } from './SettoImage.js';
|
|
15
15
|
export { SETTO_IMAGE_QUALITY, SETTO_IMAGE_WIDTHS, isOptimizable, optimizedSrcSet, optimizedUrl, settoVercelImagesConfig, } from './lib/optimized-image.js';
|
|
16
16
|
export { SETTO_MEDIA_HOST, isSettoMediaUrl } from './lib/media.js';
|
|
17
|
-
export { SettoBlog, SettoBlogSection, SettoBlogLatest, BLOG_CSS } from './blog/SettoBlog.js';
|
|
17
|
+
export { SettoBlog, SettoBlogSection, SettoBlogLatest, BlogDraft, BLOG_CSS } from './blog/SettoBlog.js';
|
|
18
|
+
export type { BlogDraftData, BlogOwnerSlotProps } from './blog/SettoBlog.js';
|
|
18
19
|
export { postsForLanguage, postForSlug, formatPostDate } from './blog/data.js';
|
|
19
20
|
export type { SettoBlogData, BlogPostData, BlogPostSummary } from './blog/data.js';
|
|
20
21
|
export { SettoRepeater } from './SettoRepeater.js';
|
|
@@ -31,7 +32,7 @@ export type { SettoMapProps } from './SettoMap.js';
|
|
|
31
32
|
export type { MapLocation, MapToolsProps, MapToolsComponent } from './map-tools.js';
|
|
32
33
|
export { SettoPage, SettoTextSection, usePageManifest, useSettoMenu, } from './pages/SettoPage.js';
|
|
33
34
|
export type { SettoPageProps, BuiltinSectionProps } from './pages/SettoPage.js';
|
|
34
|
-
export { PAGES_PATH, PAGES_MANIFEST_VERSION, BUILTIN_SECTION_TYPES, parseManifest, normalisePath, pageForPath, blogPage, blogSlugForPath, pageById, findSection, visibleMenu, applyOp, applyOps, builtinKeys, pageTitleKey, serialiseManifest, isSafeHref, ManifestError, } from './pages/manifest.js';
|
|
35
|
+
export { PAGES_PATH, PAGES_MANIFEST_VERSION, BUILTIN_SECTION_TYPES, parseManifest, normalisePath, pageForPath, blogPage, blogSlugForPath, pageById, findSection, visibleMenu, ownerMenu, applyOp, applyOps, builtinKeys, pageTitleKey, serialiseManifest, isSafeHref, ManifestError, } from './pages/manifest.js';
|
|
35
36
|
export type { PagesManifest, PageEntry, PageSection, MenuItem, MenuList, ManifestOp, ManifestIssue, ManifestParse, BuiltinSectionType, } from './pages/manifest.js';
|
|
36
37
|
export { PageStore, EMPTY_PAGE_STORE_SNAPSHOT, countChanges } from './lib/page-store.js';
|
|
37
38
|
export type { PageStoreSnapshot } from './lib/page-store.js';
|
|
@@ -26,6 +26,16 @@ export interface LanguageRoute {
|
|
|
26
26
|
/** The path with the prefix removed, always starting with `/`. */
|
|
27
27
|
rest: string;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* The address to navigate to, or null when it would leave this origin.
|
|
31
|
+
*
|
|
32
|
+
* A second lock behind `normalise`: whatever the routing above returns, the
|
|
33
|
+
* language switch and the first-visit redirect only ever go somewhere on the
|
|
34
|
+
* site they started on. Resolved by the URL parser itself rather than by a
|
|
35
|
+
* check on the string, so it agrees with the browser about what the address
|
|
36
|
+
* means.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sameOriginUrl(target: string, origin: string): string | null;
|
|
29
39
|
/**
|
|
30
40
|
* Read the language out of a path.
|
|
31
41
|
*
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** True for a single key segment that may be read or written. */
|
|
2
|
+
export declare function isSafeSegment(segment: string): boolean;
|
|
3
|
+
/** True when every segment of a dotted key may be read or written. */
|
|
4
|
+
export declare function isSafeKey(key: string): boolean;
|
|
1
5
|
/** Reads a dotted key path from a nested object. */
|
|
2
6
|
export declare function getNested(obj: unknown, key: string): unknown;
|
|
3
7
|
/** Sets a dotted key path on a nested object (mutates in place). */
|
|
@@ -11,8 +11,14 @@ export declare function usePageManifest(): PagesManifest | null;
|
|
|
11
11
|
*
|
|
12
12
|
* Already filtered: hidden links, links to hidden pages and anchors to hidden
|
|
13
13
|
* sections are gone. Render each label with `<T k={item.labelKey} />`.
|
|
14
|
+
*
|
|
15
|
+
* The signed-in owner also gets the blog's link while the blog has no posts
|
|
16
|
+
* (`ownerMenu`), marked `dimmed` and drawn faded by a stylesheet this hook
|
|
17
|
+
* adds, so no site's navbar has to know about it.
|
|
14
18
|
*/
|
|
15
|
-
export declare function useSettoMenu(list?: MenuList): MenuItem
|
|
19
|
+
export declare function useSettoMenu(list?: MenuList): Array<MenuItem & {
|
|
20
|
+
dimmed?: true;
|
|
21
|
+
}> | null;
|
|
16
22
|
/** What a built-in section's renderer is given. */
|
|
17
23
|
export interface BuiltinSectionProps {
|
|
18
24
|
sectionId: string;
|
package/dist/pages/manifest.d.ts
CHANGED
|
@@ -117,6 +117,18 @@ export declare function findSection(manifest: PagesManifest, sectionId: string):
|
|
|
117
117
|
* winter should not leave a menu entry that scrolls to nothing.
|
|
118
118
|
*/
|
|
119
119
|
export declare function visibleMenu(manifest: PagesManifest, list: MenuList): MenuItem[];
|
|
120
|
+
/**
|
|
121
|
+
* The links the site's owner sees, signed in on their own site.
|
|
122
|
+
*
|
|
123
|
+
* What a visitor sees, and one more: the blog's link while the blog is on but
|
|
124
|
+
* has no posts yet. Visitors are spared a menu entry that leads to an empty
|
|
125
|
+
* page; the owner gets it `dimmed`, as the way in — the empty blog is where
|
|
126
|
+
* Pixel offers to write the first article. A blog link the owner hid
|
|
127
|
+
* themselves once posts exist stays hidden.
|
|
128
|
+
*/
|
|
129
|
+
export declare function ownerMenu(manifest: PagesManifest, list: MenuList, blogEmpty: boolean): Array<MenuItem & {
|
|
130
|
+
dimmed?: true;
|
|
131
|
+
}>;
|
|
120
132
|
export declare class ManifestError extends Error {
|
|
121
133
|
readonly code: 'page_not_found' | 'section_not_found' | 'item_not_found' | 'duplicate_id' | 'duplicate_path' | 'invalid';
|
|
122
134
|
constructor(code: 'page_not_found' | 'section_not_found' | 'item_not_found' | 'duplicate_id' | 'duplicate_path' | 'invalid', message: string);
|
package/dist/setto-client.js
CHANGED
|
@@ -20929,22 +20929,33 @@ function createApi(args) {
|
|
|
20929
20929
|
}
|
|
20930
20930
|
};
|
|
20931
20931
|
}
|
|
20932
|
+
const UNSAFE_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
20933
|
+
function isSafeSegment(segment) {
|
|
20934
|
+
return !UNSAFE_SEGMENTS.has(segment);
|
|
20935
|
+
}
|
|
20936
|
+
function isSafeKey(key) {
|
|
20937
|
+
return key.split(".").every(isSafeSegment);
|
|
20938
|
+
}
|
|
20932
20939
|
function getNested(obj, key) {
|
|
20933
20940
|
if (!obj || typeof obj !== "object") return void 0;
|
|
20941
|
+
if (!isSafeKey(key)) return void 0;
|
|
20934
20942
|
const parts = key.split(".");
|
|
20935
20943
|
let cur = obj;
|
|
20936
20944
|
for (const part of parts) {
|
|
20937
20945
|
if (!cur || typeof cur !== "object") return void 0;
|
|
20946
|
+
if (!Object.prototype.hasOwnProperty.call(cur, part)) return void 0;
|
|
20938
20947
|
cur = cur[part];
|
|
20939
20948
|
}
|
|
20940
20949
|
return cur;
|
|
20941
20950
|
}
|
|
20942
20951
|
function deleteNested(obj, key) {
|
|
20952
|
+
if (!isSafeKey(key)) return;
|
|
20943
20953
|
const parts = key.split(".");
|
|
20944
20954
|
const chain = [obj];
|
|
20945
20955
|
let cur = obj;
|
|
20946
20956
|
for (let i = 0; i < parts.length - 1; i++) {
|
|
20947
20957
|
const part = parts[i];
|
|
20958
|
+
if (!Object.prototype.hasOwnProperty.call(cur, part)) return;
|
|
20948
20959
|
const next = cur[part];
|
|
20949
20960
|
if (!next || typeof next !== "object") return;
|
|
20950
20961
|
cur = next;
|
|
@@ -20959,7 +20970,7 @@ function deleteNested(obj, key) {
|
|
|
20959
20970
|
function collectKeysUnder(obj, prefix) {
|
|
20960
20971
|
const base = getNested(obj, prefix);
|
|
20961
20972
|
if (!base || typeof base !== "object" || Array.isArray(base)) return [];
|
|
20962
|
-
return Object.keys(base).sort(compareListKeys);
|
|
20973
|
+
return Object.keys(base).filter(isSafeSegment).sort(compareListKeys);
|
|
20963
20974
|
}
|
|
20964
20975
|
function compareListKeys(a, b) {
|
|
20965
20976
|
const na = Number(a);
|
|
@@ -21030,6 +21041,7 @@ class I18nStore {
|
|
|
21030
21041
|
* If the value is set back to the original, the draft entry is cleared.
|
|
21031
21042
|
*/
|
|
21032
21043
|
set(key, lng, value) {
|
|
21044
|
+
if (!isSafeKey(key)) return;
|
|
21033
21045
|
const id = `${lng}::${key}`;
|
|
21034
21046
|
const existing = this.drafts.get(id);
|
|
21035
21047
|
const resource = this.i18n.getResource(lng, this.ns, key);
|
|
@@ -21049,6 +21061,7 @@ class I18nStore {
|
|
|
21049
21061
|
* deletion counts as a change and reverts cleanly.
|
|
21050
21062
|
*/
|
|
21051
21063
|
delete(key, lng) {
|
|
21064
|
+
if (!isSafeKey(key)) return;
|
|
21052
21065
|
const id = `${lng}::${key}`;
|
|
21053
21066
|
const existing = this.drafts.get(id);
|
|
21054
21067
|
const resource = this.i18n.getResource(lng, this.ns, key);
|
|
@@ -21212,7 +21225,7 @@ class I18nStore {
|
|
|
21212
21225
|
const walk2 = (value, path2) => {
|
|
21213
21226
|
if (value && typeof value === "object") {
|
|
21214
21227
|
for (const [k, v] of Object.entries(value)) {
|
|
21215
|
-
walk2(v, `${path2}.${k}`);
|
|
21228
|
+
if (isSafeSegment(k)) walk2(v, `${path2}.${k}`);
|
|
21216
21229
|
}
|
|
21217
21230
|
} else if (value !== void 0) {
|
|
21218
21231
|
out.push(path2);
|
|
@@ -21245,8 +21258,16 @@ class I18nStore {
|
|
|
21245
21258
|
}
|
|
21246
21259
|
}
|
|
21247
21260
|
function normalise(pathname) {
|
|
21248
|
-
const
|
|
21249
|
-
return
|
|
21261
|
+
const collapsed = `/${pathname}`.replace(/[\\/]+/g, "/");
|
|
21262
|
+
return collapsed.length > 1 && collapsed.endsWith("/") ? collapsed.slice(0, -1) : collapsed;
|
|
21263
|
+
}
|
|
21264
|
+
function sameOriginUrl(target, origin) {
|
|
21265
|
+
try {
|
|
21266
|
+
const url = new URL(target, origin);
|
|
21267
|
+
return url.origin === origin ? url.href : null;
|
|
21268
|
+
} catch {
|
|
21269
|
+
return null;
|
|
21270
|
+
}
|
|
21250
21271
|
}
|
|
21251
21272
|
function languageFromPath(pathname, languages, primary = languages[0] ?? DEFAULT_LANGUAGE) {
|
|
21252
21273
|
const path2 = normalise(pathname);
|
|
@@ -21276,7 +21297,8 @@ function alternateLinks(origin, pathname, languages, primary = languages[0] ?? D
|
|
|
21276
21297
|
return links;
|
|
21277
21298
|
}
|
|
21278
21299
|
function isReservedPath(pathname) {
|
|
21279
|
-
|
|
21300
|
+
const path2 = normalise(pathname);
|
|
21301
|
+
return path2 === "/setto" || path2.startsWith("/setto/");
|
|
21280
21302
|
}
|
|
21281
21303
|
function redirectForVisitor(pathname, languages, browserLanguages, stored, primary = languages[0] ?? DEFAULT_LANGUAGE) {
|
|
21282
21304
|
if (languages.length < 2) return null;
|
|
@@ -21481,28 +21503,28 @@ function parseManifest(input) {
|
|
|
21481
21503
|
const rawPages = Array.isArray(input.pages) ? input.pages : null;
|
|
21482
21504
|
if (!rawPages) issues.push({ at: "pages", message: "must be a list" });
|
|
21483
21505
|
(rawPages ?? []).forEach((raw, i) => {
|
|
21484
|
-
const
|
|
21506
|
+
const at2 = `pages[${i}]`;
|
|
21485
21507
|
if (!isRecord$1(raw)) {
|
|
21486
|
-
issues.push({ at, message: "not an object" });
|
|
21508
|
+
issues.push({ at: at2, message: "not an object" });
|
|
21487
21509
|
return;
|
|
21488
21510
|
}
|
|
21489
21511
|
const id = String(raw.id ?? "");
|
|
21490
21512
|
const path2 = String(raw.path ?? "");
|
|
21491
21513
|
const titleKey = String(raw.titleKey ?? "");
|
|
21492
|
-
if (!ID.test(id)) issues.push({ at: `${
|
|
21493
|
-
else if (pageIds.has(id)) issues.push({ at: `${
|
|
21514
|
+
if (!ID.test(id)) issues.push({ at: `${at2}.id`, message: `invalid id "${id}"` });
|
|
21515
|
+
else if (pageIds.has(id)) issues.push({ at: `${at2}.id`, message: `duplicate page "${id}"` });
|
|
21494
21516
|
pageIds.add(id);
|
|
21495
|
-
if (!PATH.test(path2)) issues.push({ at: `${
|
|
21517
|
+
if (!PATH.test(path2)) issues.push({ at: `${at2}.path`, message: `invalid path "${path2}"` });
|
|
21496
21518
|
else if (path2 === "/setto" || path2.startsWith("/setto/")) {
|
|
21497
|
-
issues.push({ at: `${
|
|
21498
|
-
} else if (paths.has(path2)) issues.push({ at: `${
|
|
21519
|
+
issues.push({ at: `${at2}.path`, message: "/setto belongs to the editor" });
|
|
21520
|
+
} else if (paths.has(path2)) issues.push({ at: `${at2}.path`, message: `duplicate path "${path2}"` });
|
|
21499
21521
|
paths.add(path2);
|
|
21500
|
-
if (!titleKey) issues.push({ at: `${
|
|
21522
|
+
if (!titleKey) issues.push({ at: `${at2}.titleKey`, message: "required" });
|
|
21501
21523
|
const sections = [];
|
|
21502
21524
|
const rawSections = Array.isArray(raw.sections) ? raw.sections : null;
|
|
21503
|
-
if (!rawSections) issues.push({ at: `${
|
|
21525
|
+
if (!rawSections) issues.push({ at: `${at2}.sections`, message: "must be a list" });
|
|
21504
21526
|
(rawSections ?? []).forEach((s, j) => {
|
|
21505
|
-
const sat = `${
|
|
21527
|
+
const sat = `${at2}.sections[${j}]`;
|
|
21506
21528
|
if (!isRecord$1(s)) {
|
|
21507
21529
|
issues.push({ at: sat, message: "not an object" });
|
|
21508
21530
|
return;
|
|
@@ -21544,16 +21566,16 @@ function parseManifest(input) {
|
|
|
21544
21566
|
if (issues.length > 0) return { ok: false, issues };
|
|
21545
21567
|
return { ok: true, manifest: { version: PAGES_MANIFEST_VERSION, pages, menu, footer: footer2 } };
|
|
21546
21568
|
}
|
|
21547
|
-
function parseMenu(raw,
|
|
21569
|
+
function parseMenu(raw, at2, issues) {
|
|
21548
21570
|
if (raw === void 0) return [];
|
|
21549
21571
|
if (!Array.isArray(raw)) {
|
|
21550
|
-
issues.push({ at, message: "must be a list" });
|
|
21572
|
+
issues.push({ at: at2, message: "must be a list" });
|
|
21551
21573
|
return [];
|
|
21552
21574
|
}
|
|
21553
21575
|
const ids = /* @__PURE__ */ new Set();
|
|
21554
21576
|
const items = [];
|
|
21555
21577
|
raw.forEach((item, i) => {
|
|
21556
|
-
const iat = `${
|
|
21578
|
+
const iat = `${at2}[${i}]`;
|
|
21557
21579
|
if (!isRecord$1(item)) {
|
|
21558
21580
|
issues.push({ at: iat, message: "not an object" });
|
|
21559
21581
|
return;
|
|
@@ -21613,6 +21635,15 @@ function findSection(manifest, sectionId) {
|
|
|
21613
21635
|
function visibleMenu(manifest, list2) {
|
|
21614
21636
|
return manifest[list2].filter((item) => !item.hidden && !leadsNowhere(manifest, item.href));
|
|
21615
21637
|
}
|
|
21638
|
+
function ownerMenu(manifest, list2, blogEmpty) {
|
|
21639
|
+
const blog = blogPage(manifest);
|
|
21640
|
+
const waiting = blogEmpty && blog && !blog.page.hidden && !blog.section.hidden ? normalisePath(blog.page.path) : null;
|
|
21641
|
+
return manifest[list2].flatMap((item) => {
|
|
21642
|
+
if (!item.hidden && !leadsNowhere(manifest, item.href)) return [item];
|
|
21643
|
+
if (waiting && item.hidden && normalisePath(item.href) === waiting) return [{ ...item, dimmed: true }];
|
|
21644
|
+
return [];
|
|
21645
|
+
});
|
|
21646
|
+
}
|
|
21616
21647
|
function leadsNowhere(manifest, href) {
|
|
21617
21648
|
if (!href.startsWith("/") && !href.startsWith("#")) return false;
|
|
21618
21649
|
const [pathPart, fragment] = href.split("#");
|
|
@@ -21656,8 +21687,8 @@ function placeSection(manifest, sectionId, index2) {
|
|
|
21656
21687
|
const found = findSection(next, sectionId);
|
|
21657
21688
|
if (!found) throw new ManifestError("section_not_found", `no section "${sectionId}"`);
|
|
21658
21689
|
const [moved] = found.page.sections.splice(found.index, 1);
|
|
21659
|
-
const
|
|
21660
|
-
found.page.sections.splice(
|
|
21690
|
+
const at2 = Math.max(0, Math.min(index2, found.page.sections.length));
|
|
21691
|
+
found.page.sections.splice(at2, 0, moved);
|
|
21661
21692
|
return next;
|
|
21662
21693
|
}
|
|
21663
21694
|
function setSectionHidden(manifest, sectionId, hidden) {
|
|
@@ -21675,8 +21706,8 @@ function addSection(manifest, pageId, section, index2) {
|
|
|
21675
21706
|
}
|
|
21676
21707
|
const next = clone(manifest);
|
|
21677
21708
|
const page = mustPage(next, pageId);
|
|
21678
|
-
const
|
|
21679
|
-
page.sections.splice(
|
|
21709
|
+
const at2 = index2 === void 0 ? page.sections.length : Math.max(0, Math.min(index2, page.sections.length));
|
|
21710
|
+
page.sections.splice(at2, 0, { ...section });
|
|
21680
21711
|
return next;
|
|
21681
21712
|
}
|
|
21682
21713
|
function addPage(manifest, page) {
|
|
@@ -34621,19 +34652,19 @@ class EditMap {
|
|
|
34621
34652
|
this.index.clear();
|
|
34622
34653
|
}
|
|
34623
34654
|
}
|
|
34624
|
-
function addImplementation(editMap,
|
|
34655
|
+
function addImplementation(editMap, at2, remove2, add) {
|
|
34625
34656
|
if (remove2 === 0 && add.length === 0) {
|
|
34626
34657
|
return;
|
|
34627
34658
|
}
|
|
34628
|
-
const existing = editMap.index.get(
|
|
34659
|
+
const existing = editMap.index.get(at2);
|
|
34629
34660
|
if (existing) {
|
|
34630
34661
|
existing[1] += remove2;
|
|
34631
34662
|
existing[2].push(...add);
|
|
34632
34663
|
return;
|
|
34633
34664
|
}
|
|
34634
|
-
const change = [
|
|
34665
|
+
const change = [at2, remove2, add];
|
|
34635
34666
|
editMap.map.push(change);
|
|
34636
|
-
editMap.index.set(
|
|
34667
|
+
editMap.index.set(at2, change);
|
|
34637
34668
|
}
|
|
34638
34669
|
function gfmTableAlign(events, index2) {
|
|
34639
34670
|
let inDelimiterRow = false;
|
|
@@ -35213,11 +35244,11 @@ function createTypingSender(send, now = Date.now) {
|
|
|
35213
35244
|
stop();
|
|
35214
35245
|
return;
|
|
35215
35246
|
}
|
|
35216
|
-
const
|
|
35217
|
-
if (typing &&
|
|
35247
|
+
const at2 = now();
|
|
35248
|
+
if (typing && at2 - lastSentAt < TYPING_THROTTLE_MS) return;
|
|
35218
35249
|
if (send(true)) {
|
|
35219
35250
|
typing = true;
|
|
35220
|
-
lastSentAt =
|
|
35251
|
+
lastSentAt = at2;
|
|
35221
35252
|
}
|
|
35222
35253
|
}
|
|
35223
35254
|
return { update, stop, reset };
|
|
@@ -36780,8 +36811,14 @@ function SettoProvider({ config, children }) {
|
|
|
36780
36811
|
readStoredLanguage()
|
|
36781
36812
|
);
|
|
36782
36813
|
if (redirect && redirect !== window.location.pathname) {
|
|
36783
|
-
|
|
36784
|
-
|
|
36814
|
+
const url = sameOriginUrl(
|
|
36815
|
+
redirect + window.location.search + window.location.hash,
|
|
36816
|
+
window.location.origin
|
|
36817
|
+
);
|
|
36818
|
+
if (url) {
|
|
36819
|
+
window.location.replace(url);
|
|
36820
|
+
return;
|
|
36821
|
+
}
|
|
36785
36822
|
}
|
|
36786
36823
|
const { language } = languageFromPath(window.location.pathname, languages);
|
|
36787
36824
|
if (language !== i18n.language) void i18n.changeLanguage(language);
|
|
@@ -36932,7 +36969,8 @@ function SettoLanguages({ languages: given, inline = false }) {
|
|
|
36932
36969
|
if (tag === current) return;
|
|
36933
36970
|
storeLanguage(tag);
|
|
36934
36971
|
const target = pathForLanguage(window.location.pathname, tag, languages);
|
|
36935
|
-
|
|
36972
|
+
const url = sameOriginUrl(target + window.location.search + window.location.hash, window.location.origin);
|
|
36973
|
+
if (url) window.location.assign(url);
|
|
36936
36974
|
};
|
|
36937
36975
|
return /* @__PURE__ */ jsxs("div", { ref, style: inline ? inlineWrapStyle : floatingWrapStyle, children: [
|
|
36938
36976
|
/* @__PURE__ */ jsxs(
|
|
@@ -38172,7 +38210,49 @@ function usePageManifest() {
|
|
|
38172
38210
|
}
|
|
38173
38211
|
function useSettoMenu(list2 = "menu") {
|
|
38174
38212
|
const manifest = usePageManifest();
|
|
38175
|
-
|
|
38213
|
+
const { canEdit, config } = useSetto();
|
|
38214
|
+
const blogEmpty = (config.blog?.posts.length ?? 0) === 0;
|
|
38215
|
+
const items = manifest ? canEdit ? ownerMenu(manifest, list2, blogEmpty) : visibleMenu(manifest, list2) : null;
|
|
38216
|
+
const dimmed = items?.filter((item) => item.dimmed).map((item) => item.href) ?? [];
|
|
38217
|
+
useDimmedLinks(dimmed, config.languages ?? []);
|
|
38218
|
+
return items;
|
|
38219
|
+
}
|
|
38220
|
+
const DIM_STYLE_ID = "setto-dimmed-links";
|
|
38221
|
+
const dimmedBy = /* @__PURE__ */ new Map();
|
|
38222
|
+
function drawDimmedLinks() {
|
|
38223
|
+
if (typeof document === "undefined") return;
|
|
38224
|
+
const selectors = [...new Set([...dimmedBy.values()].flat())];
|
|
38225
|
+
let style = document.getElementById(DIM_STYLE_ID);
|
|
38226
|
+
if (!selectors.length) {
|
|
38227
|
+
style?.remove();
|
|
38228
|
+
return;
|
|
38229
|
+
}
|
|
38230
|
+
if (!style) {
|
|
38231
|
+
style = document.createElement("style");
|
|
38232
|
+
style.id = DIM_STYLE_ID;
|
|
38233
|
+
document.head.appendChild(style);
|
|
38234
|
+
}
|
|
38235
|
+
style.textContent = `${selectors.join(",")}{opacity:.45;transition:opacity .15s}${selectors.map((s) => `${s}:hover`).join(",")}{opacity:.8}`;
|
|
38236
|
+
}
|
|
38237
|
+
function useDimmedLinks(hrefs, languages) {
|
|
38238
|
+
const key = hrefs.join("|");
|
|
38239
|
+
const langs = languages.join(",");
|
|
38240
|
+
useEffect(() => {
|
|
38241
|
+
if (!key) return;
|
|
38242
|
+
const mine = {};
|
|
38243
|
+
dimmedBy.set(
|
|
38244
|
+
mine,
|
|
38245
|
+
key.split("|").flatMap((href) => [
|
|
38246
|
+
`a[href="${href}"]`,
|
|
38247
|
+
...langs.split(",").slice(1).filter(Boolean).map((language) => `a[href="/${language}${href}"]`)
|
|
38248
|
+
])
|
|
38249
|
+
);
|
|
38250
|
+
drawDimmedLinks();
|
|
38251
|
+
return () => {
|
|
38252
|
+
dimmedBy.delete(mine);
|
|
38253
|
+
drawDimmedLinks();
|
|
38254
|
+
};
|
|
38255
|
+
}, [key, langs]);
|
|
38176
38256
|
}
|
|
38177
38257
|
function SettoPage({ pageId, path: path2, sections = {}, builtins, fallback = null }) {
|
|
38178
38258
|
const manifest = usePageManifest();
|
|
@@ -38427,13 +38507,21 @@ function blogStrings(language) {
|
|
|
38427
38507
|
function BlogBody({ nodes, language }) {
|
|
38428
38508
|
return /* @__PURE__ */ jsx(Fragment, { children: nodes.map((node2, i) => renderFlow(node2, i, language)) });
|
|
38429
38509
|
}
|
|
38510
|
+
function at(node2) {
|
|
38511
|
+
const range = node2.at;
|
|
38512
|
+
return Array.isArray(range) && range.length === 2 && range.every((n) => Number.isInteger(n)) ? { "data-setto-at": `${range[0]}:${range[1]}` } : {};
|
|
38513
|
+
}
|
|
38514
|
+
function atImage(node2, alt) {
|
|
38515
|
+
const where = at(node2);
|
|
38516
|
+
return where["data-setto-at"] ? { ...where, "data-setto-kind": "image", "data-setto-alt": alt } : {};
|
|
38517
|
+
}
|
|
38430
38518
|
function renderFlow(node2, key, language) {
|
|
38431
38519
|
switch (node2.type) {
|
|
38432
38520
|
case "paragraph":
|
|
38433
|
-
return /* @__PURE__ */ jsx("p", { children: renderPhrasing(node2.children) }, key);
|
|
38521
|
+
return /* @__PURE__ */ jsx("p", { ...at(node2), children: renderPhrasing(node2.children) }, key);
|
|
38434
38522
|
case "heading": {
|
|
38435
38523
|
const Tag = node2.depth === 2 ? "h2" : node2.depth === 3 ? "h3" : "h4";
|
|
38436
|
-
return /* @__PURE__ */ jsx(Tag, { children: renderPhrasing(node2.children) }, key);
|
|
38524
|
+
return /* @__PURE__ */ jsx(Tag, { ...at(node2), children: renderPhrasing(node2.children) }, key);
|
|
38437
38525
|
}
|
|
38438
38526
|
case "list": {
|
|
38439
38527
|
const items = node2.children.map((item, i) => /* @__PURE__ */ jsx("li", { children: item.children.map((child, j) => renderListChild(child, j, item.spread === true, language)) }, i));
|
|
@@ -38454,7 +38542,8 @@ function renderFlow(node2, key, language) {
|
|
|
38454
38542
|
}
|
|
38455
38543
|
}
|
|
38456
38544
|
function renderListChild(child, key, spread, language) {
|
|
38457
|
-
if (child.type === "paragraph" && !spread)
|
|
38545
|
+
if (child.type === "paragraph" && !spread)
|
|
38546
|
+
return /* @__PURE__ */ jsx("span", { ...at(child), children: renderPhrasing(child.children) }, key);
|
|
38458
38547
|
return renderFlow(child, key, language);
|
|
38459
38548
|
}
|
|
38460
38549
|
function renderPhrasing(children) {
|
|
@@ -38503,7 +38592,7 @@ function BlogComponent({ element: element2, language }) {
|
|
|
38503
38592
|
const props = attrs(element2);
|
|
38504
38593
|
switch (element2.name) {
|
|
38505
38594
|
case "Image":
|
|
38506
|
-
return props.src && props.alt !== void 0 ? /* @__PURE__ */ jsxs("figure", { className: "setto-blog__figure", children: [
|
|
38595
|
+
return props.src && props.alt !== void 0 ? /* @__PURE__ */ jsxs("figure", { className: "setto-blog__figure", ...atImage(element2, props.alt), children: [
|
|
38507
38596
|
/* @__PURE__ */ jsx(BlogImg, { src: props.src, alt: props.alt, sizes: "(min-width: 760px) 720px, 100vw" }),
|
|
38508
38597
|
props.caption ? /* @__PURE__ */ jsx("figcaption", { children: props.caption }) : null
|
|
38509
38598
|
] }) : null;
|
|
@@ -38514,7 +38603,7 @@ function BlogComponent({ element: element2, language }) {
|
|
|
38514
38603
|
return /* @__PURE__ */ jsxs("figure", { className: "setto-blog__gallery", children: [
|
|
38515
38604
|
/* @__PURE__ */ jsx("div", { className: "setto-blog__gallery-grid", children: images.map((image2, i) => {
|
|
38516
38605
|
const a = attrs(image2);
|
|
38517
|
-
return a.src ? /* @__PURE__ */ jsxs("figure", { className: "setto-blog__gallery-item", children: [
|
|
38606
|
+
return a.src ? /* @__PURE__ */ jsxs("figure", { className: "setto-blog__gallery-item", ...atImage(image2, a.alt ?? ""), children: [
|
|
38518
38607
|
/* @__PURE__ */ jsx(BlogImg, { src: a.src, alt: a.alt ?? "", sizes: "(min-width: 760px) 360px, 50vw" }),
|
|
38519
38608
|
a.caption ? /* @__PURE__ */ jsx("figcaption", { children: a.caption }) : null
|
|
38520
38609
|
] }, i) : null;
|
|
@@ -38629,16 +38718,19 @@ function useClearFixedHeader(ref, enabled) {
|
|
|
38629
38718
|
return clear;
|
|
38630
38719
|
}
|
|
38631
38720
|
function fixedAncestor(node2) {
|
|
38632
|
-
for (let
|
|
38633
|
-
if (getComputedStyle(
|
|
38721
|
+
for (let at2 = node2; at2 && at2 !== document.body; at2 = at2.parentElement) {
|
|
38722
|
+
if (getComputedStyle(at2).position === "fixed") return at2;
|
|
38634
38723
|
}
|
|
38635
38724
|
return null;
|
|
38636
38725
|
}
|
|
38637
38726
|
function BlogIndexView({ title, first, blogPath, ctx }) {
|
|
38638
38727
|
const posts = ctx.config.blog ? postsForLanguage(ctx.config.blog.posts, ctx.language, ctx.fallbackLanguage) : [];
|
|
38639
38728
|
const Heading = first ? "h1" : "h2";
|
|
38729
|
+
const { canEdit } = useSetto();
|
|
38730
|
+
const Owner = useSettoChromeSlot("blog-owner");
|
|
38640
38731
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
38641
38732
|
/* @__PURE__ */ jsx(Heading, { className: "setto-blog__title", children: title }),
|
|
38733
|
+
canEdit && Owner ? /* @__PURE__ */ jsx("div", { className: "setto-blog__owner", "data-setto-ui": "", children: /* @__PURE__ */ jsx(Owner, { blogPath, language: ctx.language, posts: posts.length, Draft: BlogDraft }) }) : null,
|
|
38642
38734
|
posts.length === 0 ? /* @__PURE__ */ jsx("p", { className: "setto-blog__empty", children: ctx.strings.empty }) : /* @__PURE__ */ jsx("div", { className: "setto-blog__list", children: posts.map((post2) => /* @__PURE__ */ jsx(PostCard, { post: post2, blogPath, ctx, headingLevel: first ? "h2" : "h3" }, post2.slug)) })
|
|
38643
38735
|
] });
|
|
38644
38736
|
}
|
|
@@ -38698,18 +38790,35 @@ function BlogPostView({ slug, blogPath, ctx }) {
|
|
|
38698
38790
|
] });
|
|
38699
38791
|
}
|
|
38700
38792
|
const fm = post2?.frontmatter ?? summary;
|
|
38793
|
+
return /* @__PURE__ */ jsx(PostArticle, { frontmatter: fm, ctx, before: back, after: /* @__PURE__ */ jsx(ShareBar, { title: fm.title, strings: ctx.strings }), children: state === "ready" && post2 ? /* @__PURE__ */ jsx(BlogBody, { nodes: post2.body.children, language: ctx.language }) : /* @__PURE__ */ jsx("p", { className: "setto-blog__loading", "aria-live": "polite", children: ctx.strings.loading }) });
|
|
38794
|
+
}
|
|
38795
|
+
function PostArticle({
|
|
38796
|
+
frontmatter: fm,
|
|
38797
|
+
ctx,
|
|
38798
|
+
before,
|
|
38799
|
+
after,
|
|
38800
|
+
draft = false,
|
|
38801
|
+
children
|
|
38802
|
+
}) {
|
|
38803
|
+
const field = (name2) => draft ? { "data-setto-field": name2 } : {};
|
|
38804
|
+
const Title = draft ? "h2" : "h1";
|
|
38701
38805
|
return /* @__PURE__ */ jsxs("article", { className: "setto-blog__post", lang: fm.locale, children: [
|
|
38702
|
-
|
|
38806
|
+
before,
|
|
38703
38807
|
/* @__PURE__ */ jsxs("header", { className: "setto-blog__post-header", children: [
|
|
38704
38808
|
/* @__PURE__ */ jsx("time", { className: "setto-blog__date", dateTime: fm.date, children: formatPostDate(fm.date, ctx.language) }),
|
|
38705
|
-
/* @__PURE__ */ jsx(
|
|
38706
|
-
/* @__PURE__ */ jsx("p", { className: "setto-blog__lead", children: fm.description })
|
|
38809
|
+
/* @__PURE__ */ jsx(Title, { className: "setto-blog__post-title", ...field("title"), children: fm.title }),
|
|
38810
|
+
/* @__PURE__ */ jsx("p", { className: "setto-blog__lead", ...field("description"), children: fm.description })
|
|
38707
38811
|
] }),
|
|
38708
|
-
fm.cover ? /* @__PURE__ */ jsx("figure", { className: "setto-blog__cover", children: /* @__PURE__ */ jsx(BlogImg, { src: fm.cover, alt: "", sizes: "(min-width: 1040px) 960px, 100vw" }) }) : null,
|
|
38709
|
-
|
|
38710
|
-
|
|
38812
|
+
fm.cover ? /* @__PURE__ */ jsx("figure", { className: "setto-blog__cover", ...field("cover"), children: /* @__PURE__ */ jsx(BlogImg, { src: fm.cover, alt: "", sizes: "(min-width: 1040px) 960px, 100vw" }) }) : null,
|
|
38813
|
+
/* @__PURE__ */ jsx("div", { className: "setto-blog__prose", children }),
|
|
38814
|
+
after
|
|
38711
38815
|
] });
|
|
38712
38816
|
}
|
|
38817
|
+
function BlogDraft({ draft }) {
|
|
38818
|
+
useBlogStyles();
|
|
38819
|
+
const ctx = useBlogContext();
|
|
38820
|
+
return /* @__PURE__ */ jsx(PostArticle, { frontmatter: draft.frontmatter, ctx, draft: true, children: /* @__PURE__ */ jsx(BlogBody, { nodes: draft.body.children, language: ctx.language }) });
|
|
38821
|
+
}
|
|
38713
38822
|
function usePostTitle(title, siteName) {
|
|
38714
38823
|
useEffect(() => {
|
|
38715
38824
|
if (!title || typeof document === "undefined") return;
|
|
@@ -40815,6 +40924,7 @@ export {
|
|
|
40815
40924
|
BLOCK_TYPES,
|
|
40816
40925
|
BLOG_CSS,
|
|
40817
40926
|
BUILTIN_SECTION_TYPES,
|
|
40927
|
+
BlogDraft,
|
|
40818
40928
|
CHECKOUT_INTENT,
|
|
40819
40929
|
DEFAULT_LANGUAGE,
|
|
40820
40930
|
EMPTY_I18N_STORE_SNAPSHOT,
|
|
@@ -40888,6 +40998,7 @@ export {
|
|
|
40888
40998
|
normalisePath,
|
|
40889
40999
|
optimizedSrcSet,
|
|
40890
41000
|
optimizedUrl,
|
|
41001
|
+
ownerMenu,
|
|
40891
41002
|
pageById,
|
|
40892
41003
|
pageForPath,
|
|
40893
41004
|
pageTitleKey,
|