Skip to content

Commit 73eda91

Browse files
committed
Improvements to site post-proc script
1 parent 0def543 commit 73eda91

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

docs/_extensions/transform-links.lua

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,31 @@
44
function Link(el)
55
local target = el.target
66

7-
-- Only transform if it ends with .md
8-
if target:match("%.md$") then
9-
-- Transform any .md link to .qmd
10-
el.target = target:gsub("%.md$", ".qmd")
11-
return el
7+
-- Transform .md to .qmd (including anchors)
8+
if target:match("%.md") then
9+
target = target:gsub("%.md", ".qmd")
1210
end
1311

12+
-- Handle cross-skill SKILL references: ../add-xxx/SKILL.qmd -> add-xxx.qmd
13+
if target:match("%.%./[^/]+/SKILL%.qmd") then
14+
target = target:gsub("%.%./([^/]+)/SKILL%.qmd", "%1.qmd")
15+
end
16+
17+
-- Handle cross-skill reference files from references/ folder:
18+
-- ../../add-xxx/references/file.qmd -> file.qmd
19+
-- (Keep in same references/ folder, just get the filename)
20+
if target:match("%.%./%.%./[^/]+/references/") then
21+
target = target:gsub("%.%./%.%./[^/]+/references/([^/]+)", "%1")
22+
end
23+
24+
-- Handle same-skill reference files: add-xxx/references/file.qmd -> references/file.qmd
25+
if target:match("^add%-[^/]+/references/") then
26+
target = target:gsub("^add%-[^/]+/references/", "references/")
27+
end
28+
29+
-- Remove developers/ prefix
30+
target = target:gsub("^developers/", "")
31+
32+
el.target = target
1433
return el
1534
end

0 commit comments

Comments
 (0)