// Dependencies import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { pages as posts } from 'site/prebuild/blog.mjs' import { meta } from 'site/prebuild/blog-meta.mjs' import { cloudflareImageUrl } from 'shared/utils.mjs' import { nsMerge } from 'shared/utils.mjs' // Hooks import { useTranslation } from 'next-i18next' // Components import Link from 'next/link' import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs' // Translation namespaces used on this page const namespaces = nsMerge('designs', 'sections', pageNs) // Helper object to order posts const order = {} let i = 0 // Avoid posts with same date not showing up for (const [slug, props] of Object.entries(meta)) { i++ order[props.d + i] = slug } export const recentBlogPosts = Object.keys(order) .sort() .reverse() .slice(0, 2) .map((d) => order[d]) const textShadow = { style: { textShadow: '1px 1px 1px #000000, -1px -1px 1px #000000, 1px -1px 1px #000000, -1px 1px 1px #000000, 2px 2px 1px #000000', }, } /* eslint-disable @next/next/no-img-element */ export const BlogPreview = ({ post }) => ( {post.caption}
{post.t}
) /* * 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. */ const BlogIndexPage = ({ page }) => { const { t } = useTranslation() return (
{Object.keys(order) .sort() .reverse() .map((date) => ( ))}
) } export default BlogIndexPage /* * getStaticProps() is used to fetch data at build-time. * * On this page, it fetches data for the blogs to be linked to on this page * * This, in combination with getStaticPaths() below means this * page will be used to link to all blogs. * * 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: ['blog'], }, }, } }