Commit dd522b54 authored by Florian Pagnoux's avatar Florian Pagnoux
Browse files

Use relative links

parent c316d568
...@@ -16,7 +16,8 @@ function renderSubParams(item, key, path) { ...@@ -16,7 +16,8 @@ function renderSubParams(item, key, path) {
if (item.exclude && includes(item.exclude, subParam.name)) { if (item.exclude && includes(item.exclude, subParam.name)) {
return return
} }
return renderItem(subParam, subParam.name, `${path}${key}/`) const target = path ? `${path}/${key}` : key
return renderItem(subParam, subParam.name, target)
}) })
} }
...@@ -30,13 +31,13 @@ function renderItem(item, key, path) { ...@@ -30,13 +31,13 @@ function renderItem(item, key, path) {
</li> </li>
} }
if (item.table) { if (item.table) {
return <li key={key}><a href={`${path}${key}`}>{item.title || item.table.description || item.table.id}</a></li> const target = path ? `${path}/${key}` : key
return <li key={key}><a href={target}>{item.title || item.table.description || item.table.id}</a></li>
} }
} }
const Section = (props) => { const Section = (props) => {
const section = props.router.query const section = props.router.query
const path = props.router.asPath.endsWith('/') ? props.router.asPath : props.router.asPath + '/'
const subParams = flow([ const subParams = flow([
x => map(x, (subParam, name) => Object.assign({}, subParam, {name})), x => map(x, (subParam, name) => Object.assign({}, subParam, {name})),
x => sortBy(x, subParam => section?.metadata?.order.indexOf(subParam.name)) x => sortBy(x, subParam => section?.metadata?.order.indexOf(subParam.name))
...@@ -47,7 +48,7 @@ const Section = (props) => { ...@@ -47,7 +48,7 @@ const Section = (props) => {
<div className="entry-content text"> <div className="entry-content text">
<h4>Sommaire</h4> <h4>Sommaire</h4>
<ol> <ol>
{map(subParams, subParam => renderItem(subParam, subParam.name, path))} {map(subParams, subParam => renderItem(subParam, subParam.name, ''))}
</ol> </ol>
</div> </div>
</Layout> </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