|
|
@ -3,9 +3,11 @@ 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 assign = require('assign-deep')
|
|
|
|
|
|
|
|
const fs = require('fs')
|
|
|
|
|
|
|
|
|
|
|
|
const Media = require('./../factories/media.js')
|
|
|
|
const Media = require('./../factories/media.js')
|
|
|
|
const parseMarkdownFile = require('./../parsers/markdown.js')
|
|
|
|
const parseMarkdownFile = require('./../parsers/markdown.js')
|
|
|
|
|
|
|
|
const configStore = require('./../config.js')
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Page - building from markdown file
|
|
|
|
* Page - building from markdown file
|
|
|
@ -55,6 +57,12 @@ class Page {
|
|
|
|
this._permalink = this._dirPath + '/' + this._slug
|
|
|
|
this._permalink = this._dirPath + '/' + this._slug
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check if page is in subdirectory
|
|
|
|
|
|
|
|
if (fs.existsSync(configStore.get('source') + this._permalink) && this._slug) {
|
|
|
|
|
|
|
|
this._dirPath += '/' + this._slug
|
|
|
|
|
|
|
|
this._filename = 'index'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this._filename += '.' + this._fields.extensions
|
|
|
|
this._filename += '.' + this._fields.extensions
|
|
|
|
|
|
|
|
|
|
|
|
this._content = result.content
|
|
|
|
this._content = result.content
|
|
|
@ -115,7 +123,12 @@ class Page {
|
|
|
|
return fields
|
|
|
|
return fields
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
_resolveMediaSrc(field, dirPath) {
|
|
|
|
_resolveMediaSrc(field, dirPath) {
|
|
|
|
|
|
|
|
|
|
|
|
const media = new Media(dirPath)
|
|
|
|
const media = new Media(dirPath)
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof field === 'string' || field instanceof String) {
|
|
|
|
if (typeof field === 'string' || field instanceof String) {
|
|
|
|