summaryrefslogtreecommitdiff
path: root/repo/www/convert-internal-links.lua
blob: e50352a7d938320de66bc83cbf5d1c316718b445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
EXTENSIONS = {}

string.gsub(
  os.getenv("EXTENSIONS"),
  "[^%s]+",
  function (ext) EXTENSIONS[#EXTENSIONS+1] = ext end
)

function Link(link)
  if link.target:match("^[%w]+://")
  then
    return link
  end

  for _, ext in pairs(EXTENSIONS)
  do
    link.target = link.target:gsub("%."..ext.."$", ".html")
  end

  return link
end