@@ -16,10 +22,12 @@ const App = ({children, menu}) => (
+
+
-
diff --git a/src/lib/component.js b/src/lib/component.js
index 54ba3de1..f8c6eaff 100644
--- a/src/lib/component.js
+++ b/src/lib/component.js
@@ -3,9 +3,9 @@ import {renderToStaticMarkup} from 'react-dom/server'
const App = require('../components/App')
-function renderApp({menu, component}) {
+function renderApp({component, ...options}) {
const app = (
-
+
{component}
)
diff --git a/src/lib/render.js b/src/lib/render.js
index 95d42f97..c4bb80bc 100644
--- a/src/lib/render.js
+++ b/src/lib/render.js
@@ -13,6 +13,11 @@ const {compose, any} = require('../lib/common')
const menuModel = require('../models/menu').default
const config = require('../config')
+const defaultOptions = {
+ commentsEnabled: false,
+ showAuthor: false,
+}
+
function isActive(path, menuItem) {
return isEqualPate(path, menuItem.url, true)
}
@@ -63,17 +68,18 @@ const getTitle = meta => 'title' in meta
const isHtml = data => typeof data === 'string'
-async function render(path, data, meta) {
+async function render(path, data, meta, options = {}) {
const component = isHtml(data)
? getHtml(data)
: data
const menu = buildMenu(path, menuModel)
- const content = renderApp({menu, component})
+ const content = renderApp({...options, menu, component})
const source = await readFile(config.viewMain, 'utf-8')
const template = handlebars.compile(source)
+ const renderOptions = {...defaultOptions, ...options}
const metaData = {
...meta,
description: 'Сайт Шлиссельбургской художественной школы',
@@ -83,6 +89,7 @@ async function render(path, data, meta) {
return template({
content,
+ options: renderOptions,
title: getTitle(meta),
meta: metaData,
})
diff --git a/src/routes/articles.js b/src/routes/articles.js
index d09f5e41..9d267707 100644
--- a/src/routes/articles.js
+++ b/src/routes/articles.js
@@ -115,7 +115,7 @@ function getArticle() {
)
ctx.type = 'text/html'
- ctx.body = await render(path, Component, getMeta(article))
+ ctx.body = await render(path, Component, getMeta(article), {commentsEnabled: true})
} else {
ctx.status = 404
}
diff --git a/src/routes/home.js b/src/routes/home.js
index b907080d..910beb8e 100644
--- a/src/routes/home.js
+++ b/src/routes/home.js
@@ -81,7 +81,7 @@ function getHome(pageSize) {
)
- ctx.body = await render(path, Component, getMeta({title: 'Шлиссельбургская ДХШ'}))
+ ctx.body = await render(path, Component, getMeta({title: 'Шлиссельбургская ДХШ'}), {showAuthor: true})
})
}
diff --git a/src/views/main.hbs b/src/views/main.hbs
index 8a833eaa..293caa2d 100644
--- a/src/views/main.hbs
+++ b/src/views/main.hbs
@@ -87,7 +87,7 @@
script.setAttribute('data-timestamp', Date.now());
(document.head || document.body).appendChild(script);
}
- const doInitDisqus = false
+ const doInitDisqus = {{options.commentsEnabled}}
if (doInitDisqus) initDisqus()