main
HerrHase 2 years ago
parent e7028f1656
commit d8a9d1494f

@ -85,7 +85,17 @@ media:
The yaml-Section will be parsed as an Object and available in the Templates. The The yaml-Section will be parsed as an Object and available in the Templates. The
second part of the File will be parsed as Markdown, but it could be also empty. second part of the File will be parsed as Markdown, but it could be also empty.
Default type for Pages is **html**. After parsing Markdown-Files a Page always this values,
| Name | Type | Default | Description |
|-------------|-----------|----------|-------------|
| path | {String} | / | Full path with File |
| permalink | {String} | -1 | Full path without Extensions, index.html will be empty |
| filename | {String} | null | Name of File |
| hidden | {Boolean} | false | If hidden, file will not be written |
| blocks | {Object} | Object | Blocks of Directory |
| content | {String} | empty | Parsed Markdown |
| view | {String} | page.njk | Tempate to render file |
## Nesting ## Nesting

@ -0,0 +1,17 @@
---
title: "article"
view: "article.njk"
meta:
description: "DSA yes plz hot chicken green juice"
---
## Normcore cold-pressed ramps DSA
Normcore cold-pressed ramps DSA yes plz hot chicken green juice succulents leggings messenger bag truffaut iceland pabst ethical godard. Semiotics air plant marfa, drinking vinegar authentic iceland pug fit cloud bread cronut kickstarter glossier crucifix tumeric. Chicharrones polaroid flexitarian, seitan lumbersexual viral fam master cleanse four dollar toast scenester. Succulents poutine vegan keffiyeh meh, health goth DIY tattooed. Praxis roof party celiac chartreuse banjo butcher you probably haven't heard of them schlitz beard. Ethical tattooed kinfolk, cliche vegan messenger bag mukbang dreamcatcher cloud bread farm-to-table gatekeep trust fund.
## Palo santo leggings normcore aesthetic
bicycle rights sartorial godard slow-carb thundercats art party cray JOMO. Truffaut four dollar toast hoodie pour-over. Fanny pack iPhone jean shorts tote bag, master cleanse succulents tbh fixie gatekeep pok pok letterpress cornhole. Dreamcatcher tattooed hot chicken gatekeep, glossier salvia 8-bit cred. Fit lomo chillwave cold-pressed humblebrag narwhal. Meggings edison bulb fanny pack irony af pug pok pok whatever vexillologist vibecession cred butcher trust fund chia.
## Bitters kale chips chambray activated charcoal
wolf keffiyeh hell of selfies. Wolf readymade shoreditch flexitarian venmo single-origin coffee, knausgaard fit actually street art cold-pressed iPhone gatekeep. Migas bruh adaptogen semiotics marfa pickled yuccie. Locavore normcore lomo, shoreditch fashion axe actually glossier iPhone photo booth blue bottle DIY XOXO williamsburg. Pinterest whatever taxidermy, kale chips prism XOXO schlitz twee tote bag woke swag. Wayfarers fashion axe heirloom humblebrag synth. Whatever succulents PBR&B, pop-up enamel pin echo park tonx stumptown taiyaki.

@ -0,0 +1,17 @@
---
title: "blog"
view: "page.njk"
meta:
description: "DSA yes plz hot chicken green juice"
---
## Normcore cold-pressed ramps DSA
Normcore cold-pressed ramps DSA yes plz hot chicken green juice succulents leggings messenger bag truffaut iceland pabst ethical godard. Semiotics air plant marfa, drinking vinegar authentic iceland pug fit cloud bread cronut kickstarter glossier crucifix tumeric. Chicharrones polaroid flexitarian, seitan lumbersexual viral fam master cleanse four dollar toast scenester. Succulents poutine vegan keffiyeh meh, health goth DIY tattooed. Praxis roof party celiac chartreuse banjo butcher you probably haven't heard of them schlitz beard. Ethical tattooed kinfolk, cliche vegan messenger bag mukbang dreamcatcher cloud bread farm-to-table gatekeep trust fund.
## Palo santo leggings normcore aesthetic
bicycle rights sartorial godard slow-carb thundercats art party cray JOMO. Truffaut four dollar toast hoodie pour-over. Fanny pack iPhone jean shorts tote bag, master cleanse succulents tbh fixie gatekeep pok pok letterpress cornhole. Dreamcatcher tattooed hot chicken gatekeep, glossier salvia 8-bit cred. Fit lomo chillwave cold-pressed humblebrag narwhal. Meggings edison bulb fanny pack irony af pug pok pok whatever vexillologist vibecession cred butcher trust fund chia.
## Bitters kale chips chambray activated charcoal
wolf keffiyeh hell of selfies. Wolf readymade shoreditch flexitarian venmo single-origin coffee, knausgaard fit actually street art cold-pressed iPhone gatekeep. Migas bruh adaptogen semiotics marfa pickled yuccie. Locavore normcore lomo, shoreditch fashion axe actually glossier iPhone photo booth blue bottle DIY XOXO williamsburg. Pinterest whatever taxidermy, kale chips prism XOXO schlitz twee tote bag woke swag. Wayfarers fashion axe heirloom humblebrag synth. Whatever succulents PBR&B, pop-up enamel pin echo park tonx stumptown taiyaki.

@ -35,15 +35,25 @@ class Page {
// fields merge by default values // fields merge by default values
this._fields = merge({ this._fields = merge({
view: 'page.njk', view: 'page.njk',
type: 'html', extensions: 'html',
meta: { meta: {
robots: 'index' robots: 'index'
} },
hidden: false
}, result.fields) }, result.fields)
// adding filename for html as pathname and relative path in structure // adding filename for html as pathname and relative path in structure
this._filename = this._resolveFilename(file) this._filename = this._resolveFilename(file)
this._pathname = this._resolvePathname(parent) this._slug = this._resolveSlug(this._filename)
this._path = this._resolvePath(parent)
this._permalink = this._path
if (this._slug) {
this._permalink = this._path + '/' + this._slug
}
this._filename += '.' + this._fields.extensions
this._content = result.content this._content = result.content
this._blocks = blocks this._blocks = blocks
@ -60,12 +70,27 @@ class Page {
return assign({ return assign({
'content' : this._content, 'content' : this._content,
'blocks' : this._blocks, 'blocks' : this._blocks,
'path' : this._pathname + '/' + this._filename, 'path' : this._path + '/' + this._filename,
'filename' : this._filename, 'permalink' : this._permalink,
'pathname' : this._pathname 'filename' : this._filename
}, this._fields) }, this._fields)
} }
/**
*
*
*/
_resolveSlug(filename) {
let slug = filename
if (slug === 'index') {
slug = ''
}
return slug
}
/** /**
* create html-filename = filename * create html-filename = filename
* *
@ -87,7 +112,7 @@ class Page {
filename = slugify(filename) filename = slugify(filename)
} }
return filename + '.' + this._fields.type return filename
} }
/** /**
@ -97,14 +122,14 @@ class Page {
* @return {string} * @return {string}
* *
*/ */
_resolvePathname(parent) { _resolvePath(parent, slug) {
let pathname = parent let path = parent
if (parent === '/') { if (parent === '/') {
pathname = '' path = ''
} }
return pathname return path
} }
} }

@ -0,0 +1,44 @@
const { assert } = require('chai')
const fs = require('fs')
const PagesQuery = require('./../src/queries/pages.js')
describe('Page /index.md', function () {
const query = new PagesQuery('./ressources');
const results = query.find()
const page = results[2]
it('fields is object', function() {
assert.isObject(page)
})
it('path', function() {
assert.equal(page.path, '/index.html')
})
it('permalink', function() {
assert.equal(page.permalink, '')
})
})
describe('Page /blog/article.md', function () {
const query = new PagesQuery('./ressources');
const results = query.find()
const page = results[0]
it('fields is object', function() {
assert.isObject(page)
})
it('path', function() {
assert.equal(page.path, '/blog/article.html')
})
it('permalink', function() {
assert.equal(page.permalink, '/blog/article')
})
})

@ -4,7 +4,7 @@ const fs = require('fs')
describe('Parser Markdown', function () { describe('Parser Markdown', function () {
// default file // default file
const markdownData = fs.readFileSync('./ressources/default.md', 'utf8') const markdownData = fs.readFileSync('./ressources/index.md', 'utf8')
// get function parseMarkdownFile // get function parseMarkdownFile
const parseMarkdownFile = require('./../src/parsers/markdown.js') const parseMarkdownFile = require('./../src/parsers/markdown.js')

Loading…
Cancel
Save