mirror of
https://github.com/openmlsys/openmlsys-zh.git
synced 2026-04-01 01:41:17 +08:00
fix: add resource symlinks and repo root static fallback to mdbook build
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,20 @@ if ! command -v mdbook >/dev/null 2>&1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ── Create resource symlinks ──────────────────────────────────────────────────
|
||||
# Resources (img/, references/, static/, mlsys.bib) live at the repo root and
|
||||
# are symlinked into zh_chapters/ so mdbook can find them at relative paths.
|
||||
for target in img references static mlsys.bib; do
|
||||
link="${ROOT}/zh_chapters/${target}"
|
||||
rel_target="../${target}"
|
||||
if [[ -e "${link}" ]] && [[ ! -L "${link}" ]]; then
|
||||
echo "Refusing to replace non-symlink path: ${link}" >&2
|
||||
exit 1
|
||||
fi
|
||||
ln -sfn "${rel_target}" "${link}"
|
||||
done
|
||||
|
||||
# ── Build ─────────────────────────────────────────────────────────────────────
|
||||
"${PYTHON_BIN}" "${ROOT}/tools/prepare_mdbook_zh.py" \
|
||||
--source "${ROOT}/zh_chapters" \
|
||||
--summary-output "${ROOT}/zh_chapters/SUMMARY.md"
|
||||
|
||||
@@ -161,6 +161,10 @@ def resolve_raw_html_file(current_file: Path, filename: str) -> Path:
|
||||
if static_fallback.exists():
|
||||
return static_fallback
|
||||
|
||||
repo_static = (Path(__file__).resolve().parent.parent / "static" / filename)
|
||||
if repo_static.exists():
|
||||
return repo_static
|
||||
|
||||
raise FileNotFoundError(f"Raw HTML include '{filename}' from '{current_file}' does not exist")
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1
zh_chapters/mlsys.bib
Symbolic link
1
zh_chapters/mlsys.bib
Symbolic link
@@ -0,0 +1 @@
|
||||
../mlsys.bib
|
||||
Reference in New Issue
Block a user