@tenjuu99/blog 0.2.8 → 0.2.9
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/README.md +1 -1
- package/bin/dev-server +1 -0
- package/lib/filter.js +1 -32
- package/lib/render.js +2 -2
- package/package.json +1 -1
- package/src-sample/helper/add.js +3 -0
- package/src-sample/helper/index.js +1 -5
package/README.md
CHANGED
package/bin/dev-server
CHANGED
package/lib/filter.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import helper from '../lib/helper.js'
|
|
2
|
-
import { srcDir } from './dir.js'
|
|
3
|
-
import config from './config.js'
|
|
4
|
-
import replaceVariablesFilter from './replaceVariablesFilter.js'
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* @param {string} condition
|
|
@@ -84,30 +81,6 @@ const replaceIfFilter = (text, variables) => {
|
|
|
84
81
|
return text
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
/**
|
|
88
|
-
* 配列を再帰的に順不同リストに変換する
|
|
89
|
-
* @param {Array|string} arrayOrText
|
|
90
|
-
* @returns {mixed}
|
|
91
|
-
*/
|
|
92
|
-
const arrayToList = (arrayOrText) => {
|
|
93
|
-
if (typeof arrayOrText === 'string') {
|
|
94
|
-
return `<li>${arrayOrText}</li>`
|
|
95
|
-
}
|
|
96
|
-
if (Array.isArray(arrayOrText)) {
|
|
97
|
-
let resultListText = '<ul>'
|
|
98
|
-
for (const item of arrayOrText) {
|
|
99
|
-
if (Array.isArray(item)) {
|
|
100
|
-
resultListText += `<li>${arrayToList(item)}</li>`
|
|
101
|
-
} else {
|
|
102
|
-
resultListText += `<li>${item}</li>`
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
resultListText += '</ul>'
|
|
106
|
-
arrayOrText = resultListText
|
|
107
|
-
}
|
|
108
|
-
return arrayOrText
|
|
109
|
-
}
|
|
110
|
-
|
|
111
84
|
const replaceScriptFilter = async (text, variables) => {
|
|
112
85
|
let replaced = text
|
|
113
86
|
const scriptRegexp = new RegExp(/({script}|\<script\s.*type="ssg".*>)(?<script>[\s\S]*?)(\{\/script}|\<\/script>)/g)
|
|
@@ -127,9 +100,6 @@ const replaceScriptFilter = async (text, variables) => {
|
|
|
127
100
|
case 'null':
|
|
128
101
|
result = ''
|
|
129
102
|
}
|
|
130
|
-
if (Array.isArray(result)) {
|
|
131
|
-
result = helper.arrayToList(result)
|
|
132
|
-
}
|
|
133
103
|
replaced = replaced.replace(script.replace, result)
|
|
134
104
|
}
|
|
135
105
|
return replaced
|
|
@@ -137,6 +107,5 @@ const replaceScriptFilter = async (text, variables) => {
|
|
|
137
107
|
|
|
138
108
|
export {
|
|
139
109
|
replaceIfFilter,
|
|
140
|
-
replaceScriptFilter
|
|
141
|
-
replaceVariablesFilter
|
|
110
|
+
replaceScriptFilter
|
|
142
111
|
}
|
package/lib/render.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
replaceIfFilter,
|
|
3
|
-
replaceScriptFilter
|
|
4
|
-
replaceVariablesFilter
|
|
3
|
+
replaceScriptFilter
|
|
5
4
|
} from './filter.js'
|
|
5
|
+
import replaceVariablesFilter from './replaceVariablesFilter.js'
|
|
6
6
|
import includeFilter from './includeFilter.js'
|
|
7
7
|
import { marked } from "marked";
|
|
8
8
|
import { applyTemplate } from './applyTemplate.js'
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { allData } from '@tenjuu99/blog/lib/indexer.js'
|
|
2
|
-
import
|
|
2
|
+
import replaceVariablesFilter from '@tenjuu99/blog/lib/replaceVariablesFilter.js'
|
|
3
3
|
import config from '@tenjuu99/blog/lib/config.js'
|
|
4
4
|
|
|
5
5
|
export function readIndex (filter = null) {
|
|
@@ -115,10 +115,6 @@ export function renderIndex(pages, nodate = 'nodate', headingTag = 'h3') {
|
|
|
115
115
|
return resultText.join('\n')
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
export function additionalHelper() {
|
|
119
|
-
return 'これは追加ヘルパーによって出力されているメッセージです。'
|
|
120
|
-
}
|
|
121
|
-
|
|
122
118
|
export function isEditorEnabled() {
|
|
123
119
|
return allData.editor && allData.editor.distribute
|
|
124
120
|
}
|