@kensio/colophon 2.2.0 → 2.3.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/README.md +560 -24
- package/dist/cli/args.d.ts +14 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +67 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/config.d.ts +12 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +43 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +35 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli.js +34 -6
- package/dist/cli.js.map +1 -1
- package/dist/config/defaults.d.ts +64 -0
- package/dist/config/defaults.d.ts.map +1 -0
- package/dist/config/defaults.js +64 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +22 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +52 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/resolve.d.ts +24 -0
- package/dist/config/resolve.d.ts.map +1 -0
- package/dist/config/resolve.js +66 -0
- package/dist/config/resolve.js.map +1 -0
- package/dist/config/size.d.ts +20 -0
- package/dist/config/size.d.ts.map +1 -0
- package/dist/config/size.js +46 -0
- package/dist/config/size.js.map +1 -0
- package/dist/config.d.ts +27 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +78 -2
- package/dist/config.js.map +1 -1
- package/dist/content/index.d.ts +5 -51
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +3 -115
- package/dist/content/index.js.map +1 -1
- package/dist/content/props.d.ts +15 -0
- package/dist/content/props.d.ts.map +1 -0
- package/dist/content/props.js +71 -0
- package/dist/content/props.js.map +1 -0
- package/dist/content/slug.d.ts +23 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +52 -0
- package/dist/content/slug.js.map +1 -0
- package/dist/content/walk.d.ts +17 -0
- package/dist/content/walk.d.ts.map +1 -0
- package/dist/content/walk.js +57 -0
- package/dist/content/walk.js.map +1 -0
- package/dist/fonts/index.d.ts +10 -0
- package/dist/fonts/index.d.ts.map +1 -0
- package/dist/fonts/index.js +11 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/materialise.d.ts +7 -0
- package/dist/fonts/materialise.d.ts.map +1 -0
- package/dist/fonts/materialise.js +47 -0
- package/dist/fonts/materialise.js.map +1 -0
- package/dist/fonts/resolve.d.ts +7 -0
- package/dist/fonts/resolve.d.ts.map +1 -0
- package/dist/fonts/resolve.js +50 -0
- package/dist/fonts/resolve.js.map +1 -0
- package/dist/fonts.d.ts +18 -0
- package/dist/fonts.d.ts.map +1 -0
- package/dist/fonts.js +102 -0
- package/dist/fonts.js.map +1 -0
- package/dist/generate/extra.d.ts +16 -0
- package/dist/generate/extra.d.ts.map +1 -0
- package/dist/generate/extra.js +60 -0
- package/dist/generate/extra.js.map +1 -0
- package/dist/generate/index.d.ts +19 -0
- package/dist/generate/index.d.ts.map +1 -0
- package/dist/generate/index.js +46 -0
- package/dist/generate/index.js.map +1 -0
- package/dist/generate/job.d.ts +35 -0
- package/dist/generate/job.d.ts.map +1 -0
- package/dist/generate/job.js +2 -0
- package/dist/generate/job.js.map +1 -0
- package/dist/generate/options.d.ts +56 -0
- package/dist/generate/options.d.ts.map +1 -0
- package/dist/generate/options.js +17 -0
- package/dist/generate/options.js.map +1 -0
- package/dist/generate/output-path.d.ts +12 -0
- package/dist/generate/output-path.d.ts.map +1 -0
- package/dist/generate/output-path.js +18 -0
- package/dist/generate/output-path.js.map +1 -0
- package/dist/generate/outputs.d.ts +28 -0
- package/dist/generate/outputs.d.ts.map +1 -0
- package/dist/generate/outputs.js +71 -0
- package/dist/generate/outputs.js.map +1 -0
- package/dist/generate/plan.d.ts +21 -0
- package/dist/generate/plan.d.ts.map +1 -0
- package/dist/generate/plan.js +72 -0
- package/dist/generate/plan.js.map +1 -0
- package/dist/generate/render-image.d.ts +11 -0
- package/dist/generate/render-image.d.ts.map +1 -0
- package/dist/generate/render-image.js +27 -0
- package/dist/generate/render-image.js.map +1 -0
- package/dist/generate.d.ts +27 -6
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +69 -15
- package/dist/generate.js.map +1 -1
- package/dist/highlight/color.d.ts +9 -0
- package/dist/highlight/color.d.ts.map +1 -0
- package/dist/highlight/color.js +15 -0
- package/dist/highlight/color.js.map +1 -0
- package/dist/highlight/grid.d.ts +14 -0
- package/dist/highlight/grid.d.ts.map +1 -0
- package/dist/highlight/grid.js +36 -0
- package/dist/highlight/grid.js.map +1 -0
- package/dist/highlight/index.d.ts +12 -0
- package/dist/highlight/index.d.ts.map +1 -0
- package/dist/highlight/index.js +31 -0
- package/dist/highlight/index.js.map +1 -0
- package/dist/highlight/language.d.ts +14 -0
- package/dist/highlight/language.d.ts.map +1 -0
- package/dist/highlight/language.js +42 -0
- package/dist/highlight/language.js.map +1 -0
- package/dist/highlight/normalise.d.ts +17 -0
- package/dist/highlight/normalise.d.ts.map +1 -0
- package/dist/highlight/normalise.js +37 -0
- package/dist/highlight/normalise.js.map +1 -0
- package/dist/highlight/types.d.ts +40 -0
- package/dist/highlight/types.d.ts.map +1 -0
- package/dist/highlight/types.js +2 -0
- package/dist/highlight/types.js.map +1 -0
- package/dist/index.d.ts +15 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/manifest/build.d.ts +14 -0
- package/dist/manifest/build.d.ts.map +1 -0
- package/dist/manifest/build.js +43 -0
- package/dist/manifest/build.js.map +1 -0
- package/dist/manifest/index.d.ts +27 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +31 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/order.d.ts +12 -0
- package/dist/manifest/order.d.ts.map +1 -0
- package/dist/manifest/order.js +17 -0
- package/dist/manifest/order.js.map +1 -0
- package/dist/manifest/page.d.ts +24 -0
- package/dist/manifest/page.d.ts.map +1 -0
- package/dist/manifest/page.js +55 -0
- package/dist/manifest/page.js.map +1 -0
- package/dist/meta/html.d.ts +14 -0
- package/dist/meta/html.d.ts.map +1 -0
- package/dist/meta/html.js +24 -0
- package/dist/meta/html.js.map +1 -0
- package/dist/meta/index.d.ts +11 -0
- package/dist/meta/index.d.ts.map +1 -0
- package/dist/meta/index.js +11 -0
- package/dist/meta/index.js.map +1 -0
- package/dist/meta/tags.d.ts +21 -0
- package/dist/meta/tags.d.ts.map +1 -0
- package/dist/meta/tags.js +72 -0
- package/dist/meta/tags.js.map +1 -0
- package/dist/meta/url.d.ts +15 -0
- package/dist/meta/url.d.ts.map +1 -0
- package/dist/meta/url.js +34 -0
- package/dist/meta/url.js.map +1 -0
- package/dist/placement/check.d.ts +16 -0
- package/dist/placement/check.d.ts.map +1 -0
- package/dist/placement/check.js +40 -0
- package/dist/placement/check.js.map +1 -0
- package/dist/placement/index.d.ts +29 -0
- package/dist/placement/index.d.ts.map +1 -0
- package/dist/placement/index.js +61 -0
- package/dist/placement/index.js.map +1 -0
- package/dist/placement/relative.d.ts +31 -0
- package/dist/placement/relative.d.ts.map +1 -0
- package/dist/placement/relative.js +53 -0
- package/dist/placement/relative.js.map +1 -0
- package/dist/pool.d.ts +18 -0
- package/dist/pool.d.ts.map +1 -0
- package/dist/pool.js +56 -0
- package/dist/pool.js.map +1 -0
- package/dist/render/index.d.ts +10 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/png.d.ts +10 -0
- package/dist/render/png.d.ts.map +1 -0
- package/dist/render/png.js +30 -0
- package/dist/render/png.js.map +1 -0
- package/dist/render/svg.d.ts +10 -0
- package/dist/render/svg.d.ts.map +1 -0
- package/dist/render/svg.js +20 -0
- package/dist/render/svg.js.map +1 -0
- package/dist/render/template.d.ts +9 -0
- package/dist/render/template.d.ts.map +1 -0
- package/dist/render/template.js +17 -0
- package/dist/render/template.js.map +1 -0
- package/dist/render.d.ts +6 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +31 -10
- package/dist/render.js.map +1 -1
- package/dist/stamp/chunk.d.ts +16 -0
- package/dist/stamp/chunk.d.ts.map +1 -0
- package/dist/stamp/chunk.js +46 -0
- package/dist/stamp/chunk.js.map +1 -0
- package/dist/stamp/config-digest.d.ts +11 -0
- package/dist/stamp/config-digest.d.ts.map +1 -0
- package/dist/stamp/config-digest.js +43 -0
- package/dist/stamp/config-digest.js.map +1 -0
- package/dist/stamp/digest.d.ts +8 -0
- package/dist/stamp/digest.d.ts.map +1 -0
- package/dist/stamp/digest.js +20 -0
- package/dist/stamp/digest.js.map +1 -0
- package/dist/stamp/index.d.ts +20 -0
- package/dist/stamp/index.d.ts.map +1 -0
- package/dist/stamp/index.js +40 -0
- package/dist/stamp/index.js.map +1 -0
- package/dist/stamp/read.d.ts +7 -0
- package/dist/stamp/read.d.ts.map +1 -0
- package/dist/stamp/read.js +62 -0
- package/dist/stamp/read.js.map +1 -0
- package/dist/stamp.d.ts +29 -0
- package/dist/stamp.d.ts.map +1 -0
- package/dist/stamp.js +198 -0
- package/dist/stamp.js.map +1 -0
- package/dist/templates/banner/badge.d.ts +7 -0
- package/dist/templates/banner/badge.d.ts.map +1 -0
- package/dist/templates/banner/badge.js +24 -0
- package/dist/templates/banner/badge.js.map +1 -0
- package/dist/templates/banner/index.d.ts +9 -0
- package/dist/templates/banner/index.d.ts.map +1 -0
- package/dist/templates/banner/index.js +66 -0
- package/dist/templates/banner/index.js.map +1 -0
- package/dist/templates/banner/lines.d.ts +27 -0
- package/dist/templates/banner/lines.d.ts.map +1 -0
- package/dist/templates/banner/lines.js +46 -0
- package/dist/templates/banner/lines.js.map +1 -0
- package/dist/templates/card/index.d.ts +7 -0
- package/dist/templates/card/index.d.ts.map +1 -0
- package/dist/templates/card/index.js +43 -0
- package/dist/templates/card/index.js.map +1 -0
- package/dist/templates/card/lines.d.ts +17 -0
- package/dist/templates/card/lines.d.ts.map +1 -0
- package/dist/templates/card/lines.js +32 -0
- package/dist/templates/card/lines.js.map +1 -0
- package/dist/templates/code/chrome.d.ts +9 -0
- package/dist/templates/code/chrome.d.ts.map +1 -0
- package/dist/templates/code/chrome.js +32 -0
- package/dist/templates/code/chrome.js.map +1 -0
- package/dist/templates/code/clip.d.ts +18 -0
- package/dist/templates/code/clip.d.ts.map +1 -0
- package/dist/templates/code/clip.js +44 -0
- package/dist/templates/code/clip.js.map +1 -0
- package/dist/templates/code/ellipsis.d.ts +3 -0
- package/dist/templates/code/ellipsis.d.ts.map +1 -0
- package/dist/templates/code/ellipsis.js +3 -0
- package/dist/templates/code/ellipsis.js.map +1 -0
- package/dist/templates/code/fit.d.ts +27 -0
- package/dist/templates/code/fit.d.ts.map +1 -0
- package/dist/templates/code/fit.js +59 -0
- package/dist/templates/code/fit.js.map +1 -0
- package/dist/templates/code/index.d.ts +12 -0
- package/dist/templates/code/index.d.ts.map +1 -0
- package/dist/templates/code/index.js +64 -0
- package/dist/templates/code/index.js.map +1 -0
- package/dist/templates/code/layout.d.ts +21 -0
- package/dist/templates/code/layout.d.ts.map +1 -0
- package/dist/templates/code/layout.js +21 -0
- package/dist/templates/code/layout.js.map +1 -0
- package/dist/templates/code/panel.d.ts +17 -0
- package/dist/templates/code/panel.d.ts.map +1 -0
- package/dist/templates/code/panel.js +20 -0
- package/dist/templates/code/panel.js.map +1 -0
- package/dist/templates/code/plate.d.ts +15 -0
- package/dist/templates/code/plate.d.ts.map +1 -0
- package/dist/templates/code/plate.js +32 -0
- package/dist/templates/code/plate.js.map +1 -0
- package/dist/templates/code/spans.d.ts +19 -0
- package/dist/templates/code/spans.d.ts.map +1 -0
- package/dist/templates/code/spans.js +36 -0
- package/dist/templates/code/spans.js.map +1 -0
- package/dist/templates/code/warn.d.ts +11 -0
- package/dist/templates/code/warn.d.ts.map +1 -0
- package/dist/templates/code/warn.js +24 -0
- package/dist/templates/code/warn.js.map +1 -0
- package/dist/templates/footer.d.ts +21 -0
- package/dist/templates/footer.d.ts.map +1 -0
- package/dist/templates/footer.js +25 -0
- package/dist/templates/footer.js.map +1 -0
- package/dist/templates/index.d.ts +3 -3
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +6 -6
- package/dist/templates/index.js.map +1 -1
- package/dist/text/element.d.ts +18 -0
- package/dist/text/element.d.ts.map +1 -0
- package/dist/text/element.js +19 -0
- package/dist/text/element.js.map +1 -0
- package/dist/text/escape.d.ts +5 -0
- package/dist/text/escape.d.ts.map +1 -0
- package/dist/text/escape.js +12 -0
- package/dist/text/escape.js.map +1 -0
- package/dist/text/index.d.ts +7 -0
- package/dist/text/index.d.ts.map +1 -0
- package/dist/text/index.js +5 -0
- package/dist/text/index.js.map +1 -0
- package/dist/text/stack.d.ts +24 -0
- package/dist/text/stack.d.ts.map +1 -0
- package/dist/text/stack.js +18 -0
- package/dist/text/stack.js.map +1 -0
- package/dist/text/wrap.d.ts +12 -0
- package/dist/text/wrap.d.ts.map +1 -0
- package/dist/text/wrap.js +33 -0
- package/dist/text/wrap.js.map +1 -0
- package/dist/types.d.ts +326 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/validate/check.d.ts +13 -0
- package/dist/validate/check.d.ts.map +1 -0
- package/dist/validate/check.js +34 -0
- package/dist/validate/check.js.map +1 -0
- package/dist/validate/index.d.ts +15 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/dist/validate/index.js +41 -0
- package/dist/validate/index.js.map +1 -0
- package/dist/validate/keys.d.ts +58 -0
- package/dist/validate/keys.d.ts.map +1 -0
- package/dist/validate/keys.js +166 -0
- package/dist/validate/keys.js.map +1 -0
- package/dist/validate/overrides.d.ts +5 -0
- package/dist/validate/overrides.d.ts.map +1 -0
- package/dist/validate/overrides.js +43 -0
- package/dist/validate/overrides.js.map +1 -0
- package/dist/validate/placement.d.ts +10 -0
- package/dist/validate/placement.d.ts.map +1 -0
- package/dist/validate/placement.js +38 -0
- package/dist/validate/placement.js.map +1 -0
- package/dist/validate/sizes.d.ts +9 -0
- package/dist/validate/sizes.d.ts.map +1 -0
- package/dist/validate/sizes.js +27 -0
- package/dist/validate/sizes.js.map +1 -0
- package/dist/validate/suggest.d.ts +10 -0
- package/dist/validate/suggest.d.ts.map +1 -0
- package/dist/validate/suggest.js +55 -0
- package/dist/validate/suggest.js.map +1 -0
- package/dist/validate/values.d.ts +21 -0
- package/dist/validate/values.d.ts.map +1 -0
- package/dist/validate/values.js +57 -0
- package/dist/validate/values.js.map +1 -0
- package/dist/validate.d.ts +15 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +300 -0
- package/dist/validate.js.map +1 -0
- package/package.json +13 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HighlightedCode, HighlightOptions } from "./types.js";
|
|
2
|
+
export { dedent, expandTabs } from "./normalise.js";
|
|
3
|
+
export { resolveLanguage, resolveTheme } from "./language.js";
|
|
4
|
+
export type { CodeToken, HighlightedCode, HighlightOptions } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Tokenise a snippet with Shiki and flatten it onto a character grid.
|
|
7
|
+
*
|
|
8
|
+
* The snippet is first normalised: surrounding blank lines trimmed, tabs
|
|
9
|
+
* expanded, and common leading indentation removed.
|
|
10
|
+
*/
|
|
11
|
+
export declare function highlightCode(code: string, options: HighlightOptions): Promise<HighlightedCode>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE/E;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAoB1B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { codeToTokens } from "shiki";
|
|
2
|
+
import { gridLine } from "./grid.js";
|
|
3
|
+
import { resolveLanguage, resolveTheme } from "./language.js";
|
|
4
|
+
import { normaliseSnippet } from "./normalise.js";
|
|
5
|
+
export { dedent, expandTabs } from "./normalise.js";
|
|
6
|
+
export { resolveLanguage, resolveTheme } from "./language.js";
|
|
7
|
+
/**
|
|
8
|
+
* Tokenise a snippet with Shiki and flatten it onto a character grid.
|
|
9
|
+
*
|
|
10
|
+
* The snippet is first normalised: surrounding blank lines trimmed, tabs
|
|
11
|
+
* expanded, and common leading indentation removed.
|
|
12
|
+
*/
|
|
13
|
+
export async function highlightCode(code, options) {
|
|
14
|
+
const result = await codeToTokens(normaliseSnippet(code, options.tabSize), {
|
|
15
|
+
lang: resolveLanguage(options.language),
|
|
16
|
+
theme: resolveTheme(options.theme),
|
|
17
|
+
});
|
|
18
|
+
let longestLine = 0;
|
|
19
|
+
const lines = result.tokens.map((tokens) => {
|
|
20
|
+
const { line, width } = gridLine(tokens);
|
|
21
|
+
longestLine = Math.max(longestLine, width);
|
|
22
|
+
return line;
|
|
23
|
+
});
|
|
24
|
+
return {
|
|
25
|
+
lines,
|
|
26
|
+
foreground: result.fg ?? "#ffffff",
|
|
27
|
+
background: result.bg ?? "#000000",
|
|
28
|
+
longestLine,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/highlight/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAGlD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG9D;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAAY,EACZ,OAAyB;IAEzB,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE;QACzE,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC;QACvC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;KACnC,CAAC,CAAC;IAEH,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;QACzC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,UAAU,EAAE,MAAM,CAAC,EAAE,IAAI,SAAS;QAClC,WAAW;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BundledLanguage, BundledTheme, SpecialLanguage } from "shiki";
|
|
2
|
+
/**
|
|
3
|
+
* Map a frontmatter language name onto one Shiki understands, falling back to
|
|
4
|
+
* plain text so an unrecognised language still produces a readable image
|
|
5
|
+
* rather than throwing mid-build.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveLanguage(language: string): BundledLanguage | SpecialLanguage;
|
|
8
|
+
/**
|
|
9
|
+
* Validate a configured theme name. Unlike languages — which come from post
|
|
10
|
+
* frontmatter and fall back quietly — a bad theme is a config mistake worth
|
|
11
|
+
* failing on.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveTheme(theme: string): BundledTheme;
|
|
14
|
+
//# sourceMappingURL=language.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAsB5E;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GACf,eAAe,GAAG,eAAe,CAOnC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAQxD"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { bundledLanguages, bundledThemes } from "shiki";
|
|
2
|
+
/**
|
|
3
|
+
* Language names that differ between Pygments (which the original Python
|
|
4
|
+
* script used) and Shiki. Everything else is passed through — Shiki already
|
|
5
|
+
* understands `bash`, `python`, `typescript`, `yaml`, `toml`, `sql`, `json`,
|
|
6
|
+
* `js` and `text`.
|
|
7
|
+
*/
|
|
8
|
+
const languageAliases = new Map([
|
|
9
|
+
["html+handlebars", "handlebars"],
|
|
10
|
+
["html+django", "jinja-html"],
|
|
11
|
+
["html+jinja", "jinja-html"],
|
|
12
|
+
["html+php", "php"],
|
|
13
|
+
["console", "shellsession"],
|
|
14
|
+
["shell-session", "shellsession"],
|
|
15
|
+
["text", "plaintext"],
|
|
16
|
+
["plain", "plaintext"],
|
|
17
|
+
]);
|
|
18
|
+
const plainText = "plaintext";
|
|
19
|
+
/**
|
|
20
|
+
* Map a frontmatter language name onto one Shiki understands, falling back to
|
|
21
|
+
* plain text so an unrecognised language still produces a readable image
|
|
22
|
+
* rather than throwing mid-build.
|
|
23
|
+
*/
|
|
24
|
+
export function resolveLanguage(language) {
|
|
25
|
+
const normalised = language.trim().toLowerCase();
|
|
26
|
+
const aliased = languageAliases.get(normalised) ?? normalised;
|
|
27
|
+
return Object.hasOwn(bundledLanguages, aliased)
|
|
28
|
+
? aliased
|
|
29
|
+
: plainText;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate a configured theme name. Unlike languages — which come from post
|
|
33
|
+
* frontmatter and fall back quietly — a bad theme is a config mistake worth
|
|
34
|
+
* failing on.
|
|
35
|
+
*/
|
|
36
|
+
export function resolveTheme(theme) {
|
|
37
|
+
if (!Object.hasOwn(bundledThemes, theme)) {
|
|
38
|
+
throw new Error(`Unknown code theme "${theme}". See https://shiki.style/themes for the available names.`);
|
|
39
|
+
}
|
|
40
|
+
return theme;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=language.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language.js","sourceRoot":"","sources":["../../src/highlight/language.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAExD;;;;;GAKG;AACH,MAAM,eAAe,GAAgC,IAAI,GAAG,CAAC;IAC3D,CAAC,iBAAiB,EAAE,YAAY,CAAC;IACjC,CAAC,aAAa,EAAE,YAAY,CAAC;IAC7B,CAAC,YAAY,EAAE,YAAY,CAAC;IAC5B,CAAC,UAAU,EAAE,KAAK,CAAC;IACnB,CAAC,SAAS,EAAE,cAAc,CAAC;IAC3B,CAAC,eAAe,EAAE,cAAc,CAAC;IACjC,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,OAAO,EAAE,WAAW,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,SAAS,GAAoB,WAAW,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAgB;IAEhB,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,OAAO,GAAG,eAAe,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC;IAE9D,OAAO,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,OAAO,CAAC;QAC7C,CAAC,CAAE,OAA2B;QAC9B,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,uBAAuB,KAAK,4DAA4D,CACzF,CAAC;IACJ,CAAC;IAED,OAAO,KAAqB,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expand tabs to spaces so every character occupies one monospace cell.
|
|
3
|
+
*/
|
|
4
|
+
export declare function expandTabs(text: string, tabSize: number): string;
|
|
5
|
+
/**
|
|
6
|
+
* Strip the indentation common to every non-blank line. A snippet lifted out
|
|
7
|
+
* of a nested block would otherwise spend its width — the scarce dimension on
|
|
8
|
+
* the landscape sizes — on indentation that carries no meaning once the
|
|
9
|
+
* surrounding code is gone.
|
|
10
|
+
*/
|
|
11
|
+
export declare function dedent(text: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Normalise a snippet for layout: line endings unified, surrounding blank
|
|
14
|
+
* lines trimmed, tabs expanded and common leading indentation removed.
|
|
15
|
+
*/
|
|
16
|
+
export declare function normaliseSnippet(code: string, tabSize: number): string;
|
|
17
|
+
//# sourceMappingURL=normalise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalise.d.ts","sourceRoot":"","sources":["../../src/highlight/normalise.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGhE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAiB3C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAMtE"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expand tabs to spaces so every character occupies one monospace cell.
|
|
3
|
+
*/
|
|
4
|
+
export function expandTabs(text, tabSize) {
|
|
5
|
+
const spaces = " ".repeat(Math.max(1, Math.floor(tabSize)));
|
|
6
|
+
return text.replaceAll("\t", () => spaces);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Strip the indentation common to every non-blank line. A snippet lifted out
|
|
10
|
+
* of a nested block would otherwise spend its width — the scarce dimension on
|
|
11
|
+
* the landscape sizes — on indentation that carries no meaning once the
|
|
12
|
+
* surrounding code is gone.
|
|
13
|
+
*/
|
|
14
|
+
export function dedent(text) {
|
|
15
|
+
const lines = text.split("\n");
|
|
16
|
+
let common = Infinity;
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
if (line.trim() === "") {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
common = Math.min(common, line.length - line.trimStart().length);
|
|
22
|
+
}
|
|
23
|
+
if (common === 0 || !Number.isFinite(common)) {
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
return lines.map((line) => line.slice(common)).join("\n");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Normalise a snippet for layout: line endings unified, surrounding blank
|
|
30
|
+
* lines trimmed, tabs expanded and common leading indentation removed.
|
|
31
|
+
*/
|
|
32
|
+
export function normaliseSnippet(code, tabSize) {
|
|
33
|
+
return dedent(expandTabs(code.replaceAll("\r\n", "\n"), tabSize)
|
|
34
|
+
.replace(/\n+$/, "")
|
|
35
|
+
.replace(/^\n+/, ""));
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=normalise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalise.js","sourceRoot":"","sources":["../../src/highlight/normalise.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAe;IACtD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC5D,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,MAAM,GAAG,QAAQ,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACvB,SAAS;QACX,CAAC;QAED,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,OAAe;IAC5D,OAAO,MAAM,CACX,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC;SAC/C,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;SACnB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One highlighted run of text on a line, positioned by character column so the
|
|
3
|
+
* renderer can lay it out on a fixed monospace grid.
|
|
4
|
+
*/
|
|
5
|
+
export interface CodeToken {
|
|
6
|
+
readonly text: string;
|
|
7
|
+
/** Zero-based character column where this run starts. */
|
|
8
|
+
readonly column: number;
|
|
9
|
+
/** Token colour as `#rrggbb`, or `undefined` to use the theme foreground. */
|
|
10
|
+
readonly color: string | undefined;
|
|
11
|
+
/** Opacity implied by an `#rrggbbaa` token colour, if any. */
|
|
12
|
+
readonly opacity: number | undefined;
|
|
13
|
+
readonly bold: boolean;
|
|
14
|
+
readonly italic: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A tokenised snippet ready for layout: the grid of lines, the theme's own
|
|
18
|
+
* colours, and its longest line in characters.
|
|
19
|
+
*/
|
|
20
|
+
export interface HighlightedCode {
|
|
21
|
+
readonly lines: readonly (readonly CodeToken[])[];
|
|
22
|
+
/** Theme foreground, used for tokens the grammar gives no colour. */
|
|
23
|
+
readonly foreground: string;
|
|
24
|
+
/** Theme background, used to fill the code panel. */
|
|
25
|
+
readonly background: string;
|
|
26
|
+
/** Length in characters of the longest line, for width fitting. */
|
|
27
|
+
readonly longestLine: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Options for `highlightCode`.
|
|
31
|
+
*/
|
|
32
|
+
export interface HighlightOptions {
|
|
33
|
+
/** Language name; unknown names fall back to plain text. */
|
|
34
|
+
readonly language: string;
|
|
35
|
+
/** Shiki theme name. */
|
|
36
|
+
readonly theme: string;
|
|
37
|
+
/** Spaces a tab expands to. */
|
|
38
|
+
readonly tabSize: number;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/highlight/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC;IAClD,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,qDAAqD;IACrD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/highlight/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, Dimensions, GradientStop, MetaImageProps, OutputSize, RenderedMetaImage, ResolvedConfig, Template, TemplateContext, WarningHandler, } from "./types.js";
|
|
2
|
-
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
|
|
1
|
+
export type { Background, Badge, BrandColors, CodeStyle, ColophonConfig, ColophonConfigFactory, ColophonConfigInput, ContentFile, ContentOptions, Dimensions, ExtraImage, FontSource, GradientStop, Manifest, ManifestImage, ManifestPage, MetaImageProps, MetaTag, MetaTagOptions, OutputSize, Placement, PropsFromFrontmatter, RenderedMetaImage, SlugStrategy, SizeOverrides, ResolvedConfig, Template, TemplateContext, WarningHandler, } from "./types.js";
|
|
2
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config/index.js";
|
|
3
|
+
export { resolveConfigForSize } from "./config/size.js";
|
|
3
4
|
export { backgroundSvg } from "./background.js";
|
|
4
|
-
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
|
|
5
|
+
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render/index.js";
|
|
5
6
|
export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
|
|
6
|
-
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
|
|
7
|
-
export type { CodeToken, HighlightedCode, HighlightOptions, } from "./highlight.js";
|
|
8
|
-
export { defaultOutputPath, generate } from "./generate.js";
|
|
9
|
-
export type { GeneratedImage, GenerateOptions } from "./generate.js";
|
|
10
|
-
export {
|
|
7
|
+
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight/index.js";
|
|
8
|
+
export type { CodeToken, HighlightedCode, HighlightOptions, } from "./highlight/index.js";
|
|
9
|
+
export { defaultOutputPath, generate } from "./generate/index.js";
|
|
10
|
+
export type { GeneratedImage, GenerateOptions } from "./generate/index.js";
|
|
11
|
+
export { createStamper, readPngStamp, stampPng } from "./stamp/index.js";
|
|
12
|
+
export type { Stamper } from "./stamp/index.js";
|
|
13
|
+
export { escapeXml, wrapText } from "./text/index.js";
|
|
11
14
|
export { extractProps, slugFromPath, walkContent } from "./content/index.js";
|
|
12
|
-
export type {
|
|
15
|
+
export type { WalkOptions } from "./content/index.js";
|
|
16
|
+
export { metaTags, metaTagsHtml } from "./meta/index.js";
|
|
17
|
+
export { createPlacer } from "./placement/index.js";
|
|
18
|
+
export type { PlacedImage, Placer } from "./placement/index.js";
|
|
13
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,UAAU,EACV,KAAK,EACL,WAAW,EACX,SAAS,EACT,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,cAAc,EACd,OAAO,EACP,cAAc,EACd,UAAU,EACV,SAAS,EACT,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,SAAS,EACT,eAAe,EACf,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAClE,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config.js";
|
|
1
|
+
export { DEFAULT_CODE_FONT_FAMILY, DEFAULT_CODE_STYLE, DEFAULT_COLORS, DEFAULT_FONT_FAMILY, DEFAULT_SIZES, defineConfig, resolveConfig, SIZE_PRESETS, } from "./config/index.js";
|
|
2
|
+
export { resolveConfigForSize } from "./config/size.js";
|
|
2
3
|
export { backgroundSvg } from "./background.js";
|
|
3
|
-
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render.js";
|
|
4
|
+
export { buildSvg, renderMetaImages, renderSvgToPng } from "./render/index.js";
|
|
4
5
|
export { bannerTemplate, builtinTemplates, cardTemplate, codeTemplate, } from "./templates/index.js";
|
|
5
|
-
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight.js";
|
|
6
|
-
export { defaultOutputPath, generate } from "./generate.js";
|
|
7
|
-
export {
|
|
6
|
+
export { dedent, expandTabs, highlightCode, resolveLanguage, } from "./highlight/index.js";
|
|
7
|
+
export { defaultOutputPath, generate } from "./generate/index.js";
|
|
8
|
+
export { createStamper, readPngStamp, stampPng } from "./stamp/index.js";
|
|
9
|
+
export { escapeXml, wrapText } from "./text/index.js";
|
|
8
10
|
export { extractProps, slugFromPath, walkContent } from "./content/index.js";
|
|
11
|
+
export { metaTags, metaTagsHtml } from "./meta/index.js";
|
|
12
|
+
export { createPlacer } from "./placement/index.js";
|
|
9
13
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgCA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,MAAM,EACN,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAO9B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RenderJob } from "../generate/job.js";
|
|
2
|
+
import type { Manifest } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Build the manifest for a planned build.
|
|
5
|
+
*
|
|
6
|
+
* It is built from the jobs rather than from what was written, so a rebuild
|
|
7
|
+
* that skips every image still describes the whole site — the manifest says
|
|
8
|
+
* what exists, not what happened this time.
|
|
9
|
+
*
|
|
10
|
+
* Pages are sorted by slug, and each page's images by size name, so a manifest
|
|
11
|
+
* committed to a repository changes only when the build does.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildManifest(jobs: readonly RenderJob[]): Manifest;
|
|
14
|
+
//# sourceMappingURL=build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/manifest/build.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAgC5C;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,SAAS,EAAE,GAAG,QAAQ,CASlE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { byName } from "./order.js";
|
|
2
|
+
import { addToPage, startPage, toPage } from "./page.js";
|
|
3
|
+
/**
|
|
4
|
+
* Collect the jobs of each page, keyed by the slug a site addresses it by.
|
|
5
|
+
*
|
|
6
|
+
* Extras are dropped: the manifest is a map of pages, and an extra image has
|
|
7
|
+
* no page behind it. A project that named the path of one already knows where
|
|
8
|
+
* it is, which is the question this file answers for everything else.
|
|
9
|
+
*/
|
|
10
|
+
function drafts(jobs) {
|
|
11
|
+
const pages = new Map();
|
|
12
|
+
for (const job of jobs) {
|
|
13
|
+
if (job.slug === undefined) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const page = pages.get(job.slug);
|
|
17
|
+
if (page === undefined) {
|
|
18
|
+
pages.set(job.slug, startPage(job));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
addToPage(page, job);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return pages;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the manifest for a planned build.
|
|
28
|
+
*
|
|
29
|
+
* It is built from the jobs rather than from what was written, so a rebuild
|
|
30
|
+
* that skips every image still describes the whole site — the manifest says
|
|
31
|
+
* what exists, not what happened this time.
|
|
32
|
+
*
|
|
33
|
+
* Pages are sorted by slug, and each page's images by size name, so a manifest
|
|
34
|
+
* committed to a repository changes only when the build does.
|
|
35
|
+
*/
|
|
36
|
+
export function buildManifest(jobs) {
|
|
37
|
+
const pages = [...drafts(jobs)].toSorted(([a], [b]) => byName(a, b));
|
|
38
|
+
return {
|
|
39
|
+
version: 1,
|
|
40
|
+
pages: Object.fromEntries(pages.map(([slug, page]) => [slug, toPage(slug, page)])),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/manifest/build.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEzD;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,IAA0B;IACxC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC3B,SAAS;QACX,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAEjC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,IAA0B;IACtD,MAAM,KAAK,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAErE,OAAO;QACL,OAAO,EAAE,CAAC;QACV,KAAK,EAAE,MAAM,CAAC,WAAW,CACvB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CACxD;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Manifest } from "../types.js";
|
|
2
|
+
import type { RenderJob } from "../generate/job.js";
|
|
3
|
+
export { buildManifest } from "./build.js";
|
|
4
|
+
/**
|
|
5
|
+
* A manifest and where it goes, or nothing when the config asked for none.
|
|
6
|
+
*/
|
|
7
|
+
export interface PlannedManifest {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly data: Manifest;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Work out the manifest a build will write, if any.
|
|
13
|
+
*
|
|
14
|
+
* Built while planning rather than from the results, so that a site with two
|
|
15
|
+
* pages sharing a slug hears about it before rendering the tree rather than
|
|
16
|
+
* after — the same reason the output paths are checked up front.
|
|
17
|
+
*/
|
|
18
|
+
export declare function planManifest(manifestPath: string | undefined, jobs: readonly RenderJob[]): PlannedManifest | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Write the manifest, creating whatever directories its path needs.
|
|
21
|
+
*
|
|
22
|
+
* Indented, with a trailing newline: it is written into a site's data
|
|
23
|
+
* directory, where it is read by people as well as by templates, and a diff of
|
|
24
|
+
* one long line says nothing about what changed.
|
|
25
|
+
*/
|
|
26
|
+
export declare function writeManifest(manifest: PlannedManifest | undefined): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/manifest/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,IAAI,EAAE,SAAS,SAAS,EAAE,GACzB,eAAe,GAAG,SAAS,CAI7B;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,QAAQ,EAAE,eAAe,GAAG,SAAS,GACpC,OAAO,CAAC,IAAI,CAAC,CAUf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { buildManifest } from "./build.js";
|
|
4
|
+
export { buildManifest } from "./build.js";
|
|
5
|
+
/**
|
|
6
|
+
* Work out the manifest a build will write, if any.
|
|
7
|
+
*
|
|
8
|
+
* Built while planning rather than from the results, so that a site with two
|
|
9
|
+
* pages sharing a slug hears about it before rendering the tree rather than
|
|
10
|
+
* after — the same reason the output paths are checked up front.
|
|
11
|
+
*/
|
|
12
|
+
export function planManifest(manifestPath, jobs) {
|
|
13
|
+
return manifestPath === undefined
|
|
14
|
+
? undefined
|
|
15
|
+
: { path: manifestPath, data: buildManifest(jobs) };
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Write the manifest, creating whatever directories its path needs.
|
|
19
|
+
*
|
|
20
|
+
* Indented, with a trailing newline: it is written into a site's data
|
|
21
|
+
* directory, where it is read by people as well as by templates, and a diff of
|
|
22
|
+
* one long line says nothing about what changed.
|
|
23
|
+
*/
|
|
24
|
+
export async function writeManifest(manifest) {
|
|
25
|
+
if (manifest === undefined) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await mkdir(path.dirname(manifest.path), { recursive: true });
|
|
29
|
+
await writeFile(manifest.path, `${JSON.stringify(manifest.data, undefined, 2)}\n`);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/manifest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAU3C;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,YAAgC,EAChC,IAA0B;IAE1B,OAAO,YAAY,KAAK,SAAS;QAC/B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,QAAqC;IAErC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9D,MAAM,SAAS,CACb,QAAQ,CAAC,IAAI,EACb,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,IAAI,CACnD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order two names by code unit, rather than by whatever the machine's locale
|
|
3
|
+
* would say.
|
|
4
|
+
*
|
|
5
|
+
* The manifest is written into a site's repository and committed, so the order
|
|
6
|
+
* has to be the same on a laptop and on CI. `localeCompare` reads the default
|
|
7
|
+
* locale, and locales disagree about case and accented letters — a slug of
|
|
8
|
+
* `Über` or `MyPost` could sort one way in development and another in the
|
|
9
|
+
* build, leaving a diff that says nothing happened.
|
|
10
|
+
*/
|
|
11
|
+
export declare function byName(a: string, b: string): number;
|
|
12
|
+
//# sourceMappingURL=order.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.d.ts","sourceRoot":"","sources":["../../src/manifest/order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAMnD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order two names by code unit, rather than by whatever the machine's locale
|
|
3
|
+
* would say.
|
|
4
|
+
*
|
|
5
|
+
* The manifest is written into a site's repository and committed, so the order
|
|
6
|
+
* has to be the same on a laptop and on CI. `localeCompare` reads the default
|
|
7
|
+
* locale, and locales disagree about case and accented letters — a slug of
|
|
8
|
+
* `Über` or `MyPost` could sort one way in development and another in the
|
|
9
|
+
* build, leaving a diff that says nothing happened.
|
|
10
|
+
*/
|
|
11
|
+
export function byName(a, b) {
|
|
12
|
+
if (a === b) {
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
return a < b ? -1 : 1;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order.js","sourceRoot":"","sources":["../../src/manifest/order.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,MAAM,CAAC,CAAS,EAAE,CAAS;IACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,CAAC;IACX,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { RenderJob } from "../generate/job.js";
|
|
2
|
+
import type { ManifestPage } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* One page as it is collected: the jobs that draw it, and the most landscape
|
|
5
|
+
* of them so far.
|
|
6
|
+
*
|
|
7
|
+
* A page is created from its first job rather than from an empty list, so
|
|
8
|
+
* there is never a page without images to explain away — `widest` has to name
|
|
9
|
+
* one of them.
|
|
10
|
+
*/
|
|
11
|
+
export interface PageDraft {
|
|
12
|
+
readonly jobs: RenderJob[];
|
|
13
|
+
widest: RenderJob;
|
|
14
|
+
}
|
|
15
|
+
/** Start a page off from the first job that draws it. */
|
|
16
|
+
export declare function startPage(job: RenderJob): PageDraft;
|
|
17
|
+
/**
|
|
18
|
+
* Add another size of the same page. Ties keep the size configured first,
|
|
19
|
+
* since `>` leaves the incumbent in place.
|
|
20
|
+
*/
|
|
21
|
+
export declare function addToPage(page: PageDraft, job: RenderJob): void;
|
|
22
|
+
/** Finish a page: its images by size name, sorted, plus what they add up to. */
|
|
23
|
+
export declare function toPage(slug: string, page: PageDraft): ManifestPage;
|
|
24
|
+
//# sourceMappingURL=page.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/manifest/page.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC;IAC3B,MAAM,EAAE,SAAS,CAAC;CACnB;AAOD,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,CAEnD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,GAAG,IAAI,CAM/D;AA8BD,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,YAAY,CAclE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { byName } from "./order.js";
|
|
2
|
+
/** How landscape an image is. The most landscape one is what `widest` names. */
|
|
3
|
+
function ratio(job) {
|
|
4
|
+
return job.size.width / job.size.height;
|
|
5
|
+
}
|
|
6
|
+
/** Start a page off from the first job that draws it. */
|
|
7
|
+
export function startPage(job) {
|
|
8
|
+
return { jobs: [job], widest: job };
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Add another size of the same page. Ties keep the size configured first,
|
|
12
|
+
* since `>` leaves the incumbent in place.
|
|
13
|
+
*/
|
|
14
|
+
export function addToPage(page, job) {
|
|
15
|
+
page.jobs.push(job);
|
|
16
|
+
if (ratio(job) > ratio(page.widest)) {
|
|
17
|
+
page.widest = job;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reject two pages sharing a slug.
|
|
22
|
+
*
|
|
23
|
+
* The manifest is keyed by slug, so a site looking a page up would find
|
|
24
|
+
* whichever was written last — an image quietly belonging to the wrong post,
|
|
25
|
+
* which is worse than no manifest at all. Their images may well be distinct on
|
|
26
|
+
* disk, so nothing else in the build has any reason to complain.
|
|
27
|
+
*/
|
|
28
|
+
function assertOnePage(slug, page) {
|
|
29
|
+
const paths = [...new Set(page.jobs.map((job) => job.contentPath))];
|
|
30
|
+
if (paths.length > 1) {
|
|
31
|
+
throw new Error(`Two pages share the slug "${slug}": ${paths.join(" and ")}. The` +
|
|
32
|
+
` manifest is keyed by slug, so they cannot both be found. Give one a` +
|
|
33
|
+
` slug of its own, or use slugStrategy: "route".`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function toImage(job) {
|
|
37
|
+
return {
|
|
38
|
+
...(job.url !== undefined && { url: job.url }),
|
|
39
|
+
width: job.size.width,
|
|
40
|
+
height: job.size.height,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Finish a page: its images by size name, sorted, plus what they add up to. */
|
|
44
|
+
export function toPage(slug, page) {
|
|
45
|
+
assertOnePage(slug, page);
|
|
46
|
+
const title = page.widest.props.title;
|
|
47
|
+
return {
|
|
48
|
+
images: Object.fromEntries(page.jobs
|
|
49
|
+
.map((job) => [job.size.name, toImage(job)])
|
|
50
|
+
.toSorted(([a], [b]) => byName(a, b))),
|
|
51
|
+
widest: page.widest.size.name,
|
|
52
|
+
...(typeof title === "string" && title !== "" && { alt: title }),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page.js","sourceRoot":"","sources":["../../src/manifest/page.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAepC,gFAAgF;AAChF,SAAS,KAAK,CAAC,GAAc;IAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;AAC1C,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,SAAS,CAAC,GAAc;IACtC,OAAO,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,IAAe,EAAE,GAAc;IACvD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEpB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACpB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,IAAY,EAAE,IAAe;IAClD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAEpE,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,6BAA6B,IAAI,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO;YAC/D,sEAAsE;YACtE,iDAAiD,CACpD,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,GAAc;IAC7B,OAAO;QACL,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,SAAS,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;QAC9C,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK;QACrB,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,MAAM;KACxB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,IAAe;IAClD,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAE1B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;IAEtC,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,WAAW,CACxB,IAAI,CAAC,IAAI;aACN,GAAG,CAAC,CAAC,GAAG,EAA2B,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;aACpE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CACxC;QACD,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI;QAC7B,GAAG,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;KACjE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Manifest, MetaTagOptions } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The social meta tags for one page, rendered as HTML.
|
|
4
|
+
*
|
|
5
|
+
* The same tags as {@link metaTags}, for a template that writes strings rather
|
|
6
|
+
* than a component that spreads attributes. Content is escaped: alt text comes
|
|
7
|
+
* from a post's title, and a title containing an apostrophe or an ampersand is
|
|
8
|
+
* ordinary rather than exotic.
|
|
9
|
+
*
|
|
10
|
+
* Newline-separated and with no trailing newline, so it drops into a `<head>`
|
|
11
|
+
* at whatever indentation the template is already using.
|
|
12
|
+
*/
|
|
13
|
+
export declare function metaTagsHtml(manifest: Manifest, slug: string, options?: MetaTagOptions): string;
|
|
14
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/meta/html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAW,cAAc,EAAE,MAAM,aAAa,CAAC;AAWrE;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM,CAIR"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { escapeXml } from "../text/escape.js";
|
|
2
|
+
import { metaTags } from "./tags.js";
|
|
3
|
+
/** One tag as HTML, with whichever naming attribute it carries. */
|
|
4
|
+
function toHtml(tag) {
|
|
5
|
+
const [attribute, name] = "property" in tag ? ["property", tag.property] : ["name", tag.name];
|
|
6
|
+
return `<meta ${attribute}="${escapeXml(name)}" content="${escapeXml(tag.content)}">`;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The social meta tags for one page, rendered as HTML.
|
|
10
|
+
*
|
|
11
|
+
* The same tags as {@link metaTags}, for a template that writes strings rather
|
|
12
|
+
* than a component that spreads attributes. Content is escaped: alt text comes
|
|
13
|
+
* from a post's title, and a title containing an apostrophe or an ampersand is
|
|
14
|
+
* ordinary rather than exotic.
|
|
15
|
+
*
|
|
16
|
+
* Newline-separated and with no trailing newline, so it drops into a `<head>`
|
|
17
|
+
* at whatever indentation the template is already using.
|
|
18
|
+
*/
|
|
19
|
+
export function metaTagsHtml(manifest, slug, options) {
|
|
20
|
+
return metaTags(manifest, slug, options)
|
|
21
|
+
.map((tag) => toHtml(tag))
|
|
22
|
+
.join("\n");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/meta/html.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,mEAAmE;AACnE,SAAS,MAAM,CAAC,GAAY;IAC1B,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,GACrB,UAAU,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAEtE,OAAO,SAAS,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC,cAAc,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;AACxF,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,YAAY,CAC1B,QAAkB,EAClB,IAAY,EACZ,OAAwB;IAExB,OAAO,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC;SACrC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|