import Page from 'site/components/wrappers/page.js' import useApp from 'site/hooks/useApp.js' import Link from 'next/link' import TimeAgo from 'react-timeago' import { strapiHost } from 'shared/config/freesewing.mjs' import { strapiImage } from 'shared/utils.js' import { useTranslation } from 'next-i18next' import { serverSideTranslations } from 'next-i18next/serverSideTranslations' const strapi = "https://posts.freesewing.org" const Preview = ({ app, post }) => (
{post.title}

by {post.author}

) const BlogIndexPage = (props) => { const app = useApp() const { t } = useTranslation() return (
{props.posts.map(post => ) }
) } export default BlogIndexPage /* * getStaticProps() is used to fetch data at build-time. * * On this page, it is loading the blog content from strapi. * * This, in combination with getStaticPaths() below means this * page will be used to render/generate all blog content. * * To learn more, see: https://nextjs.org/docs/basic-features/data-fetching */ export async function getStaticProps({ params, locale }) { const posts = await fetch( `${strapiHost}/blogposts?_locale=${locale}&_sort=date:DESC&dev_ne=true` ) .then(response => response.json()) .then(data => data) .catch(err => console.log(err)) return { props: { posts: posts.map(post => ({ slug: post.slug, title: post.title, date: post.date, author: post.author.displayname, image: strapiImage(post.image, ['medium']), })), ...(await serverSideTranslations(locale)), } } }