@tenjuu99/blog 0.2.45 → 0.2.47

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.
@@ -15,6 +15,7 @@ const contentTypes = {
15
15
  'xml': 'application/xml',
16
16
  'rdf': 'application/rdf+xml',
17
17
  'rss': 'application/rss+xml',
18
+ 'pdf': 'application/pdf',
18
19
  }
19
20
 
20
21
  const contentType = (ext) => {
package/lib/pageData.js CHANGED
@@ -26,6 +26,7 @@ const parse = (content, name, ext) => {
26
26
  description: '',
27
27
  og_description: '',
28
28
  published: '1970-01-01',
29
+ preview: false,
29
30
  index: true,
30
31
  noindex: false,
31
32
  lang: 'ja',
@@ -46,6 +47,11 @@ const parse = (content, name, ext) => {
46
47
  }
47
48
  const metaData = parseMetaData(matched.groups.variables)
48
49
  const metaDataMerged = Object.assign(metaDataDefault, metaData)
50
+ if (metaDataMerged.preview) {
51
+ metaDataMerged.index = false
52
+ metaDataMerged.noindex = true
53
+ metaDataMerged.url = metaDataMerged.url + '/preview'
54
+ }
49
55
  metaDataMerged.full_url = fullUrl(metaDataMerged)
50
56
  metaDataMerged['__output'] = name === 'index' ? '/index.html' : `${metaDataMerged.url}.${metaDataMerged.ext}`
51
57
 
@@ -58,7 +64,7 @@ const parseMetaData = (data) => {
58
64
  let key, value
59
65
  for (const line of data.split('\n')) {
60
66
  if (!isStringContinue) {
61
- const match = line.match(/^([a-zA-Z_]+):/)
67
+ const match = line.match(/^([a-zA-Z\d_-]+):/)
62
68
  if (match) {
63
69
  key = match[1]
64
70
  value = line.slice(line.indexOf(':') + 1).trim()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenjuu99/blog",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
4
4
  "description": "blog template",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -124,22 +124,29 @@ const turbolinks = () => {
124
124
  if (`${url.pathname}${url.search}` === `${current.pathname}${current.search}`) {
125
125
  return;
126
126
  }
127
- for (let k in window.turbolink_before_transition) {
128
- window.turbolink_before_transition[k].apply()
129
- }
130
- await transition(href)
131
- for (let k in window.turbolink_after_transition) {
132
- window.turbolink_after_transition[k].apply()
133
- }
134
- history.pushState({}, '', href)
135
- turbolinks()
127
+ await executeTransition(href)
136
128
  }
137
129
  }
138
130
  })
139
131
  }
132
+
133
+ const executeTransition = async (href) => {
134
+ for (let k in window.turbolink_before_transition) {
135
+ window.turbolink_before_transition[k].apply()
136
+ }
137
+ await transition(href)
138
+ for (let k in window.turbolink_after_transition) {
139
+ window.turbolink_after_transition[k].apply()
140
+ }
141
+ history.pushState({}, '', href)
142
+ turbolinks()
143
+ }
144
+
140
145
  document.body.onload = turbolinks
141
146
  window.onpopstate = async (e) => {
142
147
  const href = window.location.pathname + window.location.search + window.location.hash
143
148
  await transition(href)
144
149
  turbolinks()
145
150
  }
151
+
152
+ window.executeTransition = executeTransition