@tenjuu99/blog 0.2.22 → 0.2.23
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/lib/config.js +2 -1
- package/lib/indexer.js +3 -1
- package/lib/render.js +8 -3
- package/lib/server.js +2 -0
- package/package.json +1 -1
- package/src-sample/pages/robots.txt +8 -0
package/lib/config.js
CHANGED
package/lib/indexer.js
CHANGED
|
@@ -3,6 +3,7 @@ import { readFile } from "node:fs/promises";
|
|
|
3
3
|
import { readdirSync } from "node:fs";
|
|
4
4
|
import { pageDir, cacheDir } from './dir.js'
|
|
5
5
|
import makePageData from './pageData.js'
|
|
6
|
+
import config from './config.js'
|
|
6
7
|
|
|
7
8
|
let allData = {}
|
|
8
9
|
|
|
@@ -18,7 +19,8 @@ const collect = (dir, namePrefix = '', promises = []) => {
|
|
|
18
19
|
if (dirent.isDirectory()) {
|
|
19
20
|
collect(`${dirent.path}/${dirent.name}`, namePrefix + dirent.name + '/', promises)
|
|
20
21
|
} else {
|
|
21
|
-
|
|
22
|
+
const regexp = `\\.(${config.allowedSrcExt})$`
|
|
23
|
+
if (dirent.name.match(regexp)) {
|
|
22
24
|
const name = `${namePrefix}${dirent.name}`
|
|
23
25
|
promises.push(readFile(`${dir}/${dirent.name}`, 'utf8').then(f => [name, f]))
|
|
24
26
|
}
|
package/lib/render.js
CHANGED
|
@@ -13,9 +13,14 @@ marked.use({
|
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
const render = async (templateName, data) => {
|
|
16
|
-
let template
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
let template
|
|
17
|
+
if (!templateName) {
|
|
18
|
+
template = '{{MARKDOWN}}'
|
|
19
|
+
} else {
|
|
20
|
+
template = await applyTemplate(templateName)
|
|
21
|
+
template = replaceIfFilter(template, data)
|
|
22
|
+
template = await replaceScriptFilter(template, data)
|
|
23
|
+
}
|
|
19
24
|
|
|
20
25
|
let markdown = data.markdown
|
|
21
26
|
markdown = includeFilter(markdown)
|
package/lib/server.js
CHANGED
package/package.json
CHANGED