Flexibility changes with App, main.hbs

This commit is contained in:
tmshv committed 2017-05-22 12:55:52 +03:00
1 parent be84058aba
commit 7bc34f9710
6 files changed
+25 -10

No files matched your search

+11 -3
View File
@@ -2,7 +2,13 @@ const React = require('react')
const Menu = require('./Menu')
const Footer = require('./Footer')
const App = ({children, menu}) => (
const Comments = () => (
<div className="content content_semi-wide">
<div id="disqus_thread"></div>
</div>
)
const App = ({children, menu, showAuthor}) => (
<div className="body-wrapper theme-default">
<header>
<div className="navigation">
@@ -16,10 +22,12 @@ const App = ({children, menu}) => (
<section className="content content_full content--padding-top--menu">
{children}
</section>
<Comments/>
</main>
<Footer showAuthor={false}
address="г. Шлиссельбург ул. 18 января д. 3"
<Footer showAuthor={showAuthor}
address=" г. Шлиссельбург ул. 18 января д. 3"
telephone="+7 (81362) 76-312"
email="hudozka@gmail.com"
/>
+2 -2
View File
@@ -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 = (
<App menu={menu}>
<App {...options}>
{component}
</App>
)
+9 -2
View File
@@ -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,
})
+1 -1
View File
@@ -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
}
+1 -1
View File
@@ -81,7 +81,7 @@ function getHome(pageSize) {
</div>
)
ctx.body = await render(path, Component, getMeta({title: 'Шлиссельбургская ДХШ'}))
ctx.body = await render(path, Component, getMeta({title: 'Шлиссельбургская ДХШ'}), {showAuthor: true})
})
}
+1 -1
View File
@@ -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()
</script>
</body>