fix(org): Port mdx components for pattern docs
This commit is contained in:
parent
0d0a19e488
commit
e58e654f21
3 changed files with 104 additions and 150 deletions
|
@ -3,7 +3,7 @@ import { useTranslation } from 'next-i18next'
|
|||
import orderBy from 'lodash.orderby'
|
||||
import PageLink from 'shared/components/page-link.js'
|
||||
|
||||
const PatternMeasurements = (props) => {
|
||||
const PatternMeasurements = ({ pattern, before=null, after=null }) => {
|
||||
const { t } = useTranslation(['measurements'])
|
||||
|
||||
const sortMeasurements = (measurements) => {
|
||||
|
@ -22,13 +22,13 @@ const PatternMeasurements = (props) => {
|
|||
}
|
||||
|
||||
const measurements = {}
|
||||
for (const m of configs[props.pattern].measurements) {
|
||||
for (const m of configs[pattern].measurements) {
|
||||
measurements[m] = {
|
||||
title: t(`measurements.${m}`),
|
||||
required: true
|
||||
}
|
||||
}
|
||||
for (const m of configs[props.pattern].measurements || []) {
|
||||
for (const m of configs[pattern].measurements || []) {
|
||||
measurements[m] = {
|
||||
name: m,
|
||||
title: t(`measurements:${m}`),
|
||||
|
@ -36,15 +36,21 @@ const PatternMeasurements = (props) => {
|
|||
}
|
||||
}
|
||||
|
||||
// Not all patterns require measurements
|
||||
if (Object.keys(measurements).length < 1) return null
|
||||
|
||||
return (
|
||||
<ol className="list-inside ml-8 my-4">
|
||||
{orderBy(measurements, ['title'], ['asc']).map(m => (
|
||||
<li key={m.name}>
|
||||
<PageLink href={'/docs/measurements/' + m.name.toLowerCase()} txt={m.title} />
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
<div>
|
||||
{before}
|
||||
<ol className="list-inside ml-8 my-4">
|
||||
{orderBy(measurements, ['title'], ['asc']).map(m => (
|
||||
<li key={m.name}>
|
||||
<PageLink href={'/docs/measurements/' + m.name.toLowerCase()} txt={m.title} />
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
{after}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue