Skip to content
Snippets Groups Projects
News.tsx 1.26 KiB
Newer Older
tovo's avatar
tovo committed
import React from "react";
import { Link } from "gatsby";
import { IGatsbyImageData } from "gatsby-plugin-image";

import CardList from "./core/CardList";
tovo's avatar
tovo committed
import Button from "./core/Button";
tovo's avatar
tovo committed

interface INew {
    title?: string;
    content?: string;
    image?: string | IGatsbyImageData;
    to?: string;
}

interface Props {
tovo's avatar
tovo committed
    title?: string;
tovo's avatar
tovo committed
    news?: INew[];
tovo's avatar
tovo committed
    action?: {
tovo's avatar
tovo committed
        title?: string;
        to?: string;
        classname?: string;
tovo's avatar
tovo committed
    };
    anime?: boolean;
tovo's avatar
tovo committed
}


tovo's avatar
tovo committed
const News = (props: Props) => {
    const {
        title = '',
        news = [],
        anime = true,
        action
    } = props;

tovo's avatar
tovo committed
    return (
        <>
tovo's avatar
tovo committed
            <h2 className="mt-2 text-3xl font-extrabold tracking-tight sm:text-4xl mb-8">{title}</h2>
tovo's avatar
tovo committed
            <CardList 
                cards={news} 
                layout='grid'
tovo's avatar
tovo committed
                anime={anime}
tovo's avatar
tovo committed
            />
            <div className="flex justify-center mt-8">
tovo's avatar
tovo committed
                {
                    action && (
                        <Button 
                            title={action.title}
                            to={action.to}
tovo's avatar
tovo committed
                            className={action.classname}
tovo's avatar
tovo committed
                        />
                    )
                }
tovo's avatar
tovo committed
            </div>
        </>
    )
};


export default News;