@norskvideo/ctl-dev-kit 0.1.38 → 0.1.39
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.
|
@@ -136,6 +136,21 @@ jobs:
|
|
|
136
136
|
# the Artifact fragment index.html — ctl hosts it directly as a page.
|
|
137
137
|
man="docs/generated/manual/manual.html"
|
|
138
138
|
[ -s "$man" ] || { echo "::error::manual was not generated at $man"; exit 1; }
|
|
139
|
+
# This asset is published ALONE, so it must carry its own images.
|
|
140
|
+
# A manual referencing sidecars renders as a page of broken images
|
|
141
|
+
# on the ctl docs site, and the only symptom is ctl's release
|
|
142
|
+
# link-check going red days later -- fail here, where the cause is
|
|
143
|
+
# visible. Every <img> chunk must carry a data: URI; the leading
|
|
144
|
+
# dot matches the attribute quote so no escaping is needed here.
|
|
145
|
+
# Counted rather than tested with grep -qv, whose empty-input exit
|
|
146
|
+
# status differs between GNU and BSD grep.
|
|
147
|
+
imgs="$(grep -oE "<img[^>]*src=[^>]*" "$man" || true)"
|
|
148
|
+
external="$(printf %s "$imgs" | grep -cv "src=.data:" || true)"
|
|
149
|
+
if [ -n "$imgs" ] && [ "${external:-0}" -gt 0 ]; then
|
|
150
|
+
echo "::error::manual.html references external images -- publish the self-contained standalone (buildManual standaloneHtml), not the sidecar variant"
|
|
151
|
+
printf %s "$imgs" | grep -v "src=.data:" | head -5
|
|
152
|
+
exit 1
|
|
153
|
+
fi
|
|
139
154
|
cp "$man" "$RUNNER_TEMP/manual.html"
|
|
140
155
|
if ! gh release view docs-latest >/dev/null 2>&1; then
|
|
141
156
|
gh release create docs-latest --title "Docs (latest)" --prerelease \
|
|
@@ -46,8 +46,13 @@ export interface ManualSpec {
|
|
|
46
46
|
export interface BuildManualResult {
|
|
47
47
|
/** Artifact-ready fragment (no doctype/head/body). */
|
|
48
48
|
indexHtml: string;
|
|
49
|
-
/** Complete standalone document wrapping the fragment.
|
|
49
|
+
/** Complete standalone document wrapping the fragment. Always self-contained,
|
|
50
|
+
* whether or not sidecars were asked for — this is the shape that survives
|
|
51
|
+
* being published on its own. */
|
|
50
52
|
standaloneHtml: string;
|
|
53
|
+
/** The same document referencing the sidecar files instead of inlining them.
|
|
54
|
+
* Only present when `assets` is set, and only useful alongside `assets.dir`. */
|
|
55
|
+
standaloneAssetHtml?: string;
|
|
51
56
|
/** `<slug>/<file>` of every referenced capture not found on disk. */
|
|
52
57
|
missing: string[];
|
|
53
58
|
}
|
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
//
|
|
13
13
|
// The FRAGMENT always inlines each image as a data URI — Artifacts serve under a
|
|
14
14
|
// CSP that blocks external image hosts, so a self-contained fragment is the only
|
|
15
|
-
// thing that renders there. The STANDALONE
|
|
16
|
-
//
|
|
17
|
-
// relative href
|
|
18
|
-
//
|
|
15
|
+
// thing that renders there. The STANDALONE is self-contained too, ALWAYS: it is
|
|
16
|
+
// the one file publish-docs uploads on its own, so anything it references by
|
|
17
|
+
// relative href would 404 wherever it lands. Pass `opts.assets` to ADDITIONALLY
|
|
18
|
+
// get `standaloneAssetHtml` plus the captures written as sidecar files — the
|
|
19
|
+
// shape marketing hosts and zips, where individual images must be liftable
|
|
20
|
+
// rather than buried in base64. Both renders share one resize cache, so asking
|
|
21
|
+
// for sidecars costs no extra ImageMagick work.
|
|
19
22
|
//
|
|
20
23
|
// Product-specific content — the page arrays, the overview copy, the brand — is
|
|
21
24
|
// supplied by the caller in `ManualSpec`; everything structural (layout, CSS,
|
|
@@ -209,15 +212,7 @@ ${ALL.map(pageHtml).join("\n")}
|
|
|
209
212
|
</script>`;
|
|
210
213
|
return html;
|
|
211
214
|
};
|
|
212
|
-
|
|
213
|
-
// when `assets` is set, otherwise the same inlined body wrapped in a document.
|
|
214
|
-
const indexHtml = render(inline);
|
|
215
|
-
let standaloneBody = indexHtml;
|
|
216
|
-
if (assets) {
|
|
217
|
-
mkdirSync(assets.dir, { recursive: true });
|
|
218
|
-
standaloneBody = render(external);
|
|
219
|
-
}
|
|
220
|
-
const standaloneHtml = `<!doctype html>
|
|
215
|
+
const document = (body) => `<!doctype html>
|
|
221
216
|
<html lang="en">
|
|
222
217
|
<head>
|
|
223
218
|
<meta charset="utf-8" />
|
|
@@ -225,8 +220,15 @@ ${ALL.map(pageHtml).join("\n")}
|
|
|
225
220
|
<title>${esc(spec.title)}</title>
|
|
226
221
|
</head>
|
|
227
222
|
<body>
|
|
228
|
-
${
|
|
223
|
+
${body}
|
|
229
224
|
</body>
|
|
230
225
|
</html>`;
|
|
231
|
-
|
|
226
|
+
// Fragment and standalone are both inlined (Artifact CSP; publishable on its
|
|
227
|
+
// own). Sidecars are an EXTRA output, never a substitution.
|
|
228
|
+
const indexHtml = render(inline);
|
|
229
|
+
const standaloneHtml = document(indexHtml);
|
|
230
|
+
if (!assets)
|
|
231
|
+
return { indexHtml, standaloneHtml, missing };
|
|
232
|
+
mkdirSync(assets.dir, { recursive: true });
|
|
233
|
+
return { indexHtml, standaloneHtml, standaloneAssetHtml: document(render(external)), missing };
|
|
232
234
|
}
|