File tree Expand file tree Collapse file tree 7 files changed +119
-1
lines changed Expand file tree Collapse file tree 7 files changed +119
-1
lines changed Original file line number Diff line number Diff line change 2727 }
2828}
2929
30- a + .breadcrumbs {
30+ a + .breadcrumbs ,
31+ button + .breadcrumbs {
3132 padding-left : 0.05rem ;
3233}
3334
@@ -52,3 +53,27 @@ a + .breadcrumbs {
5253.breadcrumbs li : last-of-type ::after {
5354 content : none;
5455}
56+
57+ # copy-url {
58+ content : "" ;
59+ background-image : url(../ img/url.svg);
60+ background-repeat : no-repeat;
61+ background-size : contain;
62+ width : 20px ;
63+ height : 20px ;
64+ margin-right : 5px ;
65+ vertical-align : middle;
66+ display : inline-block;
67+ }
68+
69+ # copy-url .copied {
70+ background-image : url(../ img/octicons-16.svg#view-copy);
71+ }
72+
73+ # copy-url ::after {
74+ content : none;
75+ }
76+
77+ # copy-url : hover {
78+ cursor : pointer;
79+ }
Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ module . exports = ( siteUrl , versionSegment , url ) => {
4+ if ( ! url ) {
5+ // occurs with stock pages like 404.html
6+ return url
7+ } else if ( url . startsWith ( `/${ versionSegment } /` ) ) {
8+ return `${ siteUrl } ${ url } `
9+ } else {
10+ return `${ siteUrl } /${ versionSegment } ${ url } `
11+ }
12+ }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2021 the original author or authors.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the 'License');
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * https://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an 'AS IS' BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+ ; ( function ( ) {
17+ 'use strict'
18+
19+ var copyUrl = document . getElementById ( 'copy-url' )
20+ if ( ! copyUrl ) return
21+
22+ copyUrl . addEventListener ( 'click' , function ( event ) {
23+ var versionedUrl = document . querySelector ( 'meta[name="versioned-url"]' ) ?. content
24+ window . navigator . clipboard . writeText ( versionedUrl )
25+ this . classList . add ( 'copied' )
26+ setTimeout ( ( ) => {
27+ this . classList . remove ( 'copied' )
28+ } , 1500 )
29+ } )
30+ } ) ( )
Original file line number Diff line number Diff line change 22 <nav class =" breadcrumbs" aria-label =" breadcrumbs" >
33 {{ #if page.breadcrumbs }}
44 <ul >
5+ <li id =" copy-url" title =" Copy versioned URL" ></li >
56 {{ #with page.componentVersion }}
67 {{ #if (and ./title (ne ./title @root.page.breadcrumbs.0.content ))}}
78 <li ><a href =" {{{ relativize ./url }}} " >{{{ ./title }}} </a ></li >
Original file line number Diff line number Diff line change 22 <meta name =" antora-ui-version" content =" @@antora-ui-version" > {{!-- replaced by the gulp build --}}
33 <meta name =" version" content =" {{{ page.version }}} " >
44 <meta name =" generation" content =" {{{ page.componentVersion.versionSegment }}} " >
5+ <meta name =" versioned-url" content =" {{{ versioned_url site.url page.componentVersion.versionSegment page.url }}} " >
56 <meta name =" component" content =" {{{ page.component.name }}} " >
67 <meta name =" latest-version" content =" {{ ~#if (and page.latest (eq page.url page.latest.url ))}} true{{ ~else }} false{{ ~/if }} " >
Original file line number Diff line number Diff line change 1+ /* eslint-env mocha */
2+ 'use strict'
3+
4+ const { expect } = require ( './harness' )
5+ const versionedUrl = require ( '../src/helpers/versioned_url.js' )
6+
7+ describe ( 'versioned_url' , ( ) => {
8+ const siteUrl = 'https://docs.spring.io/spring-security/reference'
9+ const versionSegment = '7.0'
10+ const url = '/index.html'
11+ it ( 'when url does not contain version segment' , ( ) => {
12+ const result = versionedUrl ( siteUrl , versionSegment , url )
13+ expect ( result ) . is . eql ( 'https://docs.spring.io/spring-security/reference/7.0/index.html' )
14+ } )
15+ it ( 'when url does contain version segment' , ( ) => {
16+ const result = versionedUrl ( siteUrl , versionSegment , `/${ versionSegment } ${ url } ` )
17+ expect ( result ) . is . eql ( 'https://docs.spring.io/spring-security/reference/7.0/index.html' )
18+ } )
19+ it ( 'when url undefined' , ( ) => {
20+ // happens on 404.html
21+ const result = versionedUrl ( siteUrl , versionSegment , undefined )
22+ expect ( result ) . is . eql ( undefined )
23+ } )
24+ } )
You can’t perform that action at this time.
0 commit comments