Skip to content

Commit d436f21

Browse files
add Antora xref
1 parent 61c3182 commit d436f21

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/markdown-for-llm.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,28 @@ function markdownify(page, pubDate) {
4141
`[View original HTML](${orig})\n\n` +
4242
`# ${title}\n\n${markdown}`
4343

44+
const link = antoraLink(page)
45+
4446
const frontmatter = {
4547
title,
4648
description: page.asciidoc.attributes.description,
4749
editUrl: page.src.editUrl,
4850
pubDate,
51+
link,
4952
}
5053

5154
output = `---\n${YAML.stringify(frontmatter)}---\n\n${output}`
5255

5356
page.contents = Buffer.from(output)
5457
}
5558

59+
function antoraLink({src, asciidoc}) {
60+
const { relative, version, component, module } = src
61+
const vpart = 'page-component-version-is-latest' in asciidoc.attributes ? '' : `${version}@`
62+
const coordpart = `${component}:${module}:${relative}`.replace(':ROOT:', '::')
63+
return `xref:${vpart}${coordpart}[]`
64+
}
65+
5666
module.exports.register = function ({ playbook, config }) {
5767
this.once('contextStarted', () => {
5868
const { createPageComposer: _delegate } = this.getFunctions()

0 commit comments

Comments
 (0)