@antora/content-classifier 3.0.0-beta.1 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  module.exports = Object.freeze({
4
- START_ALIAS_ID: Object.freeze({ component: '', version: '', module: '', family: 'alias', relative: 'index.adoc' }),
5
- START_PAGE_ID: Object.freeze({ component: '', version: '', module: '', family: 'page', relative: 'index.adoc' }),
4
+ ROOT_INDEX_ALIAS_ID: { component: 'ROOT', version: '', module: 'ROOT', family: 'alias', relative: 'index.adoc' },
5
+ ROOT_INDEX_PAGE_ID: { component: 'ROOT', version: '', module: 'ROOT', family: 'page', relative: 'index.adoc' },
6
6
  })
@@ -9,7 +9,7 @@ const { posix: path } = require('path')
9
9
  const resolveResource = require('./util/resolve-resource')
10
10
  const versionCompare = require('./util/version-compare-desc')
11
11
 
12
- const { START_ALIAS_ID, START_PAGE_ID } = require('./constants')
12
+ const { ROOT_INDEX_ALIAS_ID, ROOT_INDEX_PAGE_ID } = require('./constants')
13
13
  const SPACE_RX = / /g
14
14
 
15
15
  const $components = Symbol('components')
@@ -249,7 +249,7 @@ class ContentCatalog {
249
249
 
250
250
  // TODO add `follow` argument to control whether alias is followed
251
251
  getSiteStartPage () {
252
- return this.getById(START_PAGE_ID) || (this.getById(START_ALIAS_ID) || {}).rel
252
+ return this.getById(ROOT_INDEX_PAGE_ID) || (this.getById(ROOT_INDEX_ALIAS_ID) || {}).rel
253
253
  }
254
254
 
255
255
  registerComponentVersionStartPage (name, componentVersion, startPageSpec = undefined) {
@@ -261,7 +261,7 @@ class ContentCatalog {
261
261
  }
262
262
  let startPage
263
263
  let startPageSrc
264
- const indexPageId = { component: name, version, module: 'ROOT', family: 'page', relative: 'index.adoc' }
264
+ const indexPageId = Object.assign({}, ROOT_INDEX_PAGE_ID, { component: name, version })
265
265
  if (startPageSpec) {
266
266
  if (
267
267
  (startPage = this.resolvePage(startPageSpec, indexPageId)) &&
@@ -312,7 +312,8 @@ class ContentCatalog {
312
312
  if (!startPageSpec) return
313
313
  const rel = this.resolvePage(startPageSpec)
314
314
  if (rel) {
315
- return this.addFile({ src: Object.assign({}, START_ALIAS_ID), rel })
315
+ if (!(this.getSiteStartPage() || { synthetic: true }).synthetic) return
316
+ return this.addFile({ src: Object.assign({}, ROOT_INDEX_ALIAS_ID), rel, synthetic: true })
316
317
  } else if (rel === false) {
317
318
  logger.warn('Start page specified for site has invalid syntax: %s', startPageSpec)
318
319
  } else if (~startPageSpec.indexOf(':')) {
@@ -367,9 +368,10 @@ class ContentCatalog {
367
368
  *
368
369
  * Parses the specified contextual page ID spec into a page ID object, then attempts to lookup a
369
370
  * file with this page ID in the catalog. If a component is specified, but not a version, the
370
- * latest version of the component stored in the catalog is used. If a file cannot be resolved,
371
- * the function returns undefined. If the spec does not match the page ID syntax, this function
372
- * throws an error.
371
+ * latest version of the component stored in the catalog is used. If a page cannot be resolved,
372
+ * the search is attempted again for an "alias". If neither a page or alias can be resolved, the
373
+ * function returns undefined. If the spec does not match the page ID syntax, this function throws
374
+ * an error.
373
375
  *
374
376
  * @param {String} spec - The contextual page ID spec (e.g., version@component:module:topic/page.adoc).
375
377
  * @param {ContentCatalog} catalog - The content catalog in which to resolve the page file.
@@ -450,6 +452,7 @@ function prepareSrc (src) {
450
452
 
451
453
  function computeOut (src, family, version, htmlUrlExtensionStyle) {
452
454
  let { component, module: module_, basename, extname, relative, stem } = src
455
+ if (component === 'ROOT') component = ''
453
456
  if (module_ === 'ROOT') module_ = ''
454
457
  let indexifyPathSegment = ''
455
458
  let familyPathSegment = ''
@@ -480,8 +483,11 @@ function computePub (src, out, family, version, htmlUrlExtensionStyle) {
480
483
  const pub = {}
481
484
  let url
482
485
  if (family === 'nav') {
483
- const urlSegments = version ? [src.component, version] : [src.component]
484
- if (src.module && src.module !== 'ROOT') urlSegments.push(src.module)
486
+ const component = src.component || 'ROOT'
487
+ const urlSegments = component === 'ROOT' ? [] : [component]
488
+ if (version) urlSegments.push(version)
489
+ const module_ = src.module || 'ROOT'
490
+ if (module_ !== 'ROOT') urlSegments.push(module_)
485
491
  // an artificial URL used for resolving page references in navigation model
486
492
  url = '/' + urlSegments.join('/') + '/'
487
493
  pub.moduleRootPath = '.'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/content-classifier",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "description": "Organizes aggregated content into a virtual file catalog for use in an Antora documentation pipeline.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "main": "lib/index.js",
18
18
  "dependencies": {
19
- "@antora/logger": "3.0.0-beta.1",
19
+ "@antora/logger": "3.0.0-beta.2",
20
20
  "mime-types": "~2.1",
21
21
  "vinyl": "~2.2"
22
22
  },
@@ -34,5 +34,5 @@
34
34
  "static site",
35
35
  "web publishing"
36
36
  ],
37
- "gitHead": "7c5ef1ea93dd489af533c80a936c736013c41769"
37
+ "gitHead": "5cd3f9cc70622e465cb44daf1aa2035ed5a35f54"
38
38
  }