diff --git a/sites/org/page-templates/docs.mjs.mustache b/sites/org/page-templates/docs.mjs.mustache index d73f56f306c..b1dcbfe12b9 100644 --- a/sites/org/page-templates/docs.mjs.mustache +++ b/sites/org/page-templates/docs.mjs.mustache @@ -75,7 +75,7 @@ export default DocsPage export async function getStaticProps({ locale }) { return { props: { - ...(await serverSideTranslations(locale, ns)), + ...(await serverSideTranslations(locale, ['docs', ...ns])), locale, page: { locale, diff --git a/sites/org/pages/docs/docs.en.yaml b/sites/org/pages/docs/docs.en.yaml index e6601d7e4ca..1d6d3d37afb 100644 --- a/sites/org/pages/docs/docs.en.yaml +++ b/sites/org/pages/docs/docs.en.yaml @@ -1 +1,20 @@ +account: Account docs: Documentation +controltip.t: Power versus Simplicity +controltip.d1: The Power versus Simplicity setting of your FreeSewing account will impact how you experience the FreeSewing website. +controltip.d2: By default, some of the more advanced features of this site are hidden to make it more easy for new users to find their way. +controltip.d3: If you want to sacrify some of that simplicy to gain more power, you can update your Power versus Simplicity setting accordingly. +helpWithDocs: Help us improve our documentation +authors: Authors +maintainers: Maintainers +lastUpdated: Last updated +editThisPage: Edit this page +years: years +months: months +days: days +oneDay: one day +lessThanADay: less than a day +ago: ago +helpImproveDocs: Help us improve the FreeSewing documentation +helpTranslateDocs: Help us translate the FreeSewing documentation +learnMore: Learn more diff --git a/sites/shared/components/account/account.en.yaml b/sites/shared/components/account/account.en.yaml index af205952b77..b96ff74d343 100644 --- a/sites/shared/components/account/account.en.yaml +++ b/sites/shared/components/account/account.en.yaml @@ -98,10 +98,6 @@ control5t: Get out of my way control5d: Reveals all features, removes all handrails and safety checks. controlShowMore: Show more options controlTitle: What do you prefer? -controltip.d1: The Power versus Simplicity setting of your FreeSewing account will impact how you experience the FreeSewing website. -controltip.d2: By default, some of the more advanced features of this site are hidden to make it more easy for new users to find their way. -controltip.d3: If you want to sacrify some of that simplicy to gain more power, you can update your Power versus Simplicity setting accordingly. - # img imgTitle: How about a picture? imgDragAndDropImageHere: Drag and drop an image here diff --git a/sites/shared/components/control/tip.mjs b/sites/shared/components/control/tip.mjs index ed47d2a209d..8dce1f9fe1f 100644 --- a/sites/shared/components/control/tip.mjs +++ b/sites/shared/components/control/tip.mjs @@ -3,14 +3,14 @@ import { PageLink } from 'shared/components/page-link.mjs' import { useTranslation } from 'next-i18next' import { RightIcon } from 'shared/components/icons.mjs' -export const ns = ['account'] +export const ns = ['docs'] export const ControlTip = () => { const { t } = useTranslation(ns) return ( -
{t('account:control')}
+
{t('controltip.t')}

{t('controltip.d2')} @@ -18,9 +18,9 @@ export const ControlTip = () => { {t('controltip.d3')}

- + - +
) diff --git a/sites/shared/components/mdx/index.mjs b/sites/shared/components/mdx/index.mjs index 007d1911111..91f51a0448a 100644 --- a/sites/shared/components/mdx/index.mjs +++ b/sites/shared/components/mdx/index.mjs @@ -2,7 +2,7 @@ import { Popout } from 'shared/components/popout.mjs' import { Highlight } from './highlight.mjs' import { YouTube } from './youtube.mjs' import { Figure } from './figure.mjs' -//import { ReadMore } from './read-more.mjs' +import { ReadMore } from './read-more.mjs' import { Tab, Tabs } from './tabs.mjs' import { TabbedExample as Example } from './tabbed-example.mjs' import { HttpMethod, HttpStatusCode } from './http.mjs' @@ -18,7 +18,7 @@ export const components = { Fixme: (props) => , Link: (props) => , Note: (props) => , - ReadMore: (props) => ReadMore is not implemented (yet) in v3, + ReadMore, Related: (props) => , Tip: (props) => , Warning: (props) => , diff --git a/sites/shared/components/mdx/read-more.mjs b/sites/shared/components/mdx/read-more.mjs index a469e3b85fb..4d4141b609f 100644 --- a/sites/shared/components/mdx/read-more.mjs +++ b/sites/shared/components/mdx/read-more.mjs @@ -1,15 +1,16 @@ import get from 'lodash.get' import orderBy from 'lodash.orderby' import Link from 'next/link' +import { useContext } from 'react' +import { NavigationContext } from 'shared/context/navigation-context.mjs' // Helper method to filter out the real children const order = (obj) => orderBy(obj, ['o', 't'], ['asc', 'asc']) const currentChildren = (current) => Object.values(order(current)).filter((entry) => typeof entry === 'object') -export const ReadMore = ({ app, recurse = 0, slug = false }) => { - // Don't bother if we don't have the navigation tree in app - if (!app) return null +export const ReadMore = ({ app, recurse = 0 }) => { + const { nav, slug } = useContext(NavigationContext) // Deal with recurse not being a number if (recurse) { @@ -17,9 +18,7 @@ export const ReadMore = ({ app, recurse = 0, slug = false }) => { else recurse = 1 } - const root = - slug && slug !== 'docs' ? get(app.state.nav, slug.split('/').slice(1)) : app.state.nav - console.log(root) + const root = slug && slug !== 'docs' ? get(nav, slug.split('/').slice(1)) : nav const list = [] for (const page of currentChildren(root)) { @@ -30,5 +29,6 @@ export const ReadMore = ({ app, recurse = 0, slug = false }) => { ) } + return
    {list}
} diff --git a/sites/shared/components/wrappers/mdx.mjs b/sites/shared/components/wrappers/mdx.mjs index 7d8654eb7d4..54130900a82 100644 --- a/sites/shared/components/wrappers/mdx.mjs +++ b/sites/shared/components/wrappers/mdx.mjs @@ -1,14 +1,115 @@ // Components that are available in MDX content import { components as baseComponents } from 'shared/components/mdx/index.mjs' +// List of authors +import { authors as allAuthors } from 'config/authors.mjs' +// FreeSewing config +import { freeSewingConfig } from 'shared/config/freesewing.config.mjs' +// Components +import { PageLink } from 'shared/components/page-link.mjs' +import { WebLink } from 'shared/components/web-link.mjs' +import { DateTime, Interval } from 'luxon' +import { DocsIcon } from 'shared/components/icons.mjs' +// Context +import { useContext } from 'react' +import { NavigationContext } from 'shared/context/navigation-context.mjs' +// Hooks +import { useTranslation } from 'next-i18next' // Previous-Next navigation //import { PrevNext } from '../mdx/prev-next.mjs' +// +// +const TimeAgo = ({ date, t }) => { + const i = Interval.fromDateTimes(DateTime.fromISO(date), DateTime.now()) + .toDuration(['hours', 'days', 'months', 'years']) + .toObject() + let ago = '' + if (i.years > 0) ago += `${i.years} ${t('years')}, ` + if (i.months > 0) ago += `${i.months} ${t('months')}, ` + if (Math.floor(i.days) === 1) ago += `${t('oneDay')}` + else if (Math.floor(i.days) === 0) ago += `${t('lessThanADay')}` + else ago += `${Math.floor(i.days)} days` + + return `${ago} ${t('ago')}` +} + +const PersonList = ({ list }) => + list.map((id, i) => ( +
  • + {allAuthors[id] ? ( + + ) : ( + {id} + )} + {i !== list.length - 1 ? ',' : |} +
  • + )) +const Ul = ({ children }) => ( +
      + {children} +
    +) + +const MetaData = ({ authors = [], maintainers = [], updated = '20220825', locale, slug, t }) => ( +
    + {locale === 'en' ? ( +
    + {t('helpImproveDocs')} + + ✏️ + {t('editThisPage')} + +
    + ) : ( +
    + {t('helpTranslateDocs')} + + 💡 + {t('learnMore')} + +
    + )} +
    +
      + {authors.length > 0 ? ( + <> +
    • {t('authors')}:
    • + + + ) : null} + + {maintainers.length > 0 ? ( + <> +
    • {t('maintainers')}:
    • + + + ) : null} + +
    • {t('lastUpdated')}:
    • +
    • + +
    • +
    +
    +
    +) export const MdxWrapper = ({ MDX, frontmatter = {}, components = {} }) => { + const { t } = useTranslation('docs') const allComponents = { ...baseComponents, ...components } + const { locale, slug } = useContext(NavigationContext) + + const { authors = [], maintainers = [] } = frontmatter || {} return (
    +
    )