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/LICENSE +21 -0
- package/README.md +160 -3
- package/bin/mothwing.js +45 -0
- package/package.json +73 -6
- package/src/assets.js +122 -0
- package/src/build.js +104 -0
- package/src/config.js +206 -0
- package/src/csp.js +21 -0
- package/src/data.js +54 -0
- package/src/deps.js +76 -0
- package/src/dev.js +145 -0
- package/src/html.js +67 -0
- package/src/index.js +20 -0
- package/src/log.js +24 -0
- package/src/render.js +162 -0
- package/src/routes.js +125 -0
- package/src/seo.js +105 -0
- package/src/site.js +98 -0
- package/src/template.js +207 -0
- package/types/assets.d.ts +23 -0
- package/types/build.d.ts +34 -0
- package/types/config.d.ts +240 -0
- package/types/csp.d.ts +8 -0
- package/types/data.d.ts +18 -0
- package/types/deps.d.ts +10 -0
- package/types/dev.d.ts +9 -0
- package/types/html.d.ts +12 -0
- package/types/index.d.ts +17 -0
- package/types/log.d.ts +6 -0
- package/types/render.d.ts +42 -0
- package/types/routes.d.ts +39 -0
- package/types/seo.d.ts +16 -0
- package/types/site.d.ts +7 -0
- package/types/template.d.ts +64 -0
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[];
|
package/types/site.d.ts
ADDED
|
@@ -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
|
+
};
|