Skip to content

Commit ea6a76c

Browse files
authored
Merge pull request #6 from CatholicOS/fix/governance-url-hierarchy
fix: update internal links for /governance/ URL hierarchy
2 parents 029a327 + 03c04fe commit ea6a76c

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ jobs:
125125
PARENT_SLUG="${SECTION_PARENTS[$SECTION]}"
126126
127127
echo "Converting ${DOC}.md..."
128-
pandoc "${DOC}.md" --wrap=none --lua-filter=scripts/fix-internal-links.lua -f markdown -t html5 -o "${SLUG}.html"
128+
pandoc "${DOC}.md" --wrap=none -M section="$SECTION" --lua-filter=scripts/fix-internal-links.lua -f markdown -t html5 -o "${SLUG}.html"
129129
130130
HTML_CONTENT=$(cat "${SLUG}.html")
131131

scripts/fix-internal-links.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Pandoc Lua filter: rewrite internal .md links for different output targets.
22
--
33
-- Set the LINK_MODE environment variable (or pandoc metadata) to control behavior:
4-
-- "website" (default) → /slug (absolute paths for WordPress)
4+
-- "website" (default) → /governance/<section>/slug (absolute paths for WordPress)
55
-- "html" → slug.html (relative paths for standalone HTML files)
66
-- "combined" → #heading-anchor (fragment links within the combined PDF)
77
--
@@ -10,12 +10,16 @@
1010
-- - Standards docs get a "standards-" prefix to avoid slug collisions
1111

1212
local mode = os.getenv("LINK_MODE") or "website"
13+
local current_section = os.getenv("LINK_SECTION") or nil
1314

14-
-- Read mode from pandoc metadata as fallback
15+
-- Read mode and section from pandoc metadata as fallback
1516
function Meta(meta)
1617
if meta["link-mode"] then
1718
mode = pandoc.utils.stringify(meta["link-mode"])
1819
end
20+
if meta["section"] then
21+
current_section = pandoc.utils.stringify(meta["section"])
22+
end
1923
end
2024

2125
function Link(el)
@@ -59,8 +63,13 @@ function Link(el)
5963
el.target = '#' .. base
6064
end
6165
else
62-
-- website mode (default)
63-
el.target = '/' .. base .. anchor
66+
-- website mode (default): /governance/<section>/<slug>
67+
local section = dir or current_section
68+
if section then
69+
el.target = '/governance/' .. section .. '/' .. base .. anchor
70+
else
71+
el.target = '/governance/' .. base .. anchor
72+
end
6473
end
6574

6675
return el

0 commit comments

Comments
 (0)