22 lines
1.1 KiB
Bash
22 lines
1.1 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Builds the external briefs as styled HTML and prints them to docs/external/pdf/ with headless Chrome.
|
||
|
|
set -euo pipefail
|
||
|
|
cd "$(dirname "$0")"
|
||
|
|
CHROME="${CHROME:-/Applications/Google Chrome.app/Contents/MacOS/Google Chrome}"
|
||
|
|
tmp=$(mktemp -d)
|
||
|
|
mkdir -p ../pdf
|
||
|
|
|
||
|
|
build() { # <md> <out.pdf> <lang> <title> <eyebrow>
|
||
|
|
local md=$1 out=$2 lang=$3 title=$4 eyebrow=$5
|
||
|
|
PAGE_LANG="$lang" PAGE_TITLE="$title" PAGE_EYEBROW="$eyebrow" node page.mjs "$md" "$tmp/body.html" >/dev/null
|
||
|
|
{ echo "<!doctype html><html lang=\"$lang\"><head><meta charset=\"utf-8\"></head><body style=\"margin:0\">"
|
||
|
|
cat "$tmp/body.html"; echo "</body></html>"; } > "$tmp/page.html"
|
||
|
|
"$CHROME" --headless=new --disable-gpu --no-pdf-header-footer --virtual-time-budget=8000 \
|
||
|
|
--print-to-pdf="../pdf/$out" "file://$tmp/page.html" >/dev/null 2>&1
|
||
|
|
echo "wrote pdf/$out"
|
||
|
|
}
|
||
|
|
|
||
|
|
build ../architecture-brief.en.md architecture-brief.en.pdf en "VPP AI Platform Brief" "Architecture brief · condensed external edition"
|
||
|
|
build ../architecture-brief.zh.md architecture-brief.zh.pdf zh "虚拟电厂 AI 平台架构" "系统架构 · 对外精简版"
|
||
|
|
rm -rf "$tmp"
|