Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified build/ui-bundle.zip
Binary file not shown.
18 changes: 16 additions & 2 deletions src/helpers/md-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@

/**
* Map an Antora HTML page URL to its LLM Markdown twin.
* Example: /savanna/main/overview/index.html → /savanna/main/overview/index.md
*
* Handles both URL styles:
* /savanna/main/overview/index.html → /savanna/main/overview/index.md
* /savanna/main/overview/ → /savanna/main/overview/index.md
* /savanna/main/overview/pricing → /savanna/main/overview/pricing.md
*/
module.exports = (url) => (typeof url === 'string' ? url.replace(/\.html(?=[#?]|$)/, '.md') : url)
module.exports = (url) => {
if (typeof url !== 'string') return url
const match = /^(.*?)([?#].*)?$/.exec(url)
const path = match[1]
const rest = match[2] || ''
if (/\.md$/i.test(path)) return url
if (/\.html$/i.test(path)) return path.replace(/\.html$/i, '.md') + rest
if (path.endsWith('/')) return path + 'index.md' + rest
if (!path) return url
return path + '.md' + rest
}
Loading