Skip to content

Commit fadff8f

Browse files
committed
add page spec to meta data; add click event on Edit this Page link to copy it to clipboard
1 parent 48f7135 commit fadff8f

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

src/helpers/spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict'
2+
3+
module.exports = (page) => {
4+
const segments = []
5+
if (page.component.latest !== page.componentVersion) segments.push(`${page.version}@`)
6+
segments.push(`${page.component.name}:`)
7+
segments.push(page.module === 'ROOT' ? ':' : `${page.module}:`)
8+
segments.push(page.relativeSrcPath)
9+
return segments.join('')
10+
}

src/js/06-copy-page-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
;(function () {
2+
'use strict'
3+
4+
var editPageLink = document.querySelector('.toolbar .edit-this-page a')
5+
if (!editPageLink) return
6+
editPageLink.addEventListener('click', function (e) {
7+
if (e.altKey) navigator.clipboard.writeText(document.querySelector('head meta[name=page-spec]').content)
8+
})
9+
})()

src/partials/head-info.hbs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{{#with page.canonicalUrl}}
22
<link rel="canonical" href="{{{this}}}">
33
{{/with}}
4-
{{#unless (eq page.attributes.pagination undefined)}}
5-
{{#with page.previous}}
6-
<link rel="prev" href="{{{relativize ./url}}}">
7-
{{/with}}
8-
{{#with page.next}}
9-
<link rel="next" href="{{{relativize ./url}}}">
10-
{{/with}}
11-
{{/unless}}
4+
{{#if page.component}}
5+
<meta name="page-spec" content="{{spec page}}">
6+
{{/if}}
127
{{#with page.description}}
138
<meta name="description" content="{{this}}">
149
{{/with}}
@@ -18,3 +13,11 @@
1813
{{#with (or antoraVersion site.antoraVersion)}}
1914
<meta name="generator" content="Antora {{this}}">
2015
{{/with}}
16+
{{#unless (eq page.attributes.pagination undefined)}}
17+
{{#with page.previous}}
18+
<link rel="prev" href="{{{relativize ./url}}}">
19+
{{/with}}
20+
{{#with page.next}}
21+
<link rel="next" href="{{{relativize ./url}}}">
22+
{{/with}}
23+
{{/unless}}

0 commit comments

Comments
 (0)