folder rename
This commit is contained in:
parent
540a9e4129
commit
6b11b10965
2 changed files with 46 additions and 1 deletions
45
brain/data/Pages.js
Normal file
45
brain/data/Pages.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
import fh from 'filehound';
|
||||
import fs from 'fs-extra';
|
||||
import metadataParser from 'markdown-yaml-metadata-parser';
|
||||
|
||||
export default class Pages {
|
||||
//--------------------------
|
||||
// constructor
|
||||
//--------------------------
|
||||
constructor() {}
|
||||
//--------------------------
|
||||
// methods
|
||||
//--------------------------
|
||||
start() {}
|
||||
|
||||
grab(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fh.create()
|
||||
.paths('content/pages')
|
||||
.ext('md')
|
||||
.find()
|
||||
.then(files => {
|
||||
let pages = [];
|
||||
for (let index = 0; index < files.length; index++) {
|
||||
fs.readFile(files[index], { encoding: 'utf8' }, (err, file) => {
|
||||
pages.push(metadataParser(file));
|
||||
});
|
||||
}
|
||||
if (id === null || id === null || id === undefined) {
|
||||
setTimeout(() => {
|
||||
//TODO: Duct tape solution until something better created
|
||||
resolve(pages);
|
||||
}, 100);
|
||||
} else {
|
||||
// find specific pages
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
//--------------------------
|
||||
// event handlers
|
||||
//--------------------------
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import Pages from '../../content/Pages';
|
||||
import Pages from '../../control/Pages';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const settings = require('../../../config/site-settings.json');
|
||||
|
|
Loading…
Reference in a new issue