adding uuid for each page

main
HerrHase 1 week ago
parent 6d77c21c14
commit a1dac33c4d

4028
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
{ {
"name": "@site-o-mat/core", "name": "@site-o-mat/core",
"version": "0.5.3", "version": "0.6.0",
"build": "webpack", "build": "webpack",
"author": "Björn Hase <me@herr-hase.wtf>", "author": "Björn Hase <me@herr-hase.wtf>",
"main": "index.js", "main": "index.js",
@ -17,20 +17,21 @@
"assign-deep": "^1.0.1", "assign-deep": "^1.0.1",
"crypto": "^1.0.1", "crypto": "^1.0.1",
"dayjs": "^1.11.6", "dayjs": "^1.11.6",
"fast-xml-parser": "^4.0.11", "fast-xml-parser": "^5.12.1",
"html-minifier": "^4.0.0", "html-minifier": "^5.4.1",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"lodash.merge": "^4.6.2", "lodash.merge": "^4.6.2",
"lodash.orderby": "^4.6.0", "lodash.orderby": "^4.6.0",
"marked": "^4.1.1", "marked": "^4.1.1",
"mkdirp": "^1.0.4", "mkdirp": "^1.0.4",
"nunjucks": "^3.2.3", "nunjucks": "^3.2.3",
"sharp": "^0.31.1", "sharp": "^0.35.5",
"slugify": "^1.6.5", "slugify": "^1.6.5",
"uuid": "^14.0.3",
"yaml": "^2.1.3" "yaml": "^2.1.3"
}, },
"devDependencies": { "devDependencies": {
"chai": "^4.3.7", "chai": "^4.3.7",
"mocha": "^10.2.0" "mocha": "^12.0.3"
} }
} }

@ -4,6 +4,7 @@ const merge = require('lodash.merge')
const nunjucks = require('nunjucks') const nunjucks = require('nunjucks')
const assign = require('assign-deep') const assign = require('assign-deep')
const fs = require('fs') const fs = require('fs')
const uuid = require('uuid')
const Media = require('./../factories/media.js') const Media = require('./../factories/media.js')
const parseMarkdownFile = require('./../parsers/markdown.js') const parseMarkdownFile = require('./../parsers/markdown.js')
@ -52,6 +53,7 @@ class Page {
this._filename = this._resolveFilename(file) this._filename = this._resolveFilename(file)
this._slug = this._resolveSlug(this._filename) this._slug = this._resolveSlug(this._filename)
this._permalink = this._dirPath this._permalink = this._dirPath
this._uuid = uuid.v5(this._dirPath + '/' + this._filename, uuid.v5.URL)
if (this._slug) { if (this._slug) {
this._permalink = this._dirPath + '/' + this._slug this._permalink = this._dirPath + '/' + this._slug
@ -102,7 +104,8 @@ class Page {
'dirPath' : this._dirPath, 'dirPath' : this._dirPath,
'path' : this._dirPath + '/' + this._filename, 'path' : this._dirPath + '/' + this._filename,
'permalink' : this._permalink, 'permalink' : this._permalink,
'filename' : this._filename 'filename' : this._filename,
'uuid' : this._uuid
}, this._fields) }, this._fields)
} }

@ -30,6 +30,10 @@ describe('Page /index.md', function () {
assert.equal(page.permalink, '') assert.equal(page.permalink, '')
}) })
it('uuid', function() {
assert.equal(page.uuid, '060f3d16-9707-54b7-9d6a-2ee573d4b107')
})
it('parsed content contains image', () => { it('parsed content contains image', () => {
assert.match(page.content, /<img src="\/assets\/88c010ea\/4ca9b5f5\/6024c57d\/05899fae\/a33d9a45\/dog.webp" alt="_images\/dog.jpg">/) assert.match(page.content, /<img src="\/assets\/88c010ea\/4ca9b5f5\/6024c57d\/05899fae\/a33d9a45\/dog.webp" alt="_images\/dog.jpg">/)
}) })
@ -45,6 +49,8 @@ describe('Page /blog/index.md', function () {
const page = results[1] const page = results[1]
console.log(page)
it('fields is object', function() { it('fields is object', function() {
assert.isObject(page) assert.isObject(page)
}) })
@ -58,7 +64,11 @@ describe('Page /blog/index.md', function () {
}) })
it('permalink', function() { it('permalink', function() {
assert.equal(page.permalink, '/blog') assert.equal(page.permalink, '/blog/')
})
it('uuid', function() {
assert.equal(page.uuid, 'f564b12e-78e6-5606-b97d-5cb9b8ffc550')
}) })
it('fields has media src', function() { it('fields has media src', function() {

Loading…
Cancel
Save