forked from projects/fipamo
index page now created as part of blog init process
This commit is contained in:
parent
fe5c581497
commit
03e8fbe82f
4 changed files with 101 additions and 2 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,7 +1,8 @@
|
|||
node_modules/
|
||||
.sass-cache/
|
||||
.cache/
|
||||
public/
|
||||
public/*
|
||||
!public/assets/images/global
|
||||
content/
|
||||
.ftpconfig
|
||||
.vscode/
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||
import mdparser from 'markdown-yaml-metadata-parser';
|
||||
const uuidv4 = require('uuid/v4');
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const bcrypt = require('bcrypt');
|
||||
|
@ -141,6 +143,78 @@ router.post('/init', function (req, res) {
|
|||
|
||||
fs.writeJson('site/tags.json', { tags: [] });
|
||||
|
||||
//set up index file as first page
|
||||
|
||||
fs.readFile('site/init/index-template.md', { encoding: 'utf8' }).then(file => {
|
||||
let index = mdparser(file);
|
||||
let data = index.metadata;
|
||||
data.uuid = uuidv4();
|
||||
data.path = moment().format('YYYY') + '/' + moment().format('MM');
|
||||
data.author = body.new_member_handle;
|
||||
data.created = moment(Date.now()).format();
|
||||
data.updated = moment(Date.now()).format();
|
||||
|
||||
var init =
|
||||
'---\n' +
|
||||
'id: ' +
|
||||
data.id +
|
||||
'\n' +
|
||||
'uuid: ' +
|
||||
data.uuid +
|
||||
'\n' +
|
||||
'title: ' +
|
||||
data.title +
|
||||
'\n' +
|
||||
'feature: ' +
|
||||
data.feature +
|
||||
'\n' +
|
||||
'path: ' +
|
||||
moment(Date.now()).format('YYYY') +
|
||||
'/' +
|
||||
moment(Date.now()).format('MM') +
|
||||
'\n' +
|
||||
'layout: ' +
|
||||
'index' +
|
||||
'\n' +
|
||||
'tags: ' +
|
||||
data.tags +
|
||||
'\n' +
|
||||
'author: ' +
|
||||
body.new_member_handle +
|
||||
'\n' +
|
||||
'created: ' +
|
||||
moment(Date.now()).format() +
|
||||
'\n' +
|
||||
'updated: ' +
|
||||
moment(Date.now()).format() +
|
||||
'\n' +
|
||||
'deleted: ' +
|
||||
'false' +
|
||||
'\n' +
|
||||
'menu: ' +
|
||||
data.menu +
|
||||
'\n' +
|
||||
'featured: ' +
|
||||
data.featured +
|
||||
'\n' +
|
||||
'published: ' +
|
||||
data.published +
|
||||
'\n' +
|
||||
'slug: ' +
|
||||
data.slug +
|
||||
'\n' +
|
||||
'---\n' +
|
||||
index.content;
|
||||
|
||||
fs.writeFile('content/pages/index.md', init)
|
||||
.then(() => {
|
||||
console.log('index file created');
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('ERROR', err);
|
||||
});
|
||||
});
|
||||
|
||||
res.json({
|
||||
type: DataEvent.API_INIT_GOOD,
|
||||
message: 'All Set Up'
|
||||
|
|
|
@ -92,7 +92,7 @@ router.get('/list/:filter?/:page?', function (req, res) {
|
|||
router.get('/add/new', function (req, res) {
|
||||
if (req.session.user) {
|
||||
//need to grab a few copy of settings for the lastest index
|
||||
fs.readJSON('site/settings.jso')
|
||||
fs.readJSON('site/settings.json')
|
||||
.then(config => {
|
||||
res.render('page-edit', {
|
||||
id: config.library_stats.current_index,
|
||||
|
|
24
site/init/index-template.md
Normal file
24
site/init/index-template.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
id: 1
|
||||
uuid:
|
||||
title: This is the Start
|
||||
feature: /assets/images/global/default-bg.jpg
|
||||
path:
|
||||
layout: index
|
||||
tags: start
|
||||
author:
|
||||
created:
|
||||
updated:
|
||||
deleted: false
|
||||
menu: false
|
||||
featured: false
|
||||
published: false
|
||||
slug: index
|
||||
---
|
||||
# F**k Yes
|
||||
|
||||
You're up and running here are a few notes to get you started.
|
||||
|
||||
One more layout check.
|
||||
|
||||
This page should stay on the root of pages
|
Loading…
Reference in a new issue