@antora/asciidoc-loader
Advanced tools
Comparing version 1.0.0-beta.3 to 1.0.0-rc.1
@@ -55,8 +55,9 @@ 'use strict' | ||
} | ||
const fileSrc = file.src | ||
const intrinsicAttrs = { | ||
docname: file.src.stem, | ||
docname: fileSrc.stem, | ||
docfile: file.path, | ||
// NOTE docdir implicitly sets base_dir on document; Opal only expands value to absolute path if it starts with ./ | ||
docdir: file.dirname, | ||
docfilesuffix: file.src.extname, | ||
docfilesuffix: fileSrc.extname, | ||
imagesdir: path.join(file.pub.moduleRootPath, '_images'), | ||
@@ -67,3 +68,4 @@ attachmentsdir: path.join(file.pub.moduleRootPath, '_attachments'), | ||
} | ||
const attributes = Object.assign({}, envAttrs, defaultAttrs, config.attributes, intrinsicAttrs) | ||
const pageAttrs = fileSrc.family === 'page' ? computePageAttrs(fileSrc, contentCatalog) : {} | ||
const attributes = Object.assign({}, envAttrs, defaultAttrs, config.attributes, intrinsicAttrs, pageAttrs) | ||
const relativizePageRefs = config.relativizePageRefs !== false | ||
@@ -88,2 +90,28 @@ const converter = createConverter(asciidoctor, { | ||
function computePageAttrs (fileSrc, contentCatalog) { | ||
const attrs = {} | ||
// QUESTION should we soft set the page-id attribute? | ||
attrs['page-component-name'] = fileSrc.component | ||
attrs['page-component-version'] = fileSrc.version | ||
const component = contentCatalog && contentCatalog.getComponent(fileSrc.component) | ||
if (component) attrs['page-component-title'] = component.title | ||
attrs['page-module'] = fileSrc.module | ||
attrs['page-relative'] = fileSrc.relative | ||
const origin = fileSrc.origin | ||
if (origin) { | ||
attrs['page-origin-type'] = origin.type | ||
attrs['page-origin-url'] = origin.url | ||
attrs['page-origin-start-path'] = origin.startPath | ||
if (origin.branch) { | ||
attrs['page-origin-refname'] = attrs['page-origin-branch'] = origin.branch | ||
attrs['page-origin-reftype'] = 'branch' | ||
} else if (origin.tag) { | ||
attrs['page-origin-refname'] = attrs['page-origin-tag'] = origin.tag | ||
attrs['page-origin-reftype'] = 'tag' | ||
} | ||
if (origin.worktree) attrs['page-origin-worktree'] = '' | ||
} | ||
return attrs | ||
} | ||
/** | ||
@@ -90,0 +118,0 @@ * Resolves a global AsciiDoc configuration object from data in the playbook. |
{ | ||
"name": "@antora/asciidoc-loader", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-rc.1", | ||
"description": "Loads AsciiDoc content into an Asciidoctor Document object (AST) for use in an Antora documentation pipeline.", | ||
@@ -5,0 +5,0 @@ "license": "MPL-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23791
524