Commit 4d585ba0 authored by Florian Pagnoux's avatar Florian Pagnoux
Browse files

Generate minimalist pages word WP integration

parent 3f26fc41
import stylesheet from '../styles/style.css'
const isProd = process.env.PRODUCTION;
const Layout = ({children, fullWidth}) => (
const StagingLayout = ({children, fullWidth}) => (
<div>
<style dangerouslySetInnerHTML={{ __html: stylesheet }} />
<header id="main-header" className="main-header" role="banner">
<div className="inner">
<h1>
......@@ -55,4 +53,8 @@ const Layout = ({children, fullWidth}) => (
</div>
)
const ProdLayout = ({children}) => (<div>{ children }</div>)
const Layout = isProd ? ProdLayout : StagingLayout
export default Layout
import Document, { Head, Main, NextScript } from 'next/document'
const basename = process.env.BASENAME || ''
const isProd = process.env.PRODUCTION
export default class MyDocument extends Document {
class StagingDocument extends Document {
render() {
return (
<html>
......@@ -18,3 +19,13 @@ export default class MyDocument extends Document {
)
}
}
class ProdDocument extends Document {
render() {
return <Main />
}
}
const MyDocument = isProd ? ProdDocument : StagingDocument
export default MyDocument
......@@ -6,6 +6,9 @@ import includes from 'lodash.includes'
import flow from 'lodash.flow';
import sortBy from 'lodash.sortby';
const isProd = process.env.PRODUCTION
const basename = process.env.BASENAME || ''
function renderSubParams(item, key, path) {
const shouldSort = ! isArray(item.subparams) // A specific order has been explicitly defined in the conf
const subParams = flow([
......@@ -31,26 +34,37 @@ function renderItem(item, key, path) {
</li>
}
if (item.table) {
return <li key={key}><a href={`${path}${key}`}>{item.title || item.table.description || item.table.id}</a></li>
return <li key={key}><a href={`/${path}${key}`}>{item.title || item.table.description || item.table.id}</a></li>
}
}
function renderSectionContent(subParams, path) {
return (
<div>
<h4>Sommaire</h4>
<ol>
{map(subParams, subParam => renderItem(subParam, subParam.name, `${basename}${path}`))}
</ol>
</div>)
}
const Section = (props) => {
const section = props.router.query
const path = props.router.asPath.endsWith('/') ? props.router.asPath : props.router.asPath + '/'
const basename = process.env.BASENAME || ''
const subParams = flow([
x => map(x, (subParam, name) => Object.assign({}, subParam, {name})),
x => sortBy(x, subParam => section?.metadata?.order.indexOf(subParam.name))
])(section.subparams)
if (isProd) {
return renderSectionContent(subParams, path)
}
return <Layout>
<h1 className="box"><span>{section.title}</span></h1>
<div className="entry-content text">
<h4>Sommaire</h4>
<ol>
{map(subParams, subParam => renderItem(subParam, subParam.name, `${basename}${path}`))}
</ol>
{renderSectionContent(subParams, path)}
</div>
</Layout>
}
......
......@@ -6,6 +6,7 @@ import Layout from '../components/Layout'
const TablePage = (props) => {
const parameter = props.router.query
return <Layout fullWidth={ true }>
<h1 className="box"><span>{parameter.description}</span></h1>
<ParameterTable parameter={parameter}/>
</Layout>
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment