@antora/content-classifier 3.1.0 → 3.2.0-alpha.1
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/classify-content.js +3 -4
- package/lib/content-catalog.js +121 -98
- package/lib/util/resolve-resource.js +1 -1
- package/package.json +3 -3
package/lib/classify-content.js
CHANGED
|
@@ -21,10 +21,9 @@ function classifyContent (playbook, aggregate, siteAsciiDocConfig = {}) {
|
|
|
21
21
|
const contentCatalog = new ContentCatalog(playbook)
|
|
22
22
|
aggregate
|
|
23
23
|
.reduce((accum, componentVersionData) => {
|
|
24
|
-
const { name, version } = componentVersionData
|
|
25
|
-
// drop startPage to defer registration of start page
|
|
26
24
|
// drop files since they aren't needed to register component version
|
|
27
|
-
|
|
25
|
+
// drop startPage to defer registration of start page
|
|
26
|
+
const { name, version, files, startPage, ...descriptor } = Object.assign({}, componentVersionData, {
|
|
28
27
|
asciidoc: resolveAsciiDocConfig(siteAsciiDocConfig, componentVersionData),
|
|
29
28
|
})
|
|
30
29
|
return new Map(accum).set(
|
|
@@ -36,7 +35,7 @@ function classifyContent (playbook, aggregate, siteAsciiDocConfig = {}) {
|
|
|
36
35
|
const { name, version } = componentVersion
|
|
37
36
|
const { files, nav, startPage } = componentVersionData
|
|
38
37
|
componentVersionData.files = undefined // clean up memory
|
|
39
|
-
files.forEach((file) => allocateSrc(file, name, version, nav) && contentCatalog.addFile(file))
|
|
38
|
+
files.forEach((file) => allocateSrc(file, name, version, nav) && contentCatalog.addFile(file, componentVersion))
|
|
40
39
|
contentCatalog.registerComponentVersionStartPage(name, componentVersion, startPage)
|
|
41
40
|
})
|
|
42
41
|
contentCatalog.registerSiteStartPage(playbook.site.startPage)
|
package/lib/content-catalog.js
CHANGED
|
@@ -23,17 +23,17 @@ class ContentCatalog {
|
|
|
23
23
|
const urls = playbook.urls || {}
|
|
24
24
|
this.htmlUrlExtensionStyle = urls.htmlExtensionStyle || 'default'
|
|
25
25
|
this.urlRedirectFacility = urls.redirectFacility || 'static'
|
|
26
|
-
this.
|
|
27
|
-
this.
|
|
28
|
-
if (this.
|
|
29
|
-
this.
|
|
26
|
+
this.latestVersionSegment = urls.latestVersionSegment
|
|
27
|
+
this.latestPrereleaseVersionSegment = urls.latestPrereleaseVersionSegment
|
|
28
|
+
if (this.latestVersionSegment == null && this.latestPrereleaseVersionSegment == null) {
|
|
29
|
+
this.latestVersionSegmentStrategy = undefined
|
|
30
30
|
} else {
|
|
31
|
-
this.
|
|
32
|
-
if (this.
|
|
33
|
-
if (!this.
|
|
34
|
-
if (!this.
|
|
35
|
-
this.
|
|
36
|
-
if (!this.
|
|
31
|
+
this.latestVersionSegmentStrategy = urls.latestVersionSegmentStrategy || 'replace'
|
|
32
|
+
if (this.latestVersionSegmentStrategy === 'redirect:from') {
|
|
33
|
+
if (!this.latestVersionSegment) this.latestVersionSegment = undefined
|
|
34
|
+
if (!this.latestPrereleaseVersionSegment) {
|
|
35
|
+
this.latestPrereleaseVersionSegment = undefined
|
|
36
|
+
if (!this.latestVersionSegment) this.latestVersionSegmentStrategy = undefined
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -54,10 +54,13 @@ class ContentCatalog {
|
|
|
54
54
|
* component version. A true value is a special case to tell this method to register the default start page and is
|
|
55
55
|
* intended for testing.
|
|
56
56
|
* @param {String} [descriptor.title=name] - The title for this component version.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Object} The constructed component version object.
|
|
57
59
|
*/
|
|
58
60
|
registerComponentVersion (name, version, descriptor = {}) {
|
|
59
|
-
const { asciidoc, displayVersion, prerelease, startPage: startPageSpec, title } = descriptor
|
|
61
|
+
const { asciidoc, displayVersion, prerelease, startPage: startPageSpec, title, versionSegment } = descriptor
|
|
60
62
|
const componentVersion = { displayVersion: displayVersion || version || 'default', title: title || name, version }
|
|
63
|
+
if (versionSegment != null) componentVersion.versionSegment = versionSegment
|
|
61
64
|
Object.defineProperty(componentVersion, 'name', { value: name, enumerable: true })
|
|
62
65
|
if (prerelease) {
|
|
63
66
|
componentVersion.prerelease = prerelease
|
|
@@ -125,14 +128,15 @@ class ContentCatalog {
|
|
|
125
128
|
)
|
|
126
129
|
}
|
|
127
130
|
if (startPageSpec) {
|
|
131
|
+
// @deprecated use separate call to register start page for component version
|
|
128
132
|
this.registerComponentVersionStartPage(name, componentVersion, startPageSpec === true ? undefined : startPageSpec)
|
|
129
133
|
}
|
|
130
134
|
return componentVersion
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
addFile (file) {
|
|
137
|
+
addFile (file, componentVersion) {
|
|
134
138
|
const src = file.src
|
|
135
|
-
let family = src
|
|
139
|
+
let { component, version, family } = src
|
|
136
140
|
let filesForFamily = this[$files].get(family)
|
|
137
141
|
if (!filesForFamily) this[$files].set(family, (filesForFamily = new Map()))
|
|
138
142
|
const key = generateKey(src)
|
|
@@ -144,7 +148,7 @@ class ContentCatalog {
|
|
|
144
148
|
.map((it, idx) => `${idx + 1}: ${getFileLocation(it)}`)
|
|
145
149
|
.join(LOG_WRAP)
|
|
146
150
|
if (family === 'nav') {
|
|
147
|
-
throw new Error(`Duplicate nav in ${
|
|
151
|
+
throw new Error(`Duplicate nav in ${version}@${component}: ${file.path}${LOG_WRAP}${details}`)
|
|
148
152
|
} else {
|
|
149
153
|
throw new Error(`Duplicate ${family}: ${generateResourceSpec(src)}${LOG_WRAP}${details}`)
|
|
150
154
|
}
|
|
@@ -160,16 +164,18 @@ class ContentCatalog {
|
|
|
160
164
|
file = new File(file)
|
|
161
165
|
}
|
|
162
166
|
if (family === 'alias') {
|
|
163
|
-
src.mediaType = 'text/asciidoc'
|
|
164
167
|
file.mediaType = 'text/html'
|
|
165
168
|
// NOTE: an alias masquerades as the target file
|
|
166
169
|
family = file.rel.src.family
|
|
167
|
-
//
|
|
170
|
+
// NOTE: short circuit in case of splat alias (alias -> alias)
|
|
171
|
+
if (family === 'alias' && (file.pub || {}).splat) return filesForFamily.set(key, file) && file
|
|
172
|
+
src.mediaType = 'text/asciidoc'
|
|
168
173
|
} else if (!(file.mediaType = src.mediaType) && !('mediaType' in src)) {
|
|
174
|
+
// QUESTION: should we preserve the mediaType property on file if already defined?
|
|
169
175
|
file.mediaType = src.mediaType = resolveMimeType(src.extname) || (family === 'page' ? 'text/asciidoc' : undefined)
|
|
170
176
|
}
|
|
171
177
|
let publishable
|
|
172
|
-
let
|
|
178
|
+
let activeVersionSegment
|
|
173
179
|
if (file.out) {
|
|
174
180
|
publishable = true
|
|
175
181
|
} else if ('out' in file) {
|
|
@@ -179,15 +185,18 @@ class ContentCatalog {
|
|
|
179
185
|
('/' + src.relative).indexOf('/_') < 0
|
|
180
186
|
) {
|
|
181
187
|
publishable = true
|
|
182
|
-
|
|
183
|
-
|
|
188
|
+
if (componentVersion == null) componentVersion = this.getComponentVersion(component, version) || { version }
|
|
189
|
+
activeVersionSegment = computeVersionSegment.call(this, componentVersion)
|
|
190
|
+
file.out = computeOut(src, family, activeVersionSegment, this.htmlUrlExtensionStyle)
|
|
184
191
|
}
|
|
185
192
|
if (!file.pub && (publishable || family === 'nav')) {
|
|
186
|
-
if (
|
|
187
|
-
|
|
193
|
+
if (activeVersionSegment == null) {
|
|
194
|
+
if (componentVersion == null) componentVersion = this.getComponentVersion(component, version) || { version }
|
|
195
|
+
activeVersionSegment = computeVersionSegment.call(this, componentVersion)
|
|
196
|
+
}
|
|
197
|
+
file.pub = computePub(src, file.out, family, activeVersionSegment, this.htmlUrlExtensionStyle)
|
|
188
198
|
}
|
|
189
|
-
filesForFamily.set(key, file)
|
|
190
|
-
return file
|
|
199
|
+
return filesForFamily.set(key, file) && file
|
|
191
200
|
}
|
|
192
201
|
|
|
193
202
|
removeFile (file) {
|
|
@@ -269,34 +278,36 @@ class ContentCatalog {
|
|
|
269
278
|
}
|
|
270
279
|
|
|
271
280
|
registerComponentVersionStartPage (name, componentVersion, startPageSpec = undefined) {
|
|
281
|
+
const component = name
|
|
272
282
|
let version = componentVersion.version
|
|
273
283
|
if (version == null) {
|
|
274
284
|
// QUESTION: should we warn or throw error if component version cannot be found?
|
|
275
|
-
if (!(componentVersion = this.getComponentVersion(
|
|
285
|
+
if (!(componentVersion = this.getComponentVersion(component, componentVersion))) return
|
|
276
286
|
version = componentVersion.version
|
|
277
287
|
}
|
|
288
|
+
const activeVersionSegment = computeVersionSegment.call(this, componentVersion)
|
|
278
289
|
let startPage
|
|
279
290
|
let startPageSrc
|
|
280
|
-
const indexPageId = Object.assign({}, ROOT_INDEX_PAGE_ID, { component
|
|
291
|
+
const indexPageId = Object.assign({}, ROOT_INDEX_PAGE_ID, { component, version })
|
|
281
292
|
if (startPageSpec) {
|
|
282
293
|
if (
|
|
283
294
|
(startPage = this.resolvePage(startPageSpec, indexPageId)) &&
|
|
284
|
-
(startPageSrc = startPage.src).component ===
|
|
295
|
+
(startPageSrc = startPage.src).component === component &&
|
|
285
296
|
startPageSrc.version === version
|
|
286
297
|
) {
|
|
287
298
|
if (!this.getById(indexPageId)) {
|
|
288
|
-
const indexAliasId = Object.assign({}, ROOT_INDEX_ALIAS_ID, { component
|
|
299
|
+
const indexAliasId = Object.assign({}, ROOT_INDEX_ALIAS_ID, { component, version })
|
|
289
300
|
const indexAlias = this.getById(indexAliasId)
|
|
290
301
|
indexAlias
|
|
291
302
|
? indexAlias.synthetic && Object.assign(indexAlias, { rel: startPage })
|
|
292
|
-
: this.addFile({ src: indexAliasId, rel: startPage, synthetic: true })
|
|
303
|
+
: this.addFile({ src: indexAliasId, rel: startPage, synthetic: true }, componentVersion)
|
|
293
304
|
}
|
|
294
305
|
} else {
|
|
295
306
|
// TODO pass componentVersion as logObject
|
|
296
307
|
logger.warn(
|
|
297
308
|
'Start page specified for %s@%s %s: %s',
|
|
298
309
|
version,
|
|
299
|
-
|
|
310
|
+
component,
|
|
300
311
|
startPage === false ? 'has invalid syntax' : 'not found',
|
|
301
312
|
startPageSpec
|
|
302
313
|
)
|
|
@@ -309,23 +320,29 @@ class ContentCatalog {
|
|
|
309
320
|
componentVersion.url = startPage.pub.url
|
|
310
321
|
} else {
|
|
311
322
|
// QUESTION: should we warn if the default start page cannot be found?
|
|
312
|
-
const versionSegment = computeVersionSegment.call(this, name, version)
|
|
313
323
|
componentVersion.url = computePub(
|
|
314
324
|
(startPageSrc = prepareSrc(Object.assign({}, indexPageId, { family: 'page' }))),
|
|
315
|
-
computeOut(startPageSrc, startPageSrc.family,
|
|
325
|
+
computeOut(startPageSrc, startPageSrc.family, activeVersionSegment, this.htmlUrlExtensionStyle),
|
|
316
326
|
startPageSrc.family,
|
|
317
|
-
|
|
327
|
+
activeVersionSegment,
|
|
318
328
|
this.htmlUrlExtensionStyle
|
|
319
329
|
).url
|
|
320
330
|
}
|
|
321
331
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
332
|
+
Object.defineProperty(
|
|
333
|
+
componentVersion,
|
|
334
|
+
'activeVersionSegment',
|
|
335
|
+
activeVersionSegment === version
|
|
336
|
+
? {
|
|
337
|
+
configurable: true,
|
|
338
|
+
get () {
|
|
339
|
+
return this.version
|
|
340
|
+
},
|
|
341
|
+
}
|
|
342
|
+
: { configurable: true, value: activeVersionSegment }
|
|
327
343
|
)
|
|
328
|
-
|
|
344
|
+
|
|
345
|
+
addSymbolicVersionAlias.call(this, componentVersion)
|
|
329
346
|
}
|
|
330
347
|
|
|
331
348
|
registerSiteStartPage (startPageSpec) {
|
|
@@ -335,7 +352,8 @@ class ContentCatalog {
|
|
|
335
352
|
if (this.getById(ROOT_INDEX_PAGE_ID)) return
|
|
336
353
|
const indexAlias = this.getById(ROOT_INDEX_ALIAS_ID)
|
|
337
354
|
if (indexAlias) return indexAlias.synthetic ? Object.assign(indexAlias, { rel }) : undefined
|
|
338
|
-
|
|
355
|
+
const src = Object.assign({}, ROOT_INDEX_ALIAS_ID)
|
|
356
|
+
return this.addFile({ src, rel, synthetic: true }, { version: src.version })
|
|
339
357
|
} else if (rel === false) {
|
|
340
358
|
logger.warn('Start page specified for site has invalid syntax: %s', startPageSpec)
|
|
341
359
|
} else if (startPageSpec.lastIndexOf(':') > startPageSpec.indexOf(':')) {
|
|
@@ -353,9 +371,14 @@ class ContentCatalog {
|
|
|
353
371
|
// QUESTION should we throw an error if alias is invalid?
|
|
354
372
|
if (!src || (inferredSpec && src.relative === '.adoc')) return
|
|
355
373
|
const component = this.getComponent(src.component)
|
|
374
|
+
let componentVersion
|
|
356
375
|
if (component) {
|
|
357
376
|
// NOTE version is not set when alias specifies a component, but not a version
|
|
358
|
-
if (src.version == null)
|
|
377
|
+
if (src.version == null) {
|
|
378
|
+
src.version = (componentVersion = component.latest).version
|
|
379
|
+
} else {
|
|
380
|
+
componentVersion = this.getComponentVersion(component, src.version)
|
|
381
|
+
}
|
|
359
382
|
const existingPage = this.getById(src)
|
|
360
383
|
if (existingPage) {
|
|
361
384
|
throw new Error(
|
|
@@ -380,12 +403,34 @@ class ContentCatalog {
|
|
|
380
403
|
)
|
|
381
404
|
}
|
|
382
405
|
// NOTE the redirect producer will populate contents when the redirect facility is 'static'
|
|
383
|
-
const alias = this.addFile({ src, rel: target })
|
|
406
|
+
const alias = this.addFile({ src, rel: target }, componentVersion)
|
|
384
407
|
// NOTE record the first alias this target claims as the preferred one
|
|
385
408
|
if (!target.rel) target.rel = alias
|
|
386
409
|
return alias
|
|
387
410
|
}
|
|
388
411
|
|
|
412
|
+
/**
|
|
413
|
+
* Adds a splat (directory) alias from the specified version segment in one component to the specified
|
|
414
|
+
* version segment in the same or different component.
|
|
415
|
+
*
|
|
416
|
+
* @returns {File} The virtual file that represents the splat alias.
|
|
417
|
+
*/
|
|
418
|
+
addSplatAlias (from, to) {
|
|
419
|
+
if (!from.versionSegment) throw new Error('cannot map splat alias from empty version segment')
|
|
420
|
+
const family = 'alias'
|
|
421
|
+
const baseSrc = { module: 'ROOT', family, relative: '', basename: '', stem: '', extname: '' }
|
|
422
|
+
const basePub = { splat: true }
|
|
423
|
+
const { component: fromComponent = to.component, versionSegment: fromVersionSegment } = from
|
|
424
|
+
const fromSrc = Object.assign({ component: fromComponent, version: fromVersionSegment }, baseSrc)
|
|
425
|
+
const fromPub = Object.assign(computePub(fromSrc, computeOut(fromSrc, family, fromVersionSegment), family), basePub)
|
|
426
|
+
const { component: toComponent, version: toVersion } = to
|
|
427
|
+
const toVersionSegment =
|
|
428
|
+
to.versionSegment ?? this.getComponentVersion(toComponent, toVersion)?.activeVersionSegment ?? toVersion
|
|
429
|
+
const toSrc = Object.assign({ component: toComponent, version: toVersion ?? toVersionSegment }, baseSrc)
|
|
430
|
+
const toPub = Object.assign(computePub(toSrc, computeOut(toSrc, family, toVersionSegment), family), basePub)
|
|
431
|
+
return this.addFile({ pub: fromPub, src: fromSrc, rel: { pub: toPub, src: toSrc } })
|
|
432
|
+
}
|
|
433
|
+
|
|
389
434
|
/**
|
|
390
435
|
* Attempts to resolve a string contextual page ID spec to a file in the catalog.
|
|
391
436
|
*
|
|
@@ -400,7 +445,7 @@ class ContentCatalog {
|
|
|
400
445
|
* @param {ContentCatalog} catalog - The content catalog in which to resolve the page file.
|
|
401
446
|
* @param {Object} [ctx={}] - The context to use to qualified the contextual page ID.
|
|
402
447
|
*
|
|
403
|
-
* @
|
|
448
|
+
* @returns {File} The virtual file to which the contextual page ID spec refers, or undefined if the
|
|
404
449
|
* file cannot be resolved.
|
|
405
450
|
*/
|
|
406
451
|
resolvePage (spec, context = {}) {
|
|
@@ -473,7 +518,7 @@ function prepareSrc (src) {
|
|
|
473
518
|
return update ? Object.assign(src, { basename, extname, stem }) : src
|
|
474
519
|
}
|
|
475
520
|
|
|
476
|
-
function computeOut (src, family,
|
|
521
|
+
function computeOut (src, family, versionSegment, htmlUrlExtensionStyle) {
|
|
477
522
|
let { component, module: module_, basename, extname, relative, stem } = src
|
|
478
523
|
if (component === 'ROOT') component = ''
|
|
479
524
|
if (module_ === 'ROOT') module_ = ''
|
|
@@ -493,7 +538,7 @@ function computeOut (src, family, version, htmlUrlExtensionStyle) {
|
|
|
493
538
|
familyPathSegment = '_attachments'
|
|
494
539
|
}
|
|
495
540
|
|
|
496
|
-
const modulePath = path.join(component,
|
|
541
|
+
const modulePath = path.join(component, versionSegment, module_)
|
|
497
542
|
const dirname = path.join(modulePath, familyPathSegment, path.dirname(relative), indexifyPathSegment)
|
|
498
543
|
const path_ = path.join(dirname, basename)
|
|
499
544
|
const moduleRootPath = path.relative(dirname, modulePath) || '.'
|
|
@@ -502,13 +547,13 @@ function computeOut (src, family, version, htmlUrlExtensionStyle) {
|
|
|
502
547
|
return { dirname, basename, path: path_, moduleRootPath, rootPath }
|
|
503
548
|
}
|
|
504
549
|
|
|
505
|
-
function computePub (src, out, family,
|
|
550
|
+
function computePub (src, out, family, versionSegment, htmlUrlExtensionStyle) {
|
|
506
551
|
const pub = {}
|
|
507
552
|
let url
|
|
508
553
|
if (family === 'nav') {
|
|
509
554
|
const component = src.component || 'ROOT'
|
|
510
555
|
const urlSegments = component === 'ROOT' ? [] : [component]
|
|
511
|
-
if (
|
|
556
|
+
if (versionSegment) urlSegments.push(versionSegment)
|
|
512
557
|
const module_ = src.module || 'ROOT'
|
|
513
558
|
if (module_ !== 'ROOT') urlSegments.push(module_)
|
|
514
559
|
if (urlSegments.length) urlSegments.push('')
|
|
@@ -527,71 +572,49 @@ function computePub (src, out, family, version, htmlUrlExtensionStyle) {
|
|
|
527
572
|
urlSegments[lastUrlSegmentIdx] = ''
|
|
528
573
|
}
|
|
529
574
|
url = '/' + urlSegments.join('/')
|
|
530
|
-
} else {
|
|
531
|
-
|
|
532
|
-
if (family === 'alias' && !src.relative) pub.splat = true
|
|
575
|
+
} else if ((url = '/' + out.path) === '/.') {
|
|
576
|
+
url = '/'
|
|
533
577
|
}
|
|
534
|
-
|
|
535
578
|
pub.url = ~url.indexOf(' ') ? url.replace(SPACE_RX, '%20') : url
|
|
579
|
+
return out ? Object.assign(pub, { moduleRootPath: out.moduleRootPath, rootPath: out.rootPath }) : pub
|
|
580
|
+
}
|
|
536
581
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
582
|
+
function addSymbolicVersionAlias (componentVersion) {
|
|
583
|
+
const { name: component, version } = componentVersion
|
|
584
|
+
const originalVersionSegment = computeVersionSegment.call(this, componentVersion, 'original')
|
|
585
|
+
const symbolicVersionSegment = computeVersionSegment.call(this, componentVersion, 'alias')
|
|
586
|
+
if (symbolicVersionSegment === originalVersionSegment || symbolicVersionSegment == null) return
|
|
587
|
+
const originalVersionSrc = { component, version, versionSegment: originalVersionSegment }
|
|
588
|
+
const symbolicVersionSrc = { component, version, versionSegment: symbolicVersionSegment }
|
|
589
|
+
return this.latestVersionSegmentStrategy === 'redirect:to'
|
|
590
|
+
? this.addSplatAlias(originalVersionSrc, symbolicVersionSrc)
|
|
591
|
+
: this.addSplatAlias(symbolicVersionSrc, originalVersionSrc)
|
|
543
592
|
}
|
|
544
593
|
|
|
545
|
-
function computeVersionSegment (
|
|
594
|
+
function computeVersionSegment (componentVersion, mode) {
|
|
595
|
+
const version = componentVersion.version
|
|
546
596
|
// special designation for master verson is @deprecated; special designation scheduled to be removed in Antora 4
|
|
547
|
-
|
|
548
|
-
const
|
|
549
|
-
if (
|
|
550
|
-
|
|
597
|
+
const normalizedVersion = version && version !== 'master' ? version : ''
|
|
598
|
+
const { versionSegment = normalizedVersion } = componentVersion
|
|
599
|
+
if (mode === 'original') return versionSegment
|
|
600
|
+
const strategy = this.latestVersionSegmentStrategy
|
|
601
|
+
if (!versionSegment) {
|
|
602
|
+
if (!mode) return ''
|
|
551
603
|
if (strategy === 'redirect:to') return
|
|
552
604
|
}
|
|
553
|
-
if (strategy === 'redirect:to' || strategy === (mode
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
const segment =
|
|
605
|
+
if (strategy === 'redirect:to' || strategy === (mode ? 'redirect:from' : 'replace')) {
|
|
606
|
+
let component
|
|
607
|
+
if ((component = 'name' in componentVersion && this.getComponent(componentVersion.name))) {
|
|
608
|
+
const latestSegment =
|
|
558
609
|
componentVersion === component.latest
|
|
559
|
-
? this.
|
|
610
|
+
? this.latestVersionSegment
|
|
560
611
|
: componentVersion === component.latestPrerelease
|
|
561
|
-
? this.
|
|
612
|
+
? this.latestPrereleaseVersionSegment
|
|
562
613
|
: undefined
|
|
563
|
-
return
|
|
614
|
+
return latestSegment == null ? versionSegment : latestSegment
|
|
564
615
|
}
|
|
565
616
|
}
|
|
566
|
-
return
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
function createSymbolicVersionAlias (component, version, symbolicVersionSegment, strategy) {
|
|
570
|
-
if (symbolicVersionSegment == null || symbolicVersionSegment === version) return
|
|
571
|
-
const family = 'alias'
|
|
572
|
-
const baseVersionAliasSrc = { component, module: 'ROOT', family, relative: '', basename: '', stem: '', extname: '' }
|
|
573
|
-
const symbolicVersionAliasSrc = Object.assign({}, baseVersionAliasSrc, { version: symbolicVersionSegment })
|
|
574
|
-
const symbolicVersionAlias = {
|
|
575
|
-
src: symbolicVersionAliasSrc,
|
|
576
|
-
pub: computePub(
|
|
577
|
-
symbolicVersionAliasSrc,
|
|
578
|
-
computeOut(symbolicVersionAliasSrc, family, symbolicVersionSegment),
|
|
579
|
-
family
|
|
580
|
-
),
|
|
581
|
-
}
|
|
582
|
-
const originalVersionAliasSrc = Object.assign({}, baseVersionAliasSrc, { version })
|
|
583
|
-
const originalVersionSegment = computeVersionSegment(component, version, 'original')
|
|
584
|
-
const originalVersionAlias = {
|
|
585
|
-
src: originalVersionAliasSrc,
|
|
586
|
-
pub: computePub(
|
|
587
|
-
originalVersionAliasSrc,
|
|
588
|
-
computeOut(originalVersionAliasSrc, family, originalVersionSegment),
|
|
589
|
-
family
|
|
590
|
-
),
|
|
591
|
-
}
|
|
592
|
-
return strategy === 'redirect:to'
|
|
593
|
-
? Object.assign(originalVersionAlias, { out: undefined, rel: symbolicVersionAlias })
|
|
594
|
-
: Object.assign(symbolicVersionAlias, { out: undefined, rel: originalVersionAlias })
|
|
617
|
+
return versionSegment
|
|
595
618
|
}
|
|
596
619
|
|
|
597
620
|
function getFileLocation ({ path: path_, src: { abspath, origin } }) {
|
|
@@ -21,7 +21,7 @@ const parseResourceId = require('./parse-resource-id')
|
|
|
21
21
|
* The value "page" is used if not specified. This value is always used instead of family value provided by the ctx.
|
|
22
22
|
* @param {Array<String>} [permittedFamilies=undefined] - An optional array of family names to allow.
|
|
23
23
|
*
|
|
24
|
-
* @
|
|
24
|
+
* @returns {File} The virtual file to which the contextual resource ID spec refers, undefined if
|
|
25
25
|
* the file cannot be resolved, or false if the resource ID spec is invalid.
|
|
26
26
|
*/
|
|
27
27
|
function resolveResource (spec, catalog, ctx = {}, defaultFamily = undefined, permittedFamilies = undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antora/content-classifier",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-alpha.1",
|
|
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)",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"#constants": "./lib/constants.js"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@antora/asciidoc-loader": "3.
|
|
31
|
-
"@antora/logger": "3.
|
|
30
|
+
"@antora/asciidoc-loader": "3.2.0-alpha.1",
|
|
31
|
+
"@antora/logger": "3.2.0-alpha.1",
|
|
32
32
|
"mime-types": "~2.1",
|
|
33
33
|
"vinyl": "~2.2"
|
|
34
34
|
},
|