Skip to content

Commit

Permalink
Merge pull request #12 from opendevise/issue-5-url-strategy
Browse files Browse the repository at this point in the history
resolves #5 add extension to move docs components under docs folder
  • Loading branch information
jmcc0nn3ll authored Dec 12, 2023
2 parents 60c4a30 + f3e2690 commit 5dfb344
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/publish-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
node-version: '18'
- name: Generate Site
run: npx -y antora antora-playbook.yml
run: npx -y antora --html-url-extension-style=indexify antora-playbook.yml
- name: Upload Artifact
uses: actions/upload-pages-artifact@v2
- name: Deploy Artifact to GitHub Pages
Expand Down
3 changes: 3 additions & 0 deletions antora-playbook.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# npx antora antora-playbook.yml
antora:
extensions:
- ./lib/component-url-prefix-extension.js
site:
title: Eclipse Jetty
url: https://jetty.org
Expand Down
24 changes: 24 additions & 0 deletions lib/component-url-prefix-extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict'

const path = require('node:path/posix')

module.exports.register = function ({ config: { prefix = 'docs' } }) {
if ((prefix = path.join('.', prefix || '', '.')) === '.' || prefix === '..') return
this.once('contentClassified', ({ contentCatalog }) => {
contentCatalog.getComponents().filter(({ name }) => applyTo(name, prefix)).forEach(({ versions }) => {
versions.forEach((version) => {
version.url = `/${prefix}${version.url}`
})
})
contentCatalog.getFiles().filter((file) => file.out && applyTo(file.src.component, prefix)).forEach(({ out, pub }) => {
out.path = path.join((out.dirname = path.join(prefix, out.dirname)), out.basename)
out.rootPath = path.join('..', out.rootPath)
pub.url = `/${prefix}${pub.url}`
pub.rootPath = path.join('..', pub.rootPath)
})
})
}

function applyTo (name, prefix) {
return !(name === 'ROOT' || name === prefix)
}

0 comments on commit 5dfb344

Please sign in to comment.