website: fix broken GitHub links for project files in docs

This commit is contained in:
shum
2026-07-10 09:40:19 +00:00
parent 56040adf28
commit a85b958e1d
+3 -4
View File
@@ -440,10 +440,9 @@ module.exports = function (ty) {
if (fs.existsSync(linkFile)) {
// this condition works if the link is a valid project file
const githubUrl = "https://github.com/simplex-chat/simplex-chat/blob/stable"
const keyword = "/simplex-chat"
index = linkFile.indexOf(keyword)
linkFile = linkFile.substring(index + keyword.length)
parsed.path = `${githubUrl}${linkFile}`
const repoRoot = hostFile.slice(0, hostFile.indexOf('/website/src'))
const repoPath = linkFile.slice(repoRoot.length)
return `${githubUrl}${repoPath}`
} else {
// if the link is not a valid website file or project file
throw new Error(`Broken link: ${parsed.path} in ${hostFile}`)