// Dependencies import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { pages as posts } from 'site/prebuild/showcase.mjs' import { nsMerge, cloudflareImageUrl, capitalize, horFlexClasses } from 'shared/utils.mjs' import { examples } from 'site/prebuild/design-examples.mjs' // Hooks import { useTranslation } from 'next-i18next' import { useFilter } from 'shared/components/designs/design-picker.mjs' // Components import Link from 'next/link' import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' import { BareLayout } from 'site/components/layouts/bare.mjs' import { ResetIcon } from 'shared/components/icons.mjs' // Translation namespaces used on this page const namespaces = nsMerge('common', 'designs', 'tags', pageNs) const count = Object.values(examples).reduce((acc, val) => Array.isArray(acc) ? acc.length + val.length : acc + val.length ) /* * 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. */ /* eslint-disable @next/next/no-img-element */ const ShowcaseIndexPage = ({ page }) => { const { t } = useTranslation() const [filter, setFilter] = useFilter() const list = filter && examples[filter] ? examples[filter].map((id) => `showcase/${id}`) : Object.keys(posts[page.locale]) return (

FreeSewing - {t('sections:showcase')}

{filter && examples[filter] ? ( <> ) : ( {count}/{count} )}

{Object.keys(examples) .sort() .map((design) => ( ))}
{list.map((slug) => ( {slug} ))}
) } export default ShowcaseIndexPage /* * getStaticProps() is used to fetch data at build-time. * * On this page, it fetches data for the showcases to be linked to on this page * * This, in combination with getStaticPaths() below means this * page will be used to link to all showcases. * * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching */ export async function getStaticProps({ locale }) { return { props: { ...(await serverSideTranslations(locale, namespaces)), page: { locale, path: ['showcase'], }, }, } }