2021-12-24 18:17:02 +01:00
|
|
|
import get from 'lodash.get'
|
|
|
|
import orderBy from 'lodash.orderby'
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
// Helper method to filter out the real children
|
2021-12-25 13:43:41 +01:00
|
|
|
const order = obj => orderBy(obj, ['__order', '__title'], ['asc', 'asc'])
|
|
|
|
const currentChildren = current => Object.values(order(current))
|
2021-12-24 18:17:02 +01:00
|
|
|
.filter(entry => (typeof entry === 'object'))
|
|
|
|
|
|
|
|
const ReadMore = props => {
|
|
|
|
|
|
|
|
const root = get(props.app.navigation, props.app.slug.split('/'))
|
|
|
|
const list = []
|
|
|
|
for (const page of currentChildren(root)) {
|
|
|
|
list.push(<li key={page.__slug}>
|
|
|
|
<Link href={`/${page.__slug}`}>
|
|
|
|
<a>{page.__title}</a>
|
|
|
|
</Link>
|
|
|
|
</li>)
|
|
|
|
}
|
|
|
|
return <ul>{list}</ul>
|
|
|
|
}
|
2021-12-19 19:08:54 +01:00
|
|
|
|
|
|
|
export default ReadMore
|
|
|
|
|