Skip to content

Commit

Permalink
Page layout support
Browse files Browse the repository at this point in the history
  • Loading branch information
philwebb committed Jun 21, 2024
1 parent 8e24a87 commit 2ba4972
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
17 changes: 17 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,23 @@ ext:
path: api/java
----

By default, content will be added using a 'bare' page layout which is supported regardless of the UI bundle you use.
To specify a different page layout, you can use the `layout` attribute:

.antora.yml
[,yaml]
----
name: my-project
version: true
# ...
ext:
zip_contents_collector:
include:
- name: api
destination: content_catalog
layout: custom
----



=== Using the Playbook to Include Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -483,14 +483,15 @@ function register ({ config, downloadLog }) {

function addToContentCatalog (contentCatalog, component, version, include, zipFile, file) {
const moduleName = include.module || 'ROOT'
const pageLayout = include.layout || 'bare'
file = asAntoraFile(include, zipFile, file, include.path, 'application/octet-stream', {
component: component.name,
version: version.version,
module: moduleName,
family: 'page',
})
const pageAttributes = {
'page-layout': 'bare',
'page-layout': pageLayout,
'page-component-name': component.name,
'page-component-version': version.version,
'page-version': version.version,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ describe('zip contents collector extension', () => {
expect(src.module).to.be.equal('ROOT')
expect(src.family).to.be.equal('page')
expect(src.component).to.be.equal('test')
const htmlFile = files.filter((file) => file.src.path === 'api/java/javadoc.html')[0]
expect(htmlFile.asciidoc.attributes['page-layout']).to.be.equal('bare')
},
})
})
Expand Down Expand Up @@ -782,6 +784,34 @@ describe('zip contents collector extension', () => {
})
})

it('should download zip and collect files when adding to content catalog with layout', async () => {
const extensionConfig = () => ({
locations: [{ url: `http://localhost:${httpServerPort}/\${name}.zip` }],
})
const componentConfig = {
include: [{ name: 'javadoc', destination: 'content_catalog', path: 'api/java', layout: 'javadoc' }],
}
await runScenario({
repoName: 'test-at-root',
extensionConfig,
componentConfig,
zipFiles: ['javadoc'],
httpPath: '/',
descriptorVersion: 'main',
before: ({ contentAggregate, contentCatalog }) => {
expect(contentAggregate).to.have.lengthOf(1)
expect(contentAggregate[0].files).to.be.empty()
},
after: ({ contentAggregate, contentCatalog }) => {
expect(contentAggregate[0].files).to.have.lengthOf(0)
const files = contentCatalog.getFiles()
expect(files.filter((file) => file.src.path === 'api/java/javadoc.html')).to.have.lengthOf(1)
const htmlFile = files.filter((file) => file.src.path === 'api/java/javadoc.html')[0]
expect(htmlFile.asciidoc.attributes['page-layout']).to.be.equal('javadoc')
},
})
})

it('should create dedicated cache folder for collector under Antora cache dir', async () => {
await fsp.mkdir(CACHE_DIR, { recursive: true })
await fsp.writeFile(getCollectorCacheDir(), Buffer.alloc(0))
Expand Down

0 comments on commit 2ba4972

Please sign in to comment.