@sevenfold/setto-client 0.35.0 → 0.36.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.
Files changed (39) hide show
  1. package/dist/SettoAnimation.d.ts +1 -1
  2. package/dist/block-tree/SettoBlockTree.d.ts +2 -2
  3. package/dist/block-tree/extract-keys.d.ts +1 -1
  4. package/dist/block-tree/registry.d.ts +1 -1
  5. package/dist/block-tree/schema.d.ts +3 -3
  6. package/dist/block-tree/validate.d.ts +1 -1
  7. package/dist/blog/SettoBlog.d.ts +20 -0
  8. package/dist/blog/data.d.ts +36 -0
  9. package/dist/blog/index.d.ts +4 -4
  10. package/dist/blog/render.d.ts +16 -0
  11. package/dist/blog/strings.d.ts +25 -0
  12. package/dist/blog/validate.d.ts +1 -1
  13. package/dist/edit-mode/mount.d.ts +1 -1
  14. package/dist/index.d.ts +62 -59
  15. package/dist/lib/api.d.ts +2 -2
  16. package/dist/lib/map-location.d.ts +2 -2
  17. package/dist/lib/page-store.d.ts +1 -1
  18. package/dist/lib/use-site-access.d.ts +1 -1
  19. package/dist/modules/chat/index.d.ts +2 -2
  20. package/dist/modules/domain/index.d.ts +1 -1
  21. package/dist/modules/forms/SettoForm.d.ts +1 -1
  22. package/dist/modules/forms/api.d.ts +1 -1
  23. package/dist/modules/forms/field-tools.d.ts +1 -1
  24. package/dist/modules/forms/index.d.ts +6 -6
  25. package/dist/modules/index.d.ts +2 -2
  26. package/dist/pages/SettoPage.d.ts +1 -1
  27. package/dist/pages/bundled.d.ts +1 -1
  28. package/dist/pages/manifest.d.ts +18 -1
  29. package/dist/provider.d.ts +6 -6
  30. package/dist/setto-client.js +735 -198
  31. package/dist/setto-client.js.map +1 -1
  32. package/dist/types.d.ts +9 -1
  33. package/dist/vite/index.d.ts +6 -0
  34. package/dist/vite/plugin.d.ts +32 -0
  35. package/dist/vite/static.d.ts +78 -0
  36. package/dist/vite.js +550 -0
  37. package/dist/vite.js.map +1 -0
  38. package/package.json +11 -3
  39. package/virtual.d.ts +11 -0
package/dist/types.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { SectionSchema } from './section-schema';
1
+ import type { SettoBlogData } from './blog/data.js';
2
+ import type { SectionSchema } from './section-schema.js';
2
3
  export interface BrandColor {
3
4
  /** Display name in the swatch picker, e.g. 'Beige'. */
4
5
  label: string;
@@ -66,6 +67,13 @@ export interface SettoConfig {
66
67
  images?: {
67
68
  optimize?: boolean;
68
69
  };
70
+ /**
71
+ * The site's blog posts, as its build bundles them: `import blog from
72
+ * 'virtual:setto-blog'` with the `settoBlog()` plugin from
73
+ * `@setto/client/vite`. Without it the `blog` and `blog-latest` sections
74
+ * draw nothing.
75
+ */
76
+ blog?: SettoBlogData;
69
77
  }
70
78
  export interface DeploymentRow {
71
79
  id: string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `@sevenfold/setto-client/vite` — build-time only. Runs in Node inside the
3
+ * site's Vite build; never imported by the site's browser code.
4
+ */
5
+ export { settoBlog } from './plugin.js';
6
+ export type { SettoBlogPluginOptions } from './plugin.js';
@@ -0,0 +1,32 @@
1
+ import type { Plugin } from 'vite';
2
+ import { type BlogFrontmatter } from '../blog/contract.js';
3
+ export interface SettoBlogPluginOptions {
4
+ /**
5
+ * The site's public address, for canonical links, `og:url`, RSS and the
6
+ * sitemap. Otherwise `SETTO_SITE_URL`, then Vercel's
7
+ * `VERCEL_PROJECT_PRODUCTION_URL`, then the first address in
8
+ * `public/sitemap.xml`. Without any, pages still get their own head, only
9
+ * with relative addresses, and no feed.
10
+ */
11
+ siteUrl?: string;
12
+ /** Hosts a post's images may come from. Setto's media store by default. */
13
+ imageHosts?: readonly string[];
14
+ /**
15
+ * Where the blog lives, for a site without a blog page in `pages.json`
16
+ * (one that routes by hand and mounts `<SettoBlog basePath>`). A blog page
17
+ * in the manifest wins.
18
+ */
19
+ blogPath?: string;
20
+ }
21
+ interface LoadedPost {
22
+ key: string;
23
+ frontmatter: BlogFrontmatter;
24
+ body: unknown;
25
+ }
26
+ export declare function loadPosts(root: string, imageHosts: readonly string[]): LoadedPost[];
27
+ export declare function settoBlog(options?: SettoBlogPluginOptions): Plugin;
28
+ /** Exported for tests: everything `writeBundle` does, given a built `outDir`. */
29
+ export declare function writeStaticFiles(root: string, outDir: string, loaded: readonly LoadedPost[], options?: SettoBlogPluginOptions): {
30
+ written: string[];
31
+ };
32
+ export {};
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The static files a blog adds to a site's build: one HTML page per post with
3
+ * its own head, the blog's index page, an RSS feed, and the posts in
4
+ * `sitemap.xml`.
5
+ *
6
+ * Why: the sites are single-page apps — every path is the same `index.html`.
7
+ * Google runs the JavaScript; Facebook, LinkedIn, X, Slack, Messenger and
8
+ * iMessage do not. They fetch the address and read the `og:` tags in the raw
9
+ * HTML, so without a file of its own a shared post shows the front page's
10
+ * title and picture. Vercel serves a real file before it applies the
11
+ * catch-all rewrite, so `/blogg/<slug>` gets this one and the app takes over
12
+ * in the browser as before.
13
+ *
14
+ * Pure functions over strings, so they can be tested without a build.
15
+ */
16
+ import type { BlogFrontmatter } from '../blog/contract.js';
17
+ export interface HeadMeta {
18
+ title: string;
19
+ description: string;
20
+ /** Absolute, when the site's address is known. */
21
+ url?: string;
22
+ /** Absolute. */
23
+ image?: string;
24
+ type: 'article' | 'website';
25
+ locale: string;
26
+ siteName?: string;
27
+ publishedTime?: string;
28
+ jsonLd?: Record<string, unknown>;
29
+ rssUrl?: string;
30
+ /** The same page in other languages, absolute; `x-default` for the primary. */
31
+ alternates?: {
32
+ hreflang: string;
33
+ href: string;
34
+ }[];
35
+ }
36
+ export declare const escapeXml: (value: string) => string;
37
+ /**
38
+ * The site's `index.html` with a page's own head: its title, description,
39
+ * canonical address, Open Graph and Twitter tags and structured data. Any of
40
+ * those the front page already had are taken out first, so a crawler never
41
+ * reads two answers.
42
+ */
43
+ export declare function withHead(indexHtml: string, meta: HeadMeta): string;
44
+ /** `https://x.no` + `/blogg/a` — or the path alone when the address is unknown. */
45
+ export declare function absolute(siteUrl: string | null, pathOrUrl: string): string;
46
+ export interface PostHeadInput {
47
+ post: BlogFrontmatter;
48
+ blogPath: string;
49
+ siteUrl: string | null;
50
+ siteName?: string;
51
+ }
52
+ export declare function postHead({ post, blogPath, siteUrl, siteName }: PostHeadInput): HeadMeta;
53
+ export declare function indexHead({ title, description, blogPath, siteUrl, siteName, locale, }: {
54
+ title: string;
55
+ description: string;
56
+ blogPath: string;
57
+ siteUrl: string | null;
58
+ siteName?: string;
59
+ locale: string;
60
+ }): HeadMeta;
61
+ export declare function rssFeed({ posts, blogPath, siteUrl, title, description, locale, }: {
62
+ posts: readonly BlogFrontmatter[];
63
+ blogPath: string;
64
+ siteUrl: string;
65
+ title: string;
66
+ description: string;
67
+ locale: string;
68
+ }): string;
69
+ /**
70
+ * The site's `sitemap.xml` with the blog and its posts added — before the
71
+ * closing tag, and only those not already listed.
72
+ */
73
+ export declare function withSitemapEntries(sitemap: string, entries: readonly {
74
+ loc: string;
75
+ lastmod?: string;
76
+ }[]): string;
77
+ /** The site's own address, from the first `<loc>` of its sitemap. */
78
+ export declare function originFromSitemap(sitemap: string): string | null;