1
0
Fork 0
freesewing/sites/lab/pages/index.mjs

78 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-05-17 17:04:15 +02:00
// Dependencies
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
2023-10-20 16:41:03 +02:00
import { nsMerge, capitalize } from 'shared/utils.mjs'
2023-05-26 11:38:27 +02:00
// Hooks
import { useTranslation } from 'next-i18next'
2023-10-20 16:41:03 +02:00
import { collection } from 'site/hooks/use-design.mjs'
2023-05-17 17:04:15 +02:00
// Components
2023-05-26 11:38:27 +02:00
import Head from 'next/head'
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
2023-10-20 16:41:03 +02:00
import { WebLink, PageLink } from 'shared/components/link.mjs'
2023-05-17 17:04:15 +02:00
2023-10-20 16:41:03 +02:00
const ns = nsMerge('lab', 'designs', pageNs, popoutNs)
2023-05-17 17:04:15 +02:00
/*
* Each page MUST be wrapped in the PageWrapper component.
* You also MUST spread props.page into this wrapper component
* when path and locale come from static props (as here)
* or set them manually.
*/
2023-05-26 11:38:27 +02:00
const HomePage = ({ page }) => {
const { t } = useTranslation(ns)
return (
2023-10-20 17:15:13 +02:00
<PageWrapper {...page} footer={false}>
2023-05-26 11:38:27 +02:00
<Head>
<title>{t('lab:welcome')}</title>
</Head>
<div>
2023-10-20 16:41:03 +02:00
<div className="max-w-4xl m-auto">
<h1>{t('lab:welcome')}</h1>
<h2>{t('lab:designs')}</h2>
<div className="flex flex-row flex-wrap gap-1 justify-start font-medium leading-5">
{collection.sort().map((d) => (
<PageLink key={d} href={`/new/${d}`} txt={capitalize(d)} />
))}
</div>
<h2>{t('lab:docs')}</h2>
<ul className="list list-inside list-disc">
<li>
<WebLink href="https://freesewing.org/" txt="FreeSewing.org" />
<br />
<small className="pl-4">{t('lab:orgDocs')}</small>
</li>
<li>
<WebLink href="https://freesewing.dev/" txt="FreeSewing.dev" />
<br />
<small className="pl-4">{t('lab:devDocs')}</small>
<br />
<small className="pl-4 opacity-70">
<em>({t('lab:enOnly')})</em>
</small>
</li>
</ul>
<h2>{t('lab:support')}</h2>
<p>
<WebLink href="https://freesewing.org/support" txt={t('lab:supportMsg')} />
</p>
<h2>{t('lab:about')}</h2>
<p>{t('lab:what')}</p>
2023-05-26 11:38:27 +02:00
</div>
2023-05-17 17:04:15 +02:00
</div>
2023-05-26 11:38:27 +02:00
</PageWrapper>
)
}
2023-05-17 17:04:15 +02:00
export default HomePage
export async function getStaticProps({ locale }) {
return {
props: {
2023-05-26 11:38:27 +02:00
...(await serverSideTranslations(locale, ns)),
2023-05-17 17:04:15 +02:00
page: {
locale,
path: [],
},
},
}
}