@kensio/colophon 2.1.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 +608 -34
- 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 +33 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +94 -4
- 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 +77 -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/highlight.d.ts +10 -0
- package/dist/highlight.d.ts.map +1 -1
- package/dist/highlight.js +25 -2
- package/dist/highlight.js.map +1 -1
- 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/code.d.ts.map +1 -1
- package/dist/templates/code.js +101 -29
- package/dist/templates/code.js.map +1 -1
- 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 +345 -6
- 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 +14 -7
|
@@ -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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Social meta tags, built from the manifest a build wrote.
|
|
3
|
+
*
|
|
4
|
+
* Importable on its own as `@kensio/colophon/meta`: emitting tags reads a JSON
|
|
5
|
+
* file and needs none of the rendering machinery, and a site's templates
|
|
6
|
+
* should not load a rasteriser and a syntax highlighter to write a `<head>`.
|
|
7
|
+
*/
|
|
8
|
+
export { metaTagsHtml } from "./html.js";
|
|
9
|
+
export { metaTags } from "./tags.js";
|
|
10
|
+
export { absoluteUrl } from "./url.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/meta/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Social meta tags, built from the manifest a build wrote.
|
|
3
|
+
*
|
|
4
|
+
* Importable on its own as `@kensio/colophon/meta`: emitting tags reads a JSON
|
|
5
|
+
* file and needs none of the rendering machinery, and a site's templates
|
|
6
|
+
* should not load a rasteriser and a syntax highlighter to write a `<head>`.
|
|
7
|
+
*/
|
|
8
|
+
export { metaTagsHtml } from "./html.js";
|
|
9
|
+
export { metaTags } from "./tags.js";
|
|
10
|
+
export { absoluteUrl } from "./url.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/meta/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Manifest, MetaTag, MetaTagOptions } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The social meta tags for one page of a {@link Manifest}.
|
|
4
|
+
*
|
|
5
|
+
* Generating the image is half the job: a site still has to write the tags,
|
|
6
|
+
* and every site ends up with slightly different results — a missing width, a
|
|
7
|
+
* relative URL a crawler cannot resolve, a large card promising an image that
|
|
8
|
+
* is square.
|
|
9
|
+
*
|
|
10
|
+
* A page the manifest does not have gets no tags rather than an error. Not
|
|
11
|
+
* every page has a share image — a props mapper returning `undefined` is how a
|
|
12
|
+
* site says so — and a template asking about one should not have to know in
|
|
13
|
+
* advance.
|
|
14
|
+
*
|
|
15
|
+
* Alt text is emitted for both platforms when the page has any. Twitter reads
|
|
16
|
+
* its own `twitter:image:alt` rather than falling back to the Open Graph one,
|
|
17
|
+
* so leaving it out would mean no alt text on the platform, which is most of
|
|
18
|
+
* the reason for carrying it this far.
|
|
19
|
+
*/
|
|
20
|
+
export declare function metaTags(manifest: Manifest, slug: string, options?: MetaTagOptions): readonly MetaTag[];
|
|
21
|
+
//# sourceMappingURL=tags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.d.ts","sourceRoot":"","sources":["../../src/meta/tags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EAGR,OAAO,EACP,cAAc,EACf,MAAM,aAAa,CAAC;AA4CrB;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,cAAc,GACvB,SAAS,OAAO,EAAE,CA2BpB"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { absoluteUrl } from "./url.js";
|
|
2
|
+
/**
|
|
3
|
+
* How landscape an image has to be for a large Twitter card.
|
|
4
|
+
*
|
|
5
|
+
* `summary_large_image` is specified for 2:1 and the Open Graph landscape is
|
|
6
|
+
* 1.91:1, so both clear this; a 1:1 square and a 4:3 do not, and are shown
|
|
7
|
+
* better by `summary` than by a large card that crops them. Choosing between
|
|
8
|
+
* the two is a check every site writes for itself, usually by hardcoding the
|
|
9
|
+
* answer for whichever image it happens to have.
|
|
10
|
+
*/
|
|
11
|
+
const largeCardRatio = 1.5;
|
|
12
|
+
/** The image a page's tags describe: the most landscape one it has. */
|
|
13
|
+
function chooseImage(slug, page) {
|
|
14
|
+
const image = page.images[page.widest];
|
|
15
|
+
if (image === undefined) {
|
|
16
|
+
throw new Error(`The manifest page "${slug}" names "${page.widest}" as its widest` +
|
|
17
|
+
` image but has no image by that name.`);
|
|
18
|
+
}
|
|
19
|
+
return image;
|
|
20
|
+
}
|
|
21
|
+
/** The URL to point at, or a complaint that there is none to point at. */
|
|
22
|
+
function imageUrl(slug, image, options) {
|
|
23
|
+
if (image.url === undefined) {
|
|
24
|
+
throw new Error(`The manifest has no URL for "${slug}", so there is nothing to point a` +
|
|
25
|
+
` meta tag at. Set placement.urlBase, which is what records one.`);
|
|
26
|
+
}
|
|
27
|
+
return absoluteUrl(image.url, options?.baseUrl);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The social meta tags for one page of a {@link Manifest}.
|
|
31
|
+
*
|
|
32
|
+
* Generating the image is half the job: a site still has to write the tags,
|
|
33
|
+
* and every site ends up with slightly different results — a missing width, a
|
|
34
|
+
* relative URL a crawler cannot resolve, a large card promising an image that
|
|
35
|
+
* is square.
|
|
36
|
+
*
|
|
37
|
+
* A page the manifest does not have gets no tags rather than an error. Not
|
|
38
|
+
* every page has a share image — a props mapper returning `undefined` is how a
|
|
39
|
+
* site says so — and a template asking about one should not have to know in
|
|
40
|
+
* advance.
|
|
41
|
+
*
|
|
42
|
+
* Alt text is emitted for both platforms when the page has any. Twitter reads
|
|
43
|
+
* its own `twitter:image:alt` rather than falling back to the Open Graph one,
|
|
44
|
+
* so leaving it out would mean no alt text on the platform, which is most of
|
|
45
|
+
* the reason for carrying it this far.
|
|
46
|
+
*/
|
|
47
|
+
export function metaTags(manifest, slug, options) {
|
|
48
|
+
const page = manifest.pages[slug];
|
|
49
|
+
if (page === undefined) {
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const image = chooseImage(slug, page);
|
|
53
|
+
const url = imageUrl(slug, image, options);
|
|
54
|
+
const isLarge = image.width / image.height >= largeCardRatio;
|
|
55
|
+
return [
|
|
56
|
+
{ property: "og:image", content: url },
|
|
57
|
+
{ property: "og:image:width", content: String(image.width) },
|
|
58
|
+
{ property: "og:image:height", content: String(image.height) },
|
|
59
|
+
...(page.alt === undefined
|
|
60
|
+
? []
|
|
61
|
+
: [{ property: "og:image:alt", content: page.alt }]),
|
|
62
|
+
{
|
|
63
|
+
name: "twitter:card",
|
|
64
|
+
content: isLarge ? "summary_large_image" : "summary",
|
|
65
|
+
},
|
|
66
|
+
{ name: "twitter:image", content: url },
|
|
67
|
+
...(page.alt === undefined
|
|
68
|
+
? []
|
|
69
|
+
: [{ name: "twitter:image:alt", content: page.alt }]),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=tags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tags.js","sourceRoot":"","sources":["../../src/meta/tags.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,uEAAuE;AACvE,SAAS,WAAW,CAAC,IAAY,EAAE,IAAkB;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEvC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,sBAAsB,IAAI,YAAY,IAAI,CAAC,MAAM,iBAAiB;YAChE,uCAAuC,CAC1C,CAAC;IACJ,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0EAA0E;AAC1E,SAAS,QAAQ,CACf,IAAY,EACZ,KAAoB,EACpB,OAAmC;IAEnC,IAAI,KAAK,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,gCAAgC,IAAI,mCAAmC;YACrE,iEAAiE,CACpE,CAAC;IACJ,CAAC;IAED,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CACtB,QAAkB,EAClB,IAAY,EACZ,OAAwB;IAExB,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM,IAAI,cAAc,CAAC;IAE7D,OAAO;QACL,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE;QACtC,EAAE,QAAQ,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QAC5D,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC9D,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACtD;YACE,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,SAAS;SACrD;QACD,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE;QACvC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an image URL against the site's base.
|
|
3
|
+
*
|
|
4
|
+
* Open Graph wants an absolute URL: a crawler reads the tag out of the page
|
|
5
|
+
* and has nothing to resolve a relative one against. A manifest holds whatever
|
|
6
|
+
* the placement's `urlBase` said, which is usually site-relative, so this is
|
|
7
|
+
* where the two halves meet.
|
|
8
|
+
*
|
|
9
|
+
* A URL that names its own scheme is returned untouched — a placement pointing
|
|
10
|
+
* at a CDN has said everything there is to say. A scheme-relative one (`//cdn`)
|
|
11
|
+
* has not: it is relative to the page's scheme, which is exactly what a crawler
|
|
12
|
+
* reading the tag elsewhere does not have, so it borrows the base's.
|
|
13
|
+
*/
|
|
14
|
+
export declare function absoluteUrl(url: string, baseUrl: string | undefined): string;
|
|
15
|
+
//# sourceMappingURL=url.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/meta/url.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAa5E"}
|
package/dist/meta/url.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A URL that names its own scheme. Schemes are case-insensitive, so `HTTPS://`
|
|
3
|
+
* is as absolute as `https://` and prefixing it would produce nonsense.
|
|
4
|
+
*/
|
|
5
|
+
const schemed = /^[a-z][a-z\d+.-]*:\/\//i;
|
|
6
|
+
/** The scheme a base URL is served over, `https:` included. */
|
|
7
|
+
function schemeOf(url) {
|
|
8
|
+
return /^[a-z][a-z\d+.-]*:/i.exec(url)?.[0];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolve an image URL against the site's base.
|
|
12
|
+
*
|
|
13
|
+
* Open Graph wants an absolute URL: a crawler reads the tag out of the page
|
|
14
|
+
* and has nothing to resolve a relative one against. A manifest holds whatever
|
|
15
|
+
* the placement's `urlBase` said, which is usually site-relative, so this is
|
|
16
|
+
* where the two halves meet.
|
|
17
|
+
*
|
|
18
|
+
* A URL that names its own scheme is returned untouched — a placement pointing
|
|
19
|
+
* at a CDN has said everything there is to say. A scheme-relative one (`//cdn`)
|
|
20
|
+
* has not: it is relative to the page's scheme, which is exactly what a crawler
|
|
21
|
+
* reading the tag elsewhere does not have, so it borrows the base's.
|
|
22
|
+
*/
|
|
23
|
+
export function absoluteUrl(url, baseUrl) {
|
|
24
|
+
if (baseUrl === undefined || schemed.test(url)) {
|
|
25
|
+
return url;
|
|
26
|
+
}
|
|
27
|
+
if (url.startsWith("//")) {
|
|
28
|
+
const scheme = schemeOf(baseUrl);
|
|
29
|
+
return scheme === undefined ? url : `${scheme}${url}`;
|
|
30
|
+
}
|
|
31
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
32
|
+
return url.startsWith("/") ? `${base}${url}` : `${base}/${url}`;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/meta/url.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,GAAG,yBAAyB,CAAC;AAE1C,+DAA+D;AAC/D,SAAS,QAAQ,CAAC,GAAW;IAC3B,OAAO,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,OAA2B;IAClE,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,GAAG,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAEzC,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Placement } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reject a placement that cannot place anything.
|
|
4
|
+
*
|
|
5
|
+
* The types require all of this, but a CLI user's config module is plain
|
|
6
|
+
* JavaScript with nothing checking it, and none of these omissions fails
|
|
7
|
+
* anywhere near the config: a missing `dir` surfaces as a complaint about an
|
|
8
|
+
* argument to `path`, and the rest as something not being a function. Key
|
|
9
|
+
* validation is no help either — it is the option that is not there.
|
|
10
|
+
*
|
|
11
|
+
* This sits here rather than in `validate/`, which checks keys and the names
|
|
12
|
+
* of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
|
|
13
|
+
* be is known by whatever is about to use it.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertPlacement(placement: Placement): void;
|
|
16
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/placement/check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CA+C1D"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reject a placement that cannot place anything.
|
|
3
|
+
*
|
|
4
|
+
* The types require all of this, but a CLI user's config module is plain
|
|
5
|
+
* JavaScript with nothing checking it, and none of these omissions fails
|
|
6
|
+
* anywhere near the config: a missing `dir` surfaces as a complaint about an
|
|
7
|
+
* argument to `path`, and the rest as something not being a function. Key
|
|
8
|
+
* validation is no help either — it is the option that is not there.
|
|
9
|
+
*
|
|
10
|
+
* This sits here rather than in `validate/`, which checks keys and the names
|
|
11
|
+
* of closed sets, for the reason `fonts/resolve.ts` does: what a value has to
|
|
12
|
+
* be is known by whatever is about to use it.
|
|
13
|
+
*/
|
|
14
|
+
export function assertPlacement(placement) {
|
|
15
|
+
const declared = placement;
|
|
16
|
+
if (declared.urlBase !== undefined && typeof declared.urlBase !== "string") {
|
|
17
|
+
throw new TypeError(`placement urlBase must be a string; it is prefixed to each image's path.`);
|
|
18
|
+
}
|
|
19
|
+
if (declared.hash !== undefined && typeof declared.hash !== "boolean") {
|
|
20
|
+
throw new TypeError(`placement hash must be true or false. Anything else reads as neither,` +
|
|
21
|
+
` so the images would be written unhashed without a word about it.`);
|
|
22
|
+
}
|
|
23
|
+
if (placement.strategy === "public-dir") {
|
|
24
|
+
if (typeof declared.dir !== "string" || declared.dir === "") {
|
|
25
|
+
throw new TypeError(`placement "public-dir" needs a "dir" to write the images into.`);
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (placement.strategy !== "custom") {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (typeof declared.path !== "function") {
|
|
33
|
+
throw new TypeError(`placement "custom" needs a "path" function saying where each image goes.`);
|
|
34
|
+
}
|
|
35
|
+
if (declared.url !== undefined && typeof declared.url !== "function") {
|
|
36
|
+
throw new TypeError(`placement "custom" takes a "url" function, or none at all for images` +
|
|
37
|
+
` that are written but not served.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.js","sourceRoot":"","sources":["../../src/placement/check.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,MAAM,QAAQ,GAAG,SAMhB,CAAC;IAEF,IAAI,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC3E,MAAM,IAAI,SAAS,CACjB,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACtE,MAAM,IAAI,SAAS,CACjB,uEAAuE;YACrE,mEAAmE,CACtE,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxC,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,QAAQ,IAAI,QAAQ,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC;YAC5D,MAAM,IAAI,SAAS,CACjB,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO;IACT,CAAC;IAED,IAAI,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,SAAS,CACjB,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,GAAG,KAAK,SAAS,IAAI,OAAO,QAAQ,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QACrE,MAAM,IAAI,SAAS,CACjB,sEAAsE;YACpE,mCAAmC,CACtC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ContentFile, OutputSize, Placement } from "../types.js";
|
|
2
|
+
export { besideContent, imageName } from "./relative.js";
|
|
3
|
+
/**
|
|
4
|
+
* Where one image ends up: the path its bytes are written to, and the URL it
|
|
5
|
+
* is served at, if the placement knows one.
|
|
6
|
+
*/
|
|
7
|
+
export interface PlacedImage {
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly url: string | undefined;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Places each image of a build.
|
|
13
|
+
*
|
|
14
|
+
* The stamp is handed over whether or not the placement wants it: it is what a
|
|
15
|
+
* hashed filename is built from, and a placement that does not hash simply
|
|
16
|
+
* ignores it.
|
|
17
|
+
*/
|
|
18
|
+
export type Placer = (file: ContentFile, size: OutputSize, stamp: string) => PlacedImage;
|
|
19
|
+
/**
|
|
20
|
+
* Build the function that places every image of a build.
|
|
21
|
+
*
|
|
22
|
+
* The strategies differ only in the root an image is placed under and whether
|
|
23
|
+
* it keeps the directories its post sits in: `beside-content` keeps them,
|
|
24
|
+
* which is the page-bundle convention, and `public-dir` drops them so that a
|
|
25
|
+
* flat directory can be served as one. Either way the same relative path
|
|
26
|
+
* makes the disk path and the URL, so the two cannot drift apart.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createPlacer(placement: Placement | undefined, contentDir: string): Placer;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/placement/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAItE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,MAAM,GAAG,CACnB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,KACV,WAAW,CAAC;AAyBjB;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,UAAU,EAAE,MAAM,GACjB,MAAM,CAkCR"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { assertPlacement } from "./check.js";
|
|
3
|
+
import { besideContent, imageName } from "./relative.js";
|
|
4
|
+
export { besideContent, imageName } from "./relative.js";
|
|
5
|
+
/**
|
|
6
|
+
* Prefix a `urlBase` onto an image's path under the root that placed it.
|
|
7
|
+
*
|
|
8
|
+
* No base, no URL: a directory on disk does not say how — or whether — it is
|
|
9
|
+
* served, and a URL Colophon invented would be worse than the gap it fills,
|
|
10
|
+
* since the whole point of writing one down is that a site can trust it.
|
|
11
|
+
*/
|
|
12
|
+
function toUrl(urlBase, relative) {
|
|
13
|
+
if (urlBase === undefined) {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
return `${urlBase.replace(/\/+$/, "")}/${relative}`;
|
|
17
|
+
}
|
|
18
|
+
/** Join a path that uses URL separators back into a platform path. */
|
|
19
|
+
function under(root, relative) {
|
|
20
|
+
return path.join(root, ...relative.split("/"));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build the function that places every image of a build.
|
|
24
|
+
*
|
|
25
|
+
* The strategies differ only in the root an image is placed under and whether
|
|
26
|
+
* it keeps the directories its post sits in: `beside-content` keeps them,
|
|
27
|
+
* which is the page-bundle convention, and `public-dir` drops them so that a
|
|
28
|
+
* flat directory can be served as one. Either way the same relative path
|
|
29
|
+
* makes the disk path and the URL, so the two cannot drift apart.
|
|
30
|
+
*/
|
|
31
|
+
export function createPlacer(placement, contentDir) {
|
|
32
|
+
if (placement !== undefined) {
|
|
33
|
+
assertPlacement(placement);
|
|
34
|
+
}
|
|
35
|
+
if (placement === undefined || placement.strategy === "beside-content") {
|
|
36
|
+
const urlBase = placement?.urlBase;
|
|
37
|
+
const isHashes = placement?.hash === true;
|
|
38
|
+
return (file, size, stamp) => {
|
|
39
|
+
const relative = besideContent(file, size, isHashes ? stamp : undefined);
|
|
40
|
+
return {
|
|
41
|
+
path: under(contentDir, relative),
|
|
42
|
+
url: toUrl(urlBase, relative),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (placement.strategy === "public-dir") {
|
|
47
|
+
const isHashes = placement.hash === true;
|
|
48
|
+
return (file, size, stamp) => {
|
|
49
|
+
const relative = imageName(file, size, isHashes ? stamp : undefined);
|
|
50
|
+
return {
|
|
51
|
+
path: under(placement.dir, relative),
|
|
52
|
+
url: toUrl(placement.urlBase, relative),
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return (file, size) => ({
|
|
57
|
+
path: placement.path(file, size),
|
|
58
|
+
url: placement.url?.(file, size),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/placement/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAwBzD;;;;;;GAMG;AACH,SAAS,KAAK,CACZ,OAA2B,EAC3B,QAAgB;IAEhB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,QAAQ,EAAE,CAAC;AACtD,CAAC;AAED,sEAAsE;AACtE,SAAS,KAAK,CAAC,IAAY,EAAE,QAAgB;IAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAC1B,SAAgC,EAChC,UAAkB;IAElB,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,eAAe,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,KAAK,gBAAgB,EAAE,CAAC;QACvE,MAAM,OAAO,GAAG,SAAS,EAAE,OAAO,CAAC;QACnC,MAAM,QAAQ,GAAG,SAAS,EAAE,IAAI,KAAK,IAAI,CAAC;QAE1C,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACzE,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,CAAC;gBACjC,GAAG,EAAE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC;aAC9B,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,QAAQ,KAAK,YAAY,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,KAAK,IAAI,CAAC;QAEzC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YAC3B,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACrE,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAC;gBACpC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC;aACxC,CAAC;QACJ,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;QACtB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC;QAChC,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ContentFile, OutputSize } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The filename one image is written under: `<slug>-<size>.png`, or
|
|
4
|
+
* `<slug>-<size>.<hash>.png` where the placement asks for a hash. The slug
|
|
5
|
+
* carries the post's keywords, and the size name keeps every image of a post
|
|
6
|
+
* distinct (`my-post-og.png`, `my-post-square.png`).
|
|
7
|
+
*
|
|
8
|
+
* A slug carrying directories of its own — what the `route` strategy produces,
|
|
9
|
+
* and what a frontmatter `slug` of `docs/intro` means — puts them in the name,
|
|
10
|
+
* so the image's path mirrors the route wherever it is placed.
|
|
11
|
+
*
|
|
12
|
+
* The digest is the image's rebuild stamp: the props, the config and the size
|
|
13
|
+
* it is drawn from. Hashing the rendered bytes would be a truer name, but they
|
|
14
|
+
* are not known until the image has been rendered, and the point of the stamp
|
|
15
|
+
* is not rendering the ones that have not changed.
|
|
16
|
+
*/
|
|
17
|
+
export declare function imageName(file: ContentFile, size: OutputSize, hash: string | undefined): string;
|
|
18
|
+
/**
|
|
19
|
+
* Where an image goes relative to the content root, in URL form.
|
|
20
|
+
*
|
|
21
|
+
* Slashes rather than the platform's separator, because this is also what a
|
|
22
|
+
* URL is built from: a Windows build must not serve `posts\my-post\a.png`.
|
|
23
|
+
* The disk path is joined back up per platform by whoever places it.
|
|
24
|
+
*
|
|
25
|
+
* A slug with directories of its own is placed from the content root, so its
|
|
26
|
+
* path mirrors the route. Resolving it beside the file would repeat the
|
|
27
|
+
* directories already in the slug, putting `services/iam` under
|
|
28
|
+
* `content/services/iam/`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function besideContent(file: ContentFile, size: OutputSize, hash: string | undefined): string;
|
|
31
|
+
//# sourceMappingURL=relative.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relative.d.ts","sourceRoot":"","sources":["../../src/placement/relative.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW3D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,CAMR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,MAAM,CAYR"}
|