@tenjuu99/blog 0.2.25 → 0.2.26
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/package.json
CHANGED
|
@@ -31,7 +31,17 @@ const transition = async (href) => {
|
|
|
31
31
|
document.body = doc.getElementsByTagName('body')[0]
|
|
32
32
|
// set header
|
|
33
33
|
document.title = doc.getElementsByTagName('title')[0].textContent
|
|
34
|
-
const canonical = document.head.querySelector('link[rel=canonical]')
|
|
34
|
+
const canonical = document.head.querySelector('link[rel=canonical]')
|
|
35
|
+
const newCanonical = doc.querySelector('link[rel=canonical]')
|
|
36
|
+
if (canonical) {
|
|
37
|
+
if (newCanonical) {
|
|
38
|
+
canonical.href = newCanonical.href
|
|
39
|
+
} else {
|
|
40
|
+
canonical.remove()
|
|
41
|
+
}
|
|
42
|
+
} else if (newCanonical) {
|
|
43
|
+
document.head.appendChild(newCanonical)
|
|
44
|
+
}
|
|
35
45
|
|
|
36
46
|
const metas = [...document.head.querySelectorAll('meta')]
|
|
37
47
|
metas.forEach(meta => {
|
|
@@ -53,13 +63,24 @@ const transition = async (href) => {
|
|
|
53
63
|
})
|
|
54
64
|
}
|
|
55
65
|
|
|
66
|
+
const urlFromHref = (href) => {
|
|
67
|
+
try {
|
|
68
|
+
return new URL(encodeURI(href))
|
|
69
|
+
} catch (e) {
|
|
70
|
+
console.log(`${href} is invalid`)
|
|
71
|
+
throw e
|
|
72
|
+
}
|
|
73
|
+
}
|
|
56
74
|
const turbolinks = () => {
|
|
57
75
|
const links = document.querySelectorAll('a')
|
|
58
|
-
const current =
|
|
76
|
+
const current = urlFromHref(document.location.href)
|
|
59
77
|
const currentDom = document.body
|
|
60
78
|
links.forEach(link => {
|
|
61
79
|
const href = link.href
|
|
62
|
-
|
|
80
|
+
if (!href.trim() || href.startsWith('javascript:') || link.dataset['turbolink'] === 'disable') {
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
const url = urlFromHref(href)
|
|
63
84
|
if (url.host === current.host) {
|
|
64
85
|
link.onclick = async (e) => {
|
|
65
86
|
e.preventDefault()
|
|
@@ -47,12 +47,6 @@
|
|
|
47
47
|
|
|
48
48
|
{include('template/prevNext.html')}
|
|
49
49
|
</main>
|
|
50
|
-
{if isEditorEnabled() }
|
|
51
|
-
<div class="container">
|
|
52
|
-
<a href="/editor?md={{name}}.{{__filetype}}" class="editor_link">編集する</a>
|
|
53
|
-
</div>
|
|
54
|
-
{/if}
|
|
55
|
-
|
|
56
50
|
{include('template/footer.html')}
|
|
57
51
|
{if add_script}
|
|
58
52
|
<script src="{{ADD_SCRIPT}}" async></script>
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
{if isEditorEnabled() }
|
|
2
|
+
<div class="container">
|
|
3
|
+
<a href="/editor?md={{name}}.{{__filetype}}" class="editor_link" data-turbolink="disable">編集する</a>
|
|
4
|
+
</div>
|
|
5
|
+
{/if}
|
|
6
|
+
|
|
7
|
+
<footer>
|
|
8
|
+
<ul class="container">
|
|
9
|
+
<li><a href="{{RELATIVE_PATH}}/about">about</a></li>
|
|
10
|
+
<li><a href="{{RELATIVE_PATH}}/privacy_policy">プライバシーポリシー</a></li>
|
|
11
|
+
<li><a href="{{RELATIVE_PATH}}/rss.xml">RSS</a></li>
|
|
12
|
+
</ul>
|
|
13
|
+
</footer>
|
|
8
14
|
|
|
9
15
|
{if turbolink}
|
|
10
16
|
<script>
|