import { Article } from ".contentlayer/types" ; import Page from "components/pages/tags/base" ; import { getAllArticlesWhichBelongToCurrentSlug } from "lib/get-articles-data" ; import { getAllTags } from "lib/get-tags-data" ; import pick from "lodash/pick" ; import { GetStaticPaths , GetStaticProps , GetStaticPropsContext , NextPage , } from "next" ; interface IProps { articles : Article [ ] ; currentTag : string ; } const TagsListingPage = ( { articles , currentTag } ) => { return < Page articles = { articles } currentTag = { currentTag } / > ; } ; export const getStaticProps = async ( { params , } ) => { const articles = getAllArticlesWhichBelongToCurrentSlug ( params , "tags" ) . map ( ( articles ) => pick ( articles , [ "date" , "description" , "title" , "slug" ] ) ) ; return { props : { articles , currentTag : params ?. slug as string , } , } ; } ; export const getStaticPaths = async ( ) => { return { paths : getAllTags ( ) . map ( ( slug ) => { return { params : { slug , } , } ; } ) , fallback : false , } ; } ; export default TagsListingPage ;