@kensio/colophon 0.2.0 → 2.1.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 +133 -12
- package/dist/config.d.ts +50 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +62 -8
- package/dist/config.js.map +1 -1
- package/dist/content/index.d.ts +13 -0
- package/dist/content/index.d.ts.map +1 -1
- package/dist/content/index.js +23 -6
- package/dist/content/index.js.map +1 -1
- package/dist/generate.d.ts +8 -8
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +11 -20
- package/dist/generate.js.map +1 -1
- package/dist/highlight.d.ts +65 -0
- package/dist/highlight.d.ts.map +1 -0
- package/dist/highlight.js +114 -0
- package/dist/highlight.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/render.d.ts +5 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +10 -6
- package/dist/render.js.map +1 -1
- package/dist/templates/banner.d.ts.map +1 -1
- package/dist/templates/banner.js +2 -12
- package/dist/templates/banner.js.map +1 -1
- package/dist/templates/card.d.ts.map +1 -1
- package/dist/templates/card.js +2 -12
- package/dist/templates/card.js.map +1 -1
- package/dist/templates/code.d.ts +12 -0
- package/dist/templates/code.d.ts.map +1 -0
- package/dist/templates/code.js +203 -0
- package/dist/templates/code.js.map +1 -0
- package/dist/templates/index.d.ts +2 -0
- package/dist/templates/index.d.ts.map +1 -1
- package/dist/templates/index.js +4 -0
- package/dist/templates/index.js.map +1 -1
- package/dist/templates/props.d.ts +7 -0
- package/dist/templates/props.d.ts.map +1 -0
- package/dist/templates/props.js +17 -0
- package/dist/templates/props.js.map +1 -0
- package/dist/types.d.ts +57 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -5
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { highlightCode } from "../highlight.js";
|
|
2
|
+
import { escapeXml, textElement } from "../text.js";
|
|
3
|
+
import { optionalString } from "./props.js";
|
|
4
|
+
/** Fraction of the font size the baseline sits below the glyph box top. */
|
|
5
|
+
const ascentRatio = 0.78;
|
|
6
|
+
const ellipsis = "…";
|
|
7
|
+
/**
|
|
8
|
+
* Place the code panel within the image, leaving room above for a title and
|
|
9
|
+
* below for a footer when either is present.
|
|
10
|
+
*/
|
|
11
|
+
function layoutPanel(dimensions, config, titleFontSize, footerFontSize, hasTitle, hasFooter) {
|
|
12
|
+
const { width, height } = dimensions;
|
|
13
|
+
const shorter = Math.min(width, height);
|
|
14
|
+
const pad = Math.round(shorter * 0.05);
|
|
15
|
+
const gap = Math.round(shorter * 0.028);
|
|
16
|
+
const top = pad + (hasTitle ? titleFontSize + gap : 0);
|
|
17
|
+
const bottom = height - pad - (hasFooter ? footerFontSize + gap : 0);
|
|
18
|
+
return {
|
|
19
|
+
x: pad,
|
|
20
|
+
y: top,
|
|
21
|
+
width: width - pad * 2,
|
|
22
|
+
height: Math.max(1, bottom - top),
|
|
23
|
+
radius: Math.round(shorter * config.code.cornerScale),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Shrink a panel vertically onto its content, keeping it centred in the space
|
|
28
|
+
* it was allotted. Floored so a one-line snippet still gets a panel with
|
|
29
|
+
* presence rather than a letterbox slot.
|
|
30
|
+
*/
|
|
31
|
+
function hugHeight(available, wanted) {
|
|
32
|
+
// Floor relative to the panel's width, so shrinking never leaves a sliver.
|
|
33
|
+
const height = Math.min(available.height, Math.max(Math.round(wanted), Math.round(available.width * 0.25)));
|
|
34
|
+
return {
|
|
35
|
+
...available,
|
|
36
|
+
y: available.y + Math.round((available.height - height) / 2),
|
|
37
|
+
height,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Pick the largest font size that fits the snippet in the panel on both axes,
|
|
42
|
+
* clamped to the configured bounds.
|
|
43
|
+
*/
|
|
44
|
+
function fitFontSize(highlighted, codeWidth, codeHeight, imageHeight, config) {
|
|
45
|
+
const { charWidthRatio, lineHeight, maxFontScale, minFontScale } = config.code;
|
|
46
|
+
const byWidth = codeWidth / (Math.max(1, highlighted.longestLine) * charWidthRatio);
|
|
47
|
+
const byHeight = codeHeight / (Math.max(1, highlighted.lines.length) * lineHeight);
|
|
48
|
+
const fitted = Math.min(byWidth, byHeight, imageHeight * maxFontScale);
|
|
49
|
+
return Math.max(1, Math.floor(Math.max(fitted, imageHeight * minFontScale)));
|
|
50
|
+
}
|
|
51
|
+
const ellipsisToken = {
|
|
52
|
+
text: ellipsis,
|
|
53
|
+
column: 0,
|
|
54
|
+
color: undefined,
|
|
55
|
+
opacity: 0.6,
|
|
56
|
+
bold: false,
|
|
57
|
+
italic: false,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Drop lines that cannot fit at the chosen font size, marking the truncation
|
|
61
|
+
* with an ellipsis line so the image never silently misrepresents the snippet.
|
|
62
|
+
*/
|
|
63
|
+
function fitLines(lines, codeHeight, step) {
|
|
64
|
+
const maxLines = Math.max(1, Math.floor(codeHeight / step));
|
|
65
|
+
if (lines.length <= maxLines) {
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
return [...lines.slice(0, maxLines - 1), [ellipsisToken]];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Clip a line to the columns that fit, ending it with an ellipsis. The font
|
|
72
|
+
* size is floored for legibility, so a wide enough snippet can still overrun
|
|
73
|
+
* the panel — clipping keeps it inside instead of bleeding off the image.
|
|
74
|
+
*/
|
|
75
|
+
function clipLine(tokens, maxColumns) {
|
|
76
|
+
const clipped = [];
|
|
77
|
+
for (const token of tokens) {
|
|
78
|
+
if (token.column >= maxColumns) {
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
const room = maxColumns - token.column;
|
|
82
|
+
if (token.text.length <= room) {
|
|
83
|
+
clipped.push(token);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
clipped.push({ ...token, text: token.text.slice(0, room - 1) + ellipsis });
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
return clipped;
|
|
90
|
+
}
|
|
91
|
+
function tokenSpan(token, x, charWidth, foreground) {
|
|
92
|
+
const fill = token.color ?? foreground;
|
|
93
|
+
const opacity = token.opacity === undefined
|
|
94
|
+
? ""
|
|
95
|
+
: ` fill-opacity="${String(token.opacity)}"`;
|
|
96
|
+
const weight = token.bold ? ` font-weight="700"` : "";
|
|
97
|
+
const style = token.italic ? ` font-style="italic"` : "";
|
|
98
|
+
return (`<tspan x="${String(Math.round(x + token.column * charWidth))}"` +
|
|
99
|
+
` fill="${fill}"${opacity}${weight}${style}>` +
|
|
100
|
+
`${escapeXml(token.text)}</tspan>`);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Syntax-highlighted code snippet on a rounded panel over the configured
|
|
104
|
+
* background. Reads `code` and `language` from the props (as the original
|
|
105
|
+
* `image_text` / `image_lexer` frontmatter did), with an optional `title`
|
|
106
|
+
* above the panel and the configured footer below it.
|
|
107
|
+
*
|
|
108
|
+
* Highlighting uses Shiki, so token colours come from a real VS Code theme
|
|
109
|
+
* rather than being approximated.
|
|
110
|
+
*/
|
|
111
|
+
export const codeTemplate = {
|
|
112
|
+
name: "code",
|
|
113
|
+
async render({ props, config, dimensions }) {
|
|
114
|
+
const { width, height } = dimensions;
|
|
115
|
+
const code = optionalString(props["code"]) ?? "";
|
|
116
|
+
const language = optionalString(props["language"]) ?? "text";
|
|
117
|
+
const theme = optionalString(props["theme"]) ?? config.code.theme;
|
|
118
|
+
const highlighted = await highlightCode(code, {
|
|
119
|
+
language,
|
|
120
|
+
theme,
|
|
121
|
+
tabSize: config.code.tabSize,
|
|
122
|
+
});
|
|
123
|
+
const title = optionalString(props.title);
|
|
124
|
+
const hasTitle = title !== undefined && title !== "";
|
|
125
|
+
const hasFooter = config.footer !== undefined && config.footer !== "";
|
|
126
|
+
const titleFs = Math.round(height * 0.045);
|
|
127
|
+
const footerFs = Math.round(height * 0.032);
|
|
128
|
+
const available = layoutPanel(dimensions, config, titleFs, footerFs, hasTitle, hasFooter);
|
|
129
|
+
const inner = Math.round(Math.min(available.width, available.height) * 0.07);
|
|
130
|
+
const codeWidth = Math.max(1, available.width - inner * 2);
|
|
131
|
+
const codeHeight = Math.max(1, available.height - inner * 2);
|
|
132
|
+
const fontSize = fitFontSize(highlighted, codeWidth, codeHeight, height, config);
|
|
133
|
+
const charWidth = fontSize * config.code.charWidthRatio;
|
|
134
|
+
const step = fontSize * config.code.lineHeight;
|
|
135
|
+
const maxColumns = Math.max(1, Math.floor(codeWidth / charWidth));
|
|
136
|
+
const lines = fitLines(highlighted.lines, codeHeight, step).map((tokens) => clipLine(tokens, maxColumns));
|
|
137
|
+
// Padding reads best proportional to the text, not the panel — a snippet
|
|
138
|
+
// fitted down to a small size wants tighter margins. Only ever shrink, so
|
|
139
|
+
// the code area the font was fitted against stays valid.
|
|
140
|
+
const padding = Math.max(Math.min(inner, Math.round(fontSize * 1.6)), Math.round(inner * 0.35));
|
|
141
|
+
// Shrink the panel down onto a short snippet so it isn't left floating in
|
|
142
|
+
// dead space. Width stays full-bleed: a narrow panel on a landscape image
|
|
143
|
+
// reads as a mistake, whereas a short one reads as a code block.
|
|
144
|
+
const panel = hugHeight(available, lines.length * step + padding * 2);
|
|
145
|
+
// Centre the block as a whole; relative indentation is preserved by each
|
|
146
|
+
// token's column, so the snippet keeps its shape.
|
|
147
|
+
const columns = Math.min(highlighted.longestLine, maxColumns);
|
|
148
|
+
const blockWidth = columns * charWidth;
|
|
149
|
+
const originX = panel.x + (panel.width - blockWidth) / 2;
|
|
150
|
+
const originY = panel.y + (panel.height - lines.length * step) / 2;
|
|
151
|
+
const shadowOffset = Math.max(1, Math.round(Math.min(width, height) * 0.01));
|
|
152
|
+
const shadow = `<rect x="${String(panel.x)}" y="${String(panel.y + shadowOffset)}"` +
|
|
153
|
+
` width="${String(panel.width)}" height="${String(panel.height)}"` +
|
|
154
|
+
` rx="${String(panel.radius)}" fill="#000000" fill-opacity="0.22"/>`;
|
|
155
|
+
const surface = `<rect x="${String(panel.x)}" y="${String(panel.y)}"` +
|
|
156
|
+
` width="${String(panel.width)}" height="${String(panel.height)}"` +
|
|
157
|
+
` rx="${String(panel.radius)}" fill="${highlighted.background}"` +
|
|
158
|
+
` stroke="#ffffff" stroke-opacity="0.12"/>`;
|
|
159
|
+
const body = lines
|
|
160
|
+
.map((tokens, index) => {
|
|
161
|
+
if (tokens.length === 0) {
|
|
162
|
+
return "";
|
|
163
|
+
}
|
|
164
|
+
const baseline = Math.round(originY +
|
|
165
|
+
index * step +
|
|
166
|
+
(step - fontSize) / 2 +
|
|
167
|
+
fontSize * ascentRatio);
|
|
168
|
+
const spans = tokens
|
|
169
|
+
.map((token) => tokenSpan(token, originX, charWidth, highlighted.foreground))
|
|
170
|
+
.join("");
|
|
171
|
+
return (`<text y="${String(baseline)}" xml:space="preserve"` +
|
|
172
|
+
` font-family="${escapeXml(config.code.fontFamily)}"` +
|
|
173
|
+
` font-size="${String(fontSize)}">${spans}</text>`);
|
|
174
|
+
})
|
|
175
|
+
.join("");
|
|
176
|
+
const heading = title !== undefined && title !== ""
|
|
177
|
+
? textElement(title, {
|
|
178
|
+
x: Math.round(width / 2),
|
|
179
|
+
y: panel.y - Math.round(titleFs * 0.42),
|
|
180
|
+
fontFamily: config.fontFamily,
|
|
181
|
+
fontSize: titleFs,
|
|
182
|
+
fontWeight: 700,
|
|
183
|
+
fill: config.colors.foreground,
|
|
184
|
+
fillOpacity: 0.95,
|
|
185
|
+
anchor: "middle",
|
|
186
|
+
})
|
|
187
|
+
: "";
|
|
188
|
+
const footer = hasFooter
|
|
189
|
+
? textElement(config.footer, {
|
|
190
|
+
x: Math.round(width / 2),
|
|
191
|
+
y: height - Math.round(Math.min(width, height) * 0.05),
|
|
192
|
+
fontFamily: config.fontFamily,
|
|
193
|
+
fontSize: footerFs,
|
|
194
|
+
fontWeight: 500,
|
|
195
|
+
fill: config.colors.foreground,
|
|
196
|
+
fillOpacity: 0.78,
|
|
197
|
+
anchor: "middle",
|
|
198
|
+
})
|
|
199
|
+
: "";
|
|
200
|
+
return heading + shadow + surface + body + footer;
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/templates/code.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,2EAA2E;AAC3E,MAAM,WAAW,GAAG,IAAI,CAAC;AACzB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAUrB;;;GAGG;AACH,SAAS,WAAW,CAClB,UAAsB,EACtB,MAAsB,EACtB,aAAqB,EACrB,cAAsB,EACtB,QAAiB,EACjB,SAAkB;IAElB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACxC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;IAExC,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IA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AAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;gBACtD,UAAU,EAAE,MAAM,CAAC,UAAU;gBAC7B,QAAQ,EAAE,QAAQ;gBAClB,UAAU,EAAE,GAAG;gBACf,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;gBAC9B,WAAW,EAAE,IAAI;gBACjB,MAAM,EAAE,QAAQ;aACjB,CAAC;YACJ,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC;IACpD,CAAC;CACF,CAAC"}
|
|
@@ -6,4 +6,6 @@ import type { Template } from "../types.js";
|
|
|
6
6
|
export declare const builtinTemplates: Readonly<Record<string, Template>>;
|
|
7
7
|
export { bannerTemplate } from "./banner.js";
|
|
8
8
|
export { cardTemplate } from "./card.js";
|
|
9
|
+
export { codeTemplate } from "./code.js";
|
|
10
|
+
export { optionalString } from "./props.js";
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAK5C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAI/D,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/templates/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bannerTemplate } from "./banner.js";
|
|
2
2
|
import { cardTemplate } from "./card.js";
|
|
3
|
+
import { codeTemplate } from "./code.js";
|
|
3
4
|
/**
|
|
4
5
|
* Templates registered out of the box. Projects can add to or override these
|
|
5
6
|
* via `config.templates`.
|
|
@@ -7,7 +8,10 @@ import { cardTemplate } from "./card.js";
|
|
|
7
8
|
export const builtinTemplates = {
|
|
8
9
|
[bannerTemplate.name]: bannerTemplate,
|
|
9
10
|
[cardTemplate.name]: cardTemplate,
|
|
11
|
+
[codeTemplate.name]: codeTemplate,
|
|
10
12
|
};
|
|
11
13
|
export { bannerTemplate } from "./banner.js";
|
|
12
14
|
export { cardTemplate } from "./card.js";
|
|
15
|
+
export { codeTemplate } from "./code.js";
|
|
16
|
+
export { optionalString } from "./props.js";
|
|
13
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/templates/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAuC;IAClE,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,cAAc;IACrC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;IACjC,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY;CAClC,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else — templates
|
|
4
|
+
* treat "not a usable string" and "absent" the same way.
|
|
5
|
+
*/
|
|
6
|
+
export declare function optionalString(value: unknown): string | undefined;
|
|
7
|
+
//# sourceMappingURL=props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.d.ts","sourceRoot":"","sources":["../../src/templates/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAcjE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a prop as a string, coercing the scalar types YAML frontmatter yields
|
|
3
|
+
* (numbers, booleans) and returning `undefined` for anything else — templates
|
|
4
|
+
* treat "not a usable string" and "absent" the same way.
|
|
5
|
+
*/
|
|
6
|
+
export function optionalString(value) {
|
|
7
|
+
if (typeof value === "string") {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
if (typeof value === "number" ||
|
|
11
|
+
typeof value === "boolean" ||
|
|
12
|
+
typeof value === "bigint") {
|
|
13
|
+
return String(value);
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"props.js","sourceRoot":"","sources":["../../src/templates/props.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -5,6 +5,16 @@ export interface Dimensions {
|
|
|
5
5
|
readonly width: number;
|
|
6
6
|
readonly height: number;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A named output size. The `name` identifies the size in output filenames
|
|
10
|
+
* (e.g. `og`, `square`) and must be unique within a config, so every
|
|
11
|
+
* generated image gets a distinct, descriptive filename.
|
|
12
|
+
*/
|
|
13
|
+
export interface OutputSize {
|
|
14
|
+
readonly name: string;
|
|
15
|
+
readonly width: number;
|
|
16
|
+
readonly height: number;
|
|
17
|
+
}
|
|
8
18
|
/**
|
|
9
19
|
* A single colour stop in a gradient background.
|
|
10
20
|
*/
|
|
@@ -58,6 +68,36 @@ export interface Badge {
|
|
|
58
68
|
/** Badge background colour. Defaults to white. */
|
|
59
69
|
readonly background?: string;
|
|
60
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Styling for the `code` template. Every field is optional; defaults are
|
|
73
|
+
* applied by `resolveConfig`.
|
|
74
|
+
*/
|
|
75
|
+
export interface CodeStyle {
|
|
76
|
+
/** Shiki theme name, e.g. `github-dark`, `monokai`, `catppuccin-mocha`. */
|
|
77
|
+
readonly theme?: string;
|
|
78
|
+
/** Monospace font stack. Must resolve to a font available to `sharp`. */
|
|
79
|
+
readonly fontFamily?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Glyph advance width as a fraction of the font size. `0.6` matches most
|
|
82
|
+
* monospace faces (Source Code Pro, Menlo, DejaVu Sans Mono); narrower faces
|
|
83
|
+
* such as Consolas want ~`0.55`.
|
|
84
|
+
*/
|
|
85
|
+
readonly charWidthRatio?: number;
|
|
86
|
+
/** Line advance as a multiple of the font size. Default `1.55`. */
|
|
87
|
+
readonly lineHeight?: number;
|
|
88
|
+
/** Spaces a tab expands to before layout. Default `2`. */
|
|
89
|
+
readonly tabSize?: number;
|
|
90
|
+
/** Corner radius of the code panel, as a fraction of the smaller side. */
|
|
91
|
+
readonly cornerScale?: number;
|
|
92
|
+
/** Upper bound on the auto-fitted font size, as a fraction of image height. */
|
|
93
|
+
readonly maxFontScale?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Lower bound on the auto-fitted font size, as a fraction of image height.
|
|
96
|
+
* Code too long to fit at this size is truncated with an ellipsis rather
|
|
97
|
+
* than shrunk into illegibility.
|
|
98
|
+
*/
|
|
99
|
+
readonly minFontScale?: number;
|
|
100
|
+
}
|
|
61
101
|
/**
|
|
62
102
|
* Image properties, typically read from a post's frontmatter. The schema is
|
|
63
103
|
* intentionally open: templates read whatever fields they understand, so a
|
|
@@ -66,7 +106,7 @@ export interface Badge {
|
|
|
66
106
|
export interface MetaImageProps {
|
|
67
107
|
/** Name of the template to render with. */
|
|
68
108
|
readonly template: string;
|
|
69
|
-
readonly title
|
|
109
|
+
readonly title?: string;
|
|
70
110
|
readonly subtitle?: string;
|
|
71
111
|
readonly version?: string | number;
|
|
72
112
|
readonly [key: string]: unknown;
|
|
@@ -83,10 +123,14 @@ export interface TemplateContext {
|
|
|
83
123
|
* A registered template. `render` returns the SVG *foreground* content (text,
|
|
84
124
|
* badges, etc.) for the given dimensions; the background and the enclosing
|
|
85
125
|
* `<svg>` root are added by the renderer.
|
|
126
|
+
*
|
|
127
|
+
* Rendering may be asynchronous — the `code` template loads syntax grammars on
|
|
128
|
+
* demand — so `render` can return a promise. Simple templates can stay
|
|
129
|
+
* synchronous and just return a string.
|
|
86
130
|
*/
|
|
87
131
|
export interface Template {
|
|
88
132
|
readonly name: string;
|
|
89
|
-
render(context: TemplateContext): string
|
|
133
|
+
render(context: TemplateContext): string | Promise<string>;
|
|
90
134
|
}
|
|
91
135
|
/**
|
|
92
136
|
* User-supplied configuration. Every field is optional; defaults are applied
|
|
@@ -101,8 +145,13 @@ export interface ColophonConfig {
|
|
|
101
145
|
readonly footer?: string;
|
|
102
146
|
/** Corner badge for the `banner` template. Omit (the default) for none. */
|
|
103
147
|
readonly badge?: Badge;
|
|
104
|
-
/**
|
|
105
|
-
readonly
|
|
148
|
+
/** Styling for the `code` template. */
|
|
149
|
+
readonly code?: CodeStyle;
|
|
150
|
+
/**
|
|
151
|
+
* Output sizes, each with a unique `name` used in the filename. Defaults to
|
|
152
|
+
* a 1.91:1 Open Graph landscape plus a 1:1 square (see `DEFAULT_SIZES`).
|
|
153
|
+
*/
|
|
154
|
+
readonly sizes?: readonly OutputSize[];
|
|
106
155
|
/** Extra templates, merged over (and able to override) the built-ins. */
|
|
107
156
|
readonly templates?: Readonly<Record<string, Template>>;
|
|
108
157
|
}
|
|
@@ -115,13 +164,16 @@ export interface ResolvedConfig {
|
|
|
115
164
|
readonly fontFamily: string;
|
|
116
165
|
readonly footer: string | undefined;
|
|
117
166
|
readonly badge: Badge | undefined;
|
|
118
|
-
readonly
|
|
167
|
+
readonly code: Required<CodeStyle>;
|
|
168
|
+
readonly sizes: readonly OutputSize[];
|
|
119
169
|
readonly templates: Readonly<Record<string, Template>>;
|
|
120
170
|
}
|
|
121
171
|
/**
|
|
122
172
|
* One rendered image: the source SVG plus the encoded PNG bytes.
|
|
123
173
|
*/
|
|
124
174
|
export interface RenderedMetaImage {
|
|
175
|
+
/** The name of the output size this image was rendered for. */
|
|
176
|
+
readonly name: string;
|
|
125
177
|
readonly dimensions: Dimensions;
|
|
126
178
|
readonly svg: string;
|
|
127
179
|
readonly png: Buffer;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAClD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,QAAQ,CAAC,EAAE,CAAC,EAAE;QAAE,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1D,CAAC;AAEN;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC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,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACzD;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;CACxD;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://github.com/KensioSoftware/colophon#readme",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
|
-
"version": "
|
|
11
|
+
"version": "2.1.0",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
@@ -47,13 +47,16 @@
|
|
|
47
47
|
"frontmatter",
|
|
48
48
|
"static-site",
|
|
49
49
|
"svg",
|
|
50
|
-
"sharp"
|
|
50
|
+
"sharp",
|
|
51
|
+
"syntax-highlighting",
|
|
52
|
+
"code-image",
|
|
53
|
+
"shiki"
|
|
51
54
|
],
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@eslint/js": "^10.0.1",
|
|
54
57
|
"@kensio/smartass": "^1.33.0",
|
|
55
58
|
"@types/eslint-plugin-security": "^3.0.1",
|
|
56
|
-
"@types/node": "^
|
|
59
|
+
"@types/node": "^26.0.0",
|
|
57
60
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
58
61
|
"@vitest/coverage-v8": "^4.1.10",
|
|
59
62
|
"@vitest/eslint-plugin": "^1.6.22",
|
|
@@ -62,7 +65,7 @@
|
|
|
62
65
|
"eslint-plugin-jsdoc": "^63.0.13",
|
|
63
66
|
"eslint-plugin-no-secrets": "^2.3.3",
|
|
64
67
|
"eslint-plugin-security": "^4.0.1",
|
|
65
|
-
"eslint-plugin-unicorn": "^
|
|
68
|
+
"eslint-plugin-unicorn": "^68.0.0",
|
|
66
69
|
"globals": "^17.7.0",
|
|
67
70
|
"jiti": "^2.7.0",
|
|
68
71
|
"prettier": "^3.9.5",
|
|
@@ -72,7 +75,8 @@
|
|
|
72
75
|
},
|
|
73
76
|
"dependencies": {
|
|
74
77
|
"gray-matter": "^4.0.3",
|
|
75
|
-
"sharp": "^0.
|
|
78
|
+
"sharp": "^0.35.3",
|
|
79
|
+
"shiki": "^4.3.1"
|
|
76
80
|
},
|
|
77
81
|
"scripts": {
|
|
78
82
|
"build": "tsc -p tsconfig.build.json",
|