File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 2
2
extensions :
3
3
- ./ext/asciidoctor-compliance-settings.js
4
4
- ./ext/promote-favicon-to-root.js
5
+ - ./ext/assign-project-url.js
5
6
- ./ext/page-location.js
6
7
runtime :
7
8
cache_dir : ./.cache/antora
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ module . exports . register = function ( ) {
4
+ // could switch this to componentsRegistered after upgrading to Antora 3.2
5
+ this . once ( 'contentClassified' , ( { siteAsciiDocConfig, contentCatalog } ) => {
6
+ contentCatalog . getComponents ( ) . forEach ( ( component ) => {
7
+ component . versions . forEach ( ( componentVersion ) => {
8
+ const componentVersionId = { component : component . name , version : componentVersion . version }
9
+ const componentVersionStartPage = contentCatalog . resolvePage ( 'index.adoc' , componentVersionId )
10
+ if ( ! componentVersionStartPage ) return
11
+ const { startPath, webUrl } = componentVersionStartPage . src . origin
12
+ if ( ! ( startPath === 'docs' && webUrl ) ) return
13
+ if ( componentVersion . asciidoc === siteAsciiDocConfig ) {
14
+ componentVersion . asciidoc = Object . assign (
15
+ { } ,
16
+ siteAsciiDocConfig ,
17
+ { attributes : Object . assign ( { } , siteAsciiDocConfig . attributes ) }
18
+ )
19
+ }
20
+ componentVersion . asciidoc . attributes [ 'page-project-url' ] = webUrl
21
+ componentVersion . asciidoc . attributes [ 'page-project-host' ] = ~ webUrl . indexOf ( 'gitlab' ) ? 'gitlab' : 'github'
22
+ } )
23
+ } )
24
+ } )
25
+ }
You can’t perform that action at this time.
0 commit comments