@antora/content-classifier 3.0.0-beta.1 → 3.0.0-beta.5
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 +2 -2
- package/lib/content-catalog.js +26 -20
- package/package.json +3 -3
package/lib/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = Object.freeze({
|
|
4
|
-
|
|
5
|
-
|
|
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
|
})
|
package/lib/content-catalog.js
CHANGED
|
@@ -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 {
|
|
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(
|
|
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,15 +261,19 @@ class ContentCatalog {
|
|
|
261
261
|
}
|
|
262
262
|
let startPage
|
|
263
263
|
let startPageSrc
|
|
264
|
-
const indexPageId = {
|
|
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)) &&
|
|
268
268
|
(startPageSrc = startPage.src).component === name &&
|
|
269
269
|
startPageSrc.version === version
|
|
270
270
|
) {
|
|
271
|
-
if (
|
|
272
|
-
|
|
271
|
+
if (!this.getById(indexPageId)) {
|
|
272
|
+
const indexAliasId = Object.assign({}, ROOT_INDEX_ALIAS_ID, { component: name, version })
|
|
273
|
+
const indexAlias = this.getById(indexAliasId)
|
|
274
|
+
indexAlias
|
|
275
|
+
? indexAlias.synthetic && Object.assign(indexAlias, { rel: startPage })
|
|
276
|
+
: this.addFile({ src: indexAliasId, rel: startPage, synthetic: true })
|
|
273
277
|
}
|
|
274
278
|
} else {
|
|
275
279
|
// TODO pass componentVersion as logObject
|
|
@@ -312,7 +316,10 @@ class ContentCatalog {
|
|
|
312
316
|
if (!startPageSpec) return
|
|
313
317
|
const rel = this.resolvePage(startPageSpec)
|
|
314
318
|
if (rel) {
|
|
315
|
-
|
|
319
|
+
if (this.getById(ROOT_INDEX_PAGE_ID)) return
|
|
320
|
+
const indexAlias = this.getById(ROOT_INDEX_ALIAS_ID)
|
|
321
|
+
if (indexAlias) return indexAlias.synthetic ? Object.assign(indexAlias, { rel }) : undefined
|
|
322
|
+
return this.addFile({ src: Object.assign({}, ROOT_INDEX_ALIAS_ID), rel, synthetic: true })
|
|
316
323
|
} else if (rel === false) {
|
|
317
324
|
logger.warn('Start page specified for site has invalid syntax: %s', startPageSpec)
|
|
318
325
|
} else if (~startPageSpec.indexOf(':')) {
|
|
@@ -367,9 +374,10 @@ class ContentCatalog {
|
|
|
367
374
|
*
|
|
368
375
|
* Parses the specified contextual page ID spec into a page ID object, then attempts to lookup a
|
|
369
376
|
* 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
|
|
371
|
-
* the
|
|
372
|
-
*
|
|
377
|
+
* latest version of the component stored in the catalog is used. If a page cannot be resolved,
|
|
378
|
+
* the search is attempted again for an "alias". If neither a page or alias can be resolved, the
|
|
379
|
+
* function returns undefined. If the spec does not match the page ID syntax, this function throws
|
|
380
|
+
* an error.
|
|
373
381
|
*
|
|
374
382
|
* @param {String} spec - The contextual page ID spec (e.g., version@component:module:topic/page.adoc).
|
|
375
383
|
* @param {ContentCatalog} catalog - The content catalog in which to resolve the page file.
|
|
@@ -450,6 +458,7 @@ function prepareSrc (src) {
|
|
|
450
458
|
|
|
451
459
|
function computeOut (src, family, version, htmlUrlExtensionStyle) {
|
|
452
460
|
let { component, module: module_, basename, extname, relative, stem } = src
|
|
461
|
+
if (component === 'ROOT') component = ''
|
|
453
462
|
if (module_ === 'ROOT') module_ = ''
|
|
454
463
|
let indexifyPathSegment = ''
|
|
455
464
|
let familyPathSegment = ''
|
|
@@ -480,8 +489,11 @@ function computePub (src, out, family, version, htmlUrlExtensionStyle) {
|
|
|
480
489
|
const pub = {}
|
|
481
490
|
let url
|
|
482
491
|
if (family === 'nav') {
|
|
483
|
-
const
|
|
484
|
-
|
|
492
|
+
const component = src.component || 'ROOT'
|
|
493
|
+
const urlSegments = component === 'ROOT' ? [] : [component]
|
|
494
|
+
if (version) urlSegments.push(version)
|
|
495
|
+
const module_ = src.module || 'ROOT'
|
|
496
|
+
if (module_ !== 'ROOT') urlSegments.push(module_)
|
|
485
497
|
// an artificial URL used for resolving page references in navigation model
|
|
486
498
|
url = '/' + urlSegments.join('/') + '/'
|
|
487
499
|
pub.moduleRootPath = '.'
|
|
@@ -559,15 +571,9 @@ function createSymbolicVersionAlias (component, version, symbolicVersionSegment,
|
|
|
559
571
|
family
|
|
560
572
|
),
|
|
561
573
|
}
|
|
562
|
-
|
|
563
|
-
originalVersionAlias
|
|
564
|
-
|
|
565
|
-
return originalVersionAlias
|
|
566
|
-
} else {
|
|
567
|
-
symbolicVersionAlias.out = undefined
|
|
568
|
-
symbolicVersionAlias.rel = originalVersionAlias
|
|
569
|
-
return symbolicVersionAlias
|
|
570
|
-
}
|
|
574
|
+
return strategy === 'redirect:to'
|
|
575
|
+
? Object.assign(originalVersionAlias, { out: undefined, rel: symbolicVersionAlias })
|
|
576
|
+
: Object.assign(symbolicVersionAlias, { out: undefined, rel: originalVersionAlias })
|
|
571
577
|
}
|
|
572
578
|
|
|
573
579
|
function getFileLocation ({ path: path_, src: { abspath, origin } }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-classifier",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
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.
|
|
19
|
+
"@antora/logger": "3.0.0-beta.5",
|
|
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": "
|
|
37
|
+
"gitHead": "a13d03df41654d4deb78211a5a54953ce2a35fb8"
|
|
38
38
|
}
|