From cc1e709358f88853a9c355cf6c0d91e171b59915 Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 13 Jul 2020 14:08:29 -0700 Subject: [PATCH] current theme assets are moved to public when rendering pages --- brain/data/Render.js | 3 +++ brain/data/Utils.js | 36 +++++++++++++++++++++++++++++++++++- src/styles/dash.styl | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/brain/data/Render.js b/brain/data/Render.js index a9afc7d..e49e6c9 100644 --- a/brain/data/Render.js +++ b/brain/data/Render.js @@ -3,6 +3,7 @@ import StringUtils from '../../src/com/utils/StringUtils'; import Settings, { SETTINGS_FILE, SETTINGS_TAG } from './Settings'; import fs from 'fs-extra'; import sanitize from 'sanitize-html'; +import Utils from './Utils'; const pug = require('pug'); const md = require('markdown-it')('commonmark'); const _ = require('lodash'); @@ -137,6 +138,8 @@ export default class Render { type: DataEvent.PAGES_RENDERED, message: 'All Pages Rendered. Sweet.' }; + //utils.moveAssets(); + new Utils().moveAssets(); resolve(response); } } else { diff --git a/brain/data/Utils.js b/brain/data/Utils.js index dbd1093..498ff20 100644 --- a/brain/data/Utils.js +++ b/brain/data/Utils.js @@ -1,4 +1,4 @@ -import Settings from './Settings'; +import Settings, { SETTINGS_FILE } from './Settings'; import Render from './Render'; import StringUtils from '../../src/com/utils/StringUtils'; import _ from 'lodash'; @@ -6,6 +6,7 @@ const settings = new Settings(); const render = new Render(); const stringUtils = new StringUtils(); const moment = require('moment'); +const fs = require('fs-extra'); export default class Utils { constructor() {} @@ -93,4 +94,37 @@ export default class Utils { } render.publishArchive(archive); } + moveAssets() { + settings + .load(SETTINGS_FILE) + .then(settings => { + //move css assets to public directory + fs.copy( + 'content/themes/' + settings.global.theme + '/assets/css', + 'public/assets/css', + function (err) { + if (err) { + //console.log('An error occured while copying the folder.', err); + //return console.error(err); + } + //console.log('Copy completed!'); + } + ); + //move js assets to public directory + fs.copy( + 'content/themes/' + settings.global.theme + '/assets/scripts', + 'public/assets/scripts', + function (err) { + if (err) { + //console.log('An error occured while copying the folder.', err); + //return console.error(err); + } + //console.log('Copy completed!'); + } + ); + }) + .catch(() => { + //console.log('ERROR', err); + }); + } } diff --git a/src/styles/dash.styl b/src/styles/dash.styl index 2aac8b4..6c99863 100644 --- a/src/styles/dash.styl +++ b/src/styles/dash.styl @@ -31,7 +31,7 @@ @import 'main/_typography' /** ------------------------------- --- Main Structure +-- Main Structures ------------------------------- * */ @import 'main/_structure'