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 Menu = require('./Menu')
const Footer = require('./Footer') 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"> <div className="body-wrapper theme-default">
<header> <header>
<div className="navigation"> <div className="navigation">
@@ -16,10 +22,12 @@ const App = ({children, menu}) => (
<section className="content content_full content--padding-top--menu"> <section className="content content_full content--padding-top--menu">
{children} {children}
</section> </section>
<Comments/>
</main> </main>
<Footer showAuthor={false} <Footer showAuthor={showAuthor}
address="г. Шлиссельбург ул. 18 января д. 3" address=" г. Шлиссельбург ул. 18 января д. 3"
telephone="+7 (81362) 76-312" telephone="+7 (81362) 76-312"
email="hudozka@gmail.com" email="hudozka@gmail.com"
/> />
+2 -2
View File
@@ -3,9 +3,9 @@ import {renderToStaticMarkup} from 'react-dom/server'
const App = require('../components/App') const App = require('../components/App')
function renderApp({menu, component}) { function renderApp({component, ...options}) {
const app = ( const app = (
<App menu={menu}> <App {...options}>
{component} {component}
</App> </App>
) )
+9 -2
View File
@@ -13,6 +13,11 @@ const {compose, any} = require('../lib/common')
const menuModel = require('../models/menu').default const menuModel = require('../models/menu').default
const config = require('../config') const config = require('../config')
const defaultOptions = {
commentsEnabled: false,
showAuthor: false,
}
function isActive(path, menuItem) { function isActive(path, menuItem) {
return isEqualPate(path, menuItem.url, true) return isEqualPate(path, menuItem.url, true)
} }
@@ -63,17 +68,18 @@ const getTitle = meta => 'title' in meta
const isHtml = data => typeof data === 'string' const isHtml = data => typeof data === 'string'
async function render(path, data, meta) { async function render(path, data, meta, options = {}) {
const component = isHtml(data) const component = isHtml(data)
? getHtml(data) ? getHtml(data)
: data : data
const menu = buildMenu(path, menuModel) 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 source = await readFile(config.viewMain, 'utf-8')
const template = handlebars.compile(source) const template = handlebars.compile(source)
const renderOptions = {...defaultOptions, ...options}
const metaData = { const metaData = {
...meta, ...meta,
description: 'Сайт Шлиссельбургской художественной школы', description: 'Сайт Шлиссельбургской художественной школы',
@@ -83,6 +89,7 @@ async function render(path, data, meta) {
return template({ return template({
content, content,
options: renderOptions,
title: getTitle(meta), title: getTitle(meta),
meta: metaData, meta: metaData,
}) })
+1 -1
View File
@@ -115,7 +115,7 @@ function getArticle() {
) )
ctx.type = 'text/html' ctx.type = 'text/html'
ctx.body = await render(path, Component, getMeta(article)) ctx.body = await render(path, Component, getMeta(article), {commentsEnabled: true})
} else { } else {
ctx.status = 404 ctx.status = 404
} }
+1 -1
View File
@@ -81,7 +81,7 @@ function getHome(pageSize) {
</div> </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()); script.setAttribute('data-timestamp', Date.now());
(document.head || document.body).appendChild(script); (document.head || document.body).appendChild(script);
} }
const doInitDisqus = false const doInitDisqus = {{options.commentsEnabled}}
if (doInitDisqus) initDisqus() if (doInitDisqus) initDisqus()
</script> </script>
</body> </body>