@slybridges/kiss 0.5.2 → 0.5.6

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 CHANGED
@@ -42,7 +42,7 @@ Concept is being tuned until reaching v1. Things might break. Use at your own ri
42
42
 
43
43
  ## Requirements
44
44
 
45
- Node 10 or above.
45
+ Node 12 or above.
46
46
 
47
47
  ## Quick start
48
48
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slybridges/kiss",
3
- "version": "0.5.2",
3
+ "version": "0.5.6",
4
4
  "description": "Keep It Simple and Static site generator",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -12,24 +12,24 @@
12
12
  "author": "Sylvestre Dupont",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "browser-sync": "^2.26.14",
16
- "chalk": "^4.1.0",
17
- "cheerio": "^1.0.0-rc.6",
18
- "chokidar": "^3.5.1",
19
- "date-fns": "^2.21.1",
20
- "fast-glob": "^3.2.5",
15
+ "browser-sync": "^2.27.7",
16
+ "chalk": "^4.1.2",
17
+ "cheerio": "^1.0.0-rc.10",
18
+ "chokidar": "^3.5.2",
19
+ "date-fns": "^2.27.0",
20
+ "fast-glob": "^3.2.7",
21
21
  "front-matter": "^4.0.2",
22
- "fs-extra": "^9.1.0",
22
+ "fs-extra": "^10.0.0",
23
23
  "lodash": "^4.17.21",
24
- "marked": "^2.0.3",
24
+ "marked": "^4.0.6",
25
25
  "nunjucks": "^3.2.3",
26
- "sharp": "^0.28.1",
27
- "slugify": "^1.5.0",
26
+ "sharp": "^0.29.3",
27
+ "slugify": "^1.6.3",
28
28
  "xml": "^1.0.1",
29
- "yargs": "^16.2.0"
29
+ "yargs": "^17.3.0"
30
30
  },
31
31
  "devDependencies": {
32
- "eslint": "^7.24.0"
32
+ "eslint": "^8.3.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",
@@ -8,6 +8,7 @@ const {
8
8
  } = require("../libs")
9
9
  const {
10
10
  jsLoader,
11
+ jsonLoader,
11
12
  markdownLoader,
12
13
  staticLoader,
13
14
  textLoader,
@@ -112,6 +113,7 @@ const defaultConfig = {
112
113
  libs: {},
113
114
  loaders: [
114
115
  { handler: jsLoader, namespace: "jsLoader" },
116
+ { handler: jsonLoader, namespace: "jsonLoader" },
115
117
  { handler: markdownLoader, namespace: "markdownLoader" },
116
118
  { handler: staticLoader, namespace: "staticLoader" },
117
119
  { handler: textLoader, namespace: "textLoader" },
@@ -145,6 +147,7 @@ const defaultConfig = {
145
147
  ],
146
148
  // Namespaced options
147
149
  jsLoader: { match: ["**/*.js"] },
150
+ jsonLoader: { match: ["**/*.json"] },
148
151
  markdownLoader: { match: ["**/*.md"] },
149
152
  textLoader: { match: ["**/*.html"] },
150
153
  staticLoader: {
@@ -171,7 +174,8 @@ const defaultConfig = {
171
174
  rss: {
172
175
  active: true,
173
176
  target: "feed.xml",
174
- pageFilter: (page) => page._meta.isPost && !page.excludeFromCollection,
177
+ pageFilter: (page) =>
178
+ page.url && page._meta.isPost && !page.excludeFromCollection,
175
179
  xmlOptions: {
176
180
  declaration: true,
177
181
  indent: env === "production" ? null : " ",
@@ -196,7 +200,7 @@ const defaultConfig = {
196
200
  collection: 0.5,
197
201
  },
198
202
  target: "sitemap.xml",
199
- pageFilter: (page) => page._meta.outputType === "HTML",
203
+ pageFilter: (page) => page.url && page._meta.outputType === "HTML",
200
204
  xmlOptions: {
201
205
  declaration: true,
202
206
  indent: env === "production" ? null : " ",
@@ -1,7 +1,11 @@
1
1
  // Super basic computation, you probably want to set the title manually
2
2
  // or do something smarter according to your context
3
- const computeTitle = ({ permalink }, config) =>
4
- config.libs.unslugify(permalink, { slash: " | " })
3
+ const computeTitle = ({ permalink }, config) => {
4
+ if (!permalink) {
5
+ return null
6
+ }
7
+ return config.libs.unslugify(permalink, { slash: " | " })
8
+ }
5
9
 
6
10
  computeTitle.kissDependencies = ["permalink"]
7
11
 
@@ -1,4 +1,7 @@
1
1
  const computeURL = ({ permalink }, config, context) => {
2
+ if (!permalink) {
3
+ return null
4
+ }
2
5
  if (!context.site.url) {
3
6
  return permalink
4
7
  }
@@ -1,4 +1,4 @@
1
- const marked = require("marked")
1
+ const { marked } = require("marked")
2
2
 
3
3
  const loadMarked = (_, config) => {
4
4
  config.libs.marked = marked
@@ -1,6 +1,7 @@
1
1
  const baseLoader = require("./baseLoader")
2
2
  const computeCollectionLoader = require("./computeCollectionLoader")
3
3
  const jsLoader = require("./jsLoader")
4
+ const jsonLoader = require("./jsonLoader")
4
5
  const markdownLoader = require("./markdownLoader")
5
6
  const staticLoader = require("./staticLoader")
6
7
  const textLoader = require("./textLoader")
@@ -9,6 +10,7 @@ module.exports = {
9
10
  baseLoader,
10
11
  computeCollectionLoader,
11
12
  jsLoader,
13
+ jsonLoader,
12
14
  markdownLoader,
13
15
  staticLoader,
14
16
  textLoader,
@@ -0,0 +1,17 @@
1
+ const { parseISO } = require("date-fns")
2
+ const { readJsonSync } = require("fs-extra")
3
+
4
+ const jsonLoader = (path, options, page, pages, config) => {
5
+ let fileData = readJsonSync(path)
6
+ const published = fileData[config.defaults.pagePublishedAttribute]
7
+ const updated = fileData[config.defaults.pageUpdatedAttribute]
8
+ if (published && typeof published === "string") {
9
+ fileData[config.defaults.pagePublishedAttribut] = parseISO(published)
10
+ }
11
+ if (updated && typeof updated === "string") {
12
+ fileData[config.defaults.pageUpdatedAttribute] = parseISO(updated)
13
+ }
14
+ return { ...page, ...fileData }
15
+ }
16
+
17
+ module.exports = jsonLoader
@@ -33,7 +33,7 @@ const pageObject = (page, options, config) => {
33
33
  }
34
34
  return {
35
35
  url: [
36
- { loc: page.permalink },
36
+ { loc: page.url },
37
37
  { lastmod: lastMod },
38
38
  { changefreq: changeFreq },
39
39
  { priority: priority.toFixed(1) },
package/clean.sh DELETED
@@ -1,2 +0,0 @@
1
- rm -rf public package-lock.json node_modules
2
-