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) {
if (item.exclude && includes(item.exclude, subParam.name)) {
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) {
</li>
}
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.router.query
const path = props.router.asPath.endsWith('/') ? props.router.asPath : props.router.asPath + '/'
const subParams = flow([
x => map(x, (subParam, name) => Object.assign({}, subParam, {name})),
x => sortBy(x, subParam => section?.metadata?.order.indexOf(subParam.name))
......@@ -47,7 +48,7 @@ const Section = (props) => {
<div className="entry-content text">
<h4>Sommaire</h4>
<ol>
{map(subParams, subParam => renderItem(subParam, subParam.name, path))}
{map(subParams, subParam => renderItem(subParam, subParam.name, ''))}
</ol>
</div>
</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