mothwing 0.0.0-stage → 0.0.2

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/types/seo.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @param {string} description HTML, as the <x-seo> attribute has it
3
+ * @param {number} max
4
+ * @returns {string} At most `max` characters of text, cut at a word so it ends on "...", still HTML
5
+ */
6
+ export function fitDescription(description: string, max: number): string;
7
+ /**
8
+ * The <title>, description, canonical URL, link preview tags and breadcrumbs for <x-seo title="..." description="..."/>.
9
+ * Optional: image="..." image-alt="..." image-size="WxH" for its own preview image, and section="..." name="..." for its
10
+ * breadcrumb in search results.
11
+ * @param {import("./config.js").Site} site
12
+ * @param {import("./routes.js").Route} route
13
+ * @param {Record<string, string | true>} attrs
14
+ * @returns {string[]} The tags, one per line
15
+ */
16
+ export function seoTags(site: import("./config.js").Site, route: import("./routes.js").Route, attrs: Record<string, string | true>): string[];
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Writes the CNAME, sitemaps and robots.txt, those the config turned on.
3
+ * @param {import("./config.js").Site} site
4
+ * @param {import("./routes.js").Route[]} routes
5
+ * @param {boolean} [dated] Add each page's lastmod, from git, which takes a moment
6
+ */
7
+ export function writeSiteFiles(site: import("./config.js").Site, routes: import("./routes.js").Route[], dated?: boolean): Promise<void>;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Pastes in the <x-html src="..."/> partials. One on a line of its own is indented like its tag, so partials are
3
+ * written unindented.
4
+ * @param {string} src The source folder, partials are relative to it
5
+ * @param {string} html
6
+ * @param {string} from For errors, the file `html` came from
7
+ * @param {Set<string>} [used] Gets every partial pasted in, relative to src
8
+ * @param {number} [depth]
9
+ * @returns {string}
10
+ */
11
+ export function includeHtml(src: string, html: string, from: string, used?: Set<string>, depth?: number): string;
12
+ /**
13
+ * {{ name }} is filled with the value as text, {{{ name }}} as HTML, on a line of its own each line indented like it.
14
+ * Names can go into objects: {{ project.name }}.
15
+ * @param {string} html
16
+ * @param {Record<string, any>} values
17
+ * @param {string} from For errors, the page's file
18
+ * @param {Set<string>} [used] Gets the first part of every name filled in
19
+ * @returns {string}
20
+ */
21
+ export function fillPlaceholders(html: string, values: Record<string, any>, from: string, used?: Set<string>): string;
22
+ /**
23
+ * @param {string} html
24
+ * @param {string} from For errors, the page's file
25
+ * @returns {Node[]}
26
+ */
27
+ export function parseTemplate(html: string, from: string): Node[];
28
+ /**
29
+ * Fills in the placeholders and runs the blocks:
30
+ * - <x-each items="projects" as="project">...</x-each> once per item, `index="i"` names its position
31
+ * - <x-if value="project.url">...</x-if> only when it's there, `not="..."` only when it isn't
32
+ * @param {Node[]} nodes
33
+ * @param {Record<string, any>} values
34
+ * @param {Context} context
35
+ * @returns {string}
36
+ */
37
+ export function renderNodes(nodes: Node[], values: Record<string, any>, context: Context): string;
38
+ export function parseAttrs(attrs: string): Record<string, string | true>;
39
+ export function lookup(values: Record<string, any>, name: string): any;
40
+ /**
41
+ * What a page is filled from, and what it used of it.
42
+ */
43
+ export type Context = {
44
+ /**
45
+ * The page, for errors
46
+ */
47
+ from: string;
48
+ /**
49
+ * The first part of every name looked up, "projects" for {{ projects.0.name }}
50
+ */
51
+ used: Set<string>;
52
+ };
53
+ /**
54
+ * A page's HTML split at its <x-each> and <x-if> blocks.
55
+ */
56
+ export type Node = {
57
+ type: "text";
58
+ text: string;
59
+ } | {
60
+ type: "x-each" | "x-if";
61
+ attrs: Record<string, string | true>;
62
+ dedent: number;
63
+ children: Node[];
64
+ };