@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 CHANGED
@@ -9,7 +9,8 @@ const config = {
9
9
  "distribute_raw": "image",
10
10
  "relative_path": "",
11
11
  "helper": "",
12
- "packages": ""
12
+ "packages": "",
13
+ "allowedSrcExt": "md|html|txt"
13
14
  }
14
15
  try {
15
16
  const file = rootDir + '/blog.json'
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
- if (dirent.name.match(/\.(md|html)$/)) {
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 = await applyTemplate(templateName)
17
- template = replaceIfFilter(template, data)
18
- template = await replaceScriptFilter(template, data)
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
@@ -7,6 +7,8 @@ import handle from './tryServer.js'
7
7
 
8
8
  const contentType = (ext) => {
9
9
  switch (ext) {
10
+ case 'txt':
11
+ return 'text/plain'
10
12
  case 'html':
11
13
  case 'css':
12
14
  return `text/${ext}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenjuu99/blog",
3
- "version": "0.2.22",
3
+ "version": "0.2.23",
4
4
  "description": "blog template",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -0,0 +1,8 @@
1
+ ---
2
+ template:
3
+ url: /robots
4
+ ext: txt
5
+ ---
6
+ User-Agent: *
7
+
8
+ Allow: /