/* eslint-disable react/prop-types */ import { graphql, Link as Link2 } from "gatsby"; import { StaticImage } from "gatsby-plugin-image"; import { Link } from "gatsby-plugin-react-i18next"; import React from "react"; import { useTranslation } from "react-i18next"; import Layout from "../layouts/default"; import * as styles from "./blogListing.module.scss"; const BlogListing = ({ data, pageContext }) => { const { t } = useTranslation(); const title = t(`blog.section.${pageContext.section ?? "blog"}.name`); const description = t( `blog.section.${pageContext.section ?? "blog"}.description` ); const hasSection = typeof pageContext.section !== "undefined"; return (
{hasSection && ( {t("blog.title")} / )}

{title}

{description}

{!hasSection && ( <>

{t("blog.sections")}

{t("blog.section.scambox.name")}
)}

{t("blog.posts")}

{data.posts.nodes.map((post) => { return ( {post.childMdx.frontmatter.title} {t("blog.meta", { date: post.childMdx.frontmatter .published, author: post.childMdx.frontmatter .author.name, })} {post.childMdx.frontmatter.section && !hasSection && ( <> {" | "} {t( `blog.section.${post.childMdx.frontmatter.section}.name` )} )} {" | "} {t( `language.${post.childMdx.frontmatter.language}.name` )} {post.childMdx.excerpt}{" "} {t("blog.readFull")} ); })}
{pageContext.pageNumber > 0 ? ( {t("blog.previous")} ) : ( )} {t("blog.page", { page: pageContext.humanPageNumber, maxPage: pageContext.numberOfPages, })} {pageContext.humanPageNumber < pageContext.numberOfPages ? ( {t("blog.next")} ) : ( )}
); }; export const query = graphql` query ($language: String!, $skip: Int!, $limit: Int!, $section: String) { posts: allFile( filter: { sourceInstanceName: { eq: "blogContent" } childMdx: { frontmatter: { section: { eq: $section } } } } sort: { fields: childMdx___frontmatter___published, order: DESC } limit: $limit skip: $skip ) { nodes { childMdx { frontmatter { platform tags title url published(formatString: "DD.MM.YYYY") urlPublished: published(formatString: "YYYY/MM") section language author { name } } excerpt } } } locales: allLocale(filter: { language: { eq: $language } }) { edges { node { ns data language } } } } `; export default BlogListing;