import Head from 'next/head' import { PageLink } from 'shared/components/page-link.mjs' import { Lightbox } from 'shared/components/lightbox.mjs' import { ImageWrapper } from 'shared/components/wrappers/img.mjs' import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' import { Author } from './author.mjs' import { TimeAgo } from 'shared/components/wrappers/mdx.mjs' import { SanityMdxWrapper } from './mdx-wrapper.mjs' import { useTranslation } from 'next-i18next' import { siteConfig } from 'site/site.config.mjs' import { sanityLoader } from 'site/components/sanity/utils.mjs' export const ns = ['common', 'posts', ...pageNs] export const SanityPageWrapper = ({ post = {}, author = {}, page = {}, namespaces = ['common'], slug, }) => { const { t } = useTranslation(namespaces) console.log({ slug }) return (
[{post.date}]
{post.designs?.map((design) => ( ))}
By{' '} {author.displayname || 'FIXME: No displayname'}
{post.caption}
) } export const getSanityStaticPaths = (type) => { return async () => { const filter = `{"slug": slug.current, _type}` const query = ` *[_type in [${siteConfig.languages.map((l) => `"${type}${l}"`).join(', ')}]] ${filter}` const allPosts = await sanityLoader({ query }).catch((err) => console.log(err)) return { paths: allPosts.map((p) => { const lng = p._type.replace(type, '') return `${lng === 'en' ? '' : '/' + lng}/${type}/${p.slug}` }), fallback: false, } } }