develop
HerrHase 1 year ago
parent 918c0896e7
commit 184c5fc61e

37
package-lock.json generated

@ -1,13 +1,14 @@
{ {
"name": "@/siteomat-webpack-plugin", "name": "@helpers/siteomat-webpack-plugin",
"version": "0.1.0", "version": "0.1.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@/siteomat-webpack-plugin", "name": "@helpers/siteomat-webpack-plugin",
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"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": "^4.0.11",
@ -38,6 +39,25 @@
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="
}, },
"node_modules/assign-deep": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/assign-deep/-/assign-deep-1.0.1.tgz",
"integrity": "sha512-CSXAX79mibneEYfqLT5FEmkqR5WXF+xDRjgQQuVf6wSCXCYU8/vHttPidNar7wJ5BFmKAo8Wei0rCtzb+M/yeA==",
"dependencies": {
"assign-symbols": "^2.0.2"
},
"engines": {
"node": ">=6"
}
},
"node_modules/assign-symbols": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-2.0.2.tgz",
"integrity": "sha512-9sBQUQZMKFKcO/C3Bo6Rx4CQany0R0UeVcefNGRRdW2vbmaMOhV1sbmlXcQLcD56juLXbSGTBm0GGuvmrAF8pA==",
"engines": {
"node": ">=6"
}
},
"node_modules/base64-js": { "node_modules/base64-js": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@ -766,6 +786,19 @@
"resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz",
"integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA=="
}, },
"assign-deep": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/assign-deep/-/assign-deep-1.0.1.tgz",
"integrity": "sha512-CSXAX79mibneEYfqLT5FEmkqR5WXF+xDRjgQQuVf6wSCXCYU8/vHttPidNar7wJ5BFmKAo8Wei0rCtzb+M/yeA==",
"requires": {
"assign-symbols": "^2.0.2"
}
},
"assign-symbols": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-2.0.2.tgz",
"integrity": "sha512-9sBQUQZMKFKcO/C3Bo6Rx4CQany0R0UeVcefNGRRdW2vbmaMOhV1sbmlXcQLcD56juLXbSGTBm0GGuvmrAF8pA=="
},
"base64-js": { "base64-js": {
"version": "1.5.1", "version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",

@ -10,6 +10,7 @@
}, },
"description": "A Webpack Plugin for generating a Website as Html-Files from a Markdown File Structure", "description": "A Webpack Plugin for generating a Website as Html-Files from a Markdown File Structure",
"dependencies": { "dependencies": {
"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": "^4.0.11",

@ -1,8 +1,13 @@
/** /**
* ConfigStore
* *
* *
*
* @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
*
*/ */
class ConfigStore { class ConfigStore {
constructor() { constructor() {
@ -15,6 +20,10 @@ class ConfigStore {
} }
/** /**
* set value by key
*
* @param {String} key
* @param {String|Object} value
* *
*/ */
set(key, value) { set(key, value) {
@ -22,10 +31,17 @@ class ConfigStore {
} }
/** /**
* get value by key
* *
* * @param {String} key
* @return {String|Object}
*/ */
get(key) { get(key) {
if (!this._data?.[key]) {
throw new Error(key + ' not found in ConfigStore!')
}
return this._data[key] return this._data[key]
} }
} }
@ -33,4 +49,4 @@ class ConfigStore {
// create instance // create instance
const instance = new ConfigStore(); const instance = new ConfigStore();
module.exports =instance module.exports = instance

@ -12,8 +12,8 @@ const Media = require('./media.js')
* *
*/ */
function asset(staticPath) function asset(staticPath) {
{
// getting basePath // getting basePath
let result = staticPath let result = staticPath

@ -2,16 +2,17 @@ const nunjucks = require('nunjucks')
const { minify } = require('html-minifier') const { minify } = require('html-minifier')
const fs = require('fs') const fs = require('fs')
const configStore = require('./../config.js')
const { asset, resize } = require('./helpers.js') const { asset, resize } = require('./helpers.js')
const PageQuery = require('./queries/pages.js') const PageQuery = require('./../queries/pages.js')
const configStore = require('./config.js')
/** /**
* engine - handle eta.js * nunjucks
*
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
class Engine { class Engine {

@ -6,7 +6,7 @@ const dayjs = require('dayjs')
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
class Sitemap { class Sitemap {

@ -4,12 +4,12 @@ const parseMarkdownFile = require('./../parsers/markdown.js')
/** /**
* Block * Block
* *
* parsed markdown-file that can contains fields * parsed markdown-file that can
* as yaml * contains fields as yaml
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
@ -26,9 +26,10 @@ class Block {
// parse string of file // parse string of file
const parsedFile = parseMarkdownFile(fileString) const parsedFile = parseMarkdownFile(fileString)
this._content = parsedFile.content // getting parsed data
this._fields = parsedFile.fields this.content = parsedFile.content
this.fields = parsedFile.fields
} }
} }
module.exports =Block module.exports = Block

@ -2,6 +2,7 @@ const path = require('path')
const slugify = require('slugify') const slugify = require('slugify')
const merge = require('lodash.merge') const merge = require('lodash.merge')
const nunjucks = require('nunjucks') const nunjucks = require('nunjucks')
const assign = require('assign-deep')
const parseMarkdownFile = require('./../parsers/markdown.js') const parseMarkdownFile = require('./../parsers/markdown.js')
@ -11,7 +12,7 @@ const parseMarkdownFile = require('./../parsers/markdown.js')
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
@ -36,15 +37,15 @@ class Page {
this.pathname = this._resolvePathname(parent) this.pathname = this._resolvePathname(parent)
// fields merge by default values // fields merge by default values
this._fields = merge({ this.fields = merge({
view: 'page', view: 'page',
meta: { meta: {
robots: 'index' robots: 'index'
} }
}, result.fields) }, result.fields)
this._content = result.content this.content = result.content
this._blocks = blocks this.blocks = blocks
} }
/** /**
@ -56,13 +57,13 @@ class Page {
*/ */
render(engine, done) { render(engine, done) {
const page = Object.assign({}, this._fields) const page = assign({}, this.fields)
page.content = this._content page.content = this.content
page.blocks = this._blocks page.blocks = this.blocks
page.path = this.pathname + '/' + this.filename page.path = this.pathname + '/' + this.filename
return engine.render(this._fields.view, { return engine.render(this.fields.view, {
page: page page: page
}, done) }, done)
} }

@ -6,7 +6,7 @@ const { marked } = require('marked')
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
@ -39,4 +39,4 @@ function parseMarkdownFile(fileString) {
return result return result
} }
module.exports =parseMarkdownFile module.exports = parseMarkdownFile

@ -5,7 +5,7 @@ const yaml = require('js-yaml')
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */

@ -6,9 +6,10 @@ const Block = require('./../models/block.js')
/** /**
* search, filter and find pages * search, filter and find pages
* *
*
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
@ -22,6 +23,7 @@ class Blocks {
*/ */
constructor(dirPath) { constructor(dirPath) {
this.FILE_EXTENSION = '.md'
this.DIRECTORY_BLOCKS = '_blocks' this.DIRECTORY_BLOCKS = '_blocks'
this._dirPath = dirPath + '/' + this.DIRECTORY_BLOCKS; this._dirPath = dirPath + '/' + this.DIRECTORY_BLOCKS;
@ -45,7 +47,7 @@ class Blocks {
/** /**
* find files * find files
* *
* @param {[type]} dirPath * @param {string} dirPath
* @param {Object} [parent = ''] * @param {Object} [parent = '']
* *
*/ */
@ -59,7 +61,7 @@ class Blocks {
files.forEach((file) => { files.forEach((file) => {
// skip for file that is not markdown // skip for file that is not markdown
if (file.isFile() && path.extname(file.name) !== '.md') { if (file.isFile() && path.extname(file.name) !== this.FILE_EXTENSION) {
return; return;
} }

@ -11,7 +11,7 @@ const Blocks = require('./../queries/blocks.js')
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */

@ -2,22 +2,22 @@ const fs = require('fs')
const path = require('path') const path = require('path')
const mkdirp = require('mkdirp') const mkdirp = require('mkdirp')
const Engine = require('./engine.js') const configStore = require('./config.js')
const Sitemap = require('./sitemap.js')
const Engine = require('./engines/nunjucks.js')
const Sitemap = require('./factories/sitemap.js')
const PagesQuery = require('./queries/pages.js') const PagesQuery = require('./queries/pages.js')
const parseYamlFile = require('./parsers/yaml.js') const parseYamlFile = require('./parsers/yaml.js')
const configStore = require('./config.js')
/** /**
* Main * Siteomat
* *
* *
* *
* @author Björn Hase <me@herr-hase.wtf> * @author Björn Hase <me@herr-hase.wtf>
* @license http://opensource.org/licenses/MIT The MIT License * @license http://opensource.org/licenses/MIT The MIT License
* @link https://gitea.node001.net/HerrHase/happy-site-webpack-plugin.git * @link https://gitea.node001.net/HerrHase/siteomat-webpack-plugin.git
* *
*/ */
class Siteomat { class Siteomat {

Loading…
Cancel
Save