Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
French Tax and Benefit Tables
baremes-ipp-views
Commits
4d585ba0
Commit
4d585ba0
authored
Feb 07, 2019
by
Florian Pagnoux
Browse files
Generate minimalist pages word WP integration
parent
3f26fc41
Changes
4
Hide whitespace changes
Inline
Side-by-side
components/Layout.js
View file @
4d585ba0
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
pages/_document.js
View file @
4d585ba0
import
Document
,
{
Head
,
Main
,
NextScript
}
from
'
next/document
'
const
basename
=
process
.
env
.
BASENAME
||
''
const
isProd
=
process
.
env
.
PRODUCTION
export
default
class
My
Document
extends
Document
{
class
Staging
Document
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
pages/section.js
View file @
4d585ba0
...
...
@@ -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
>
}
...
...
pages/table.js
View file @
4d585ba0
...
...
@@ -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
>
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment