import * as React from "react" ; import Layout from "../../components/Layout" ; import BlogItem from "../../components/Etc/blog" ; import { getAllPosts } from "../../lib/data" ; import { GetStaticProps } from "next" ; export default function Blog ( { posts } ) { return ( < Layout title = "Blog | DhafitF" metaDesc = "Daftar blog yang diposting oleh Dhafit Farenza" > < div className = "container" > < h2 className = "pageTitle" > Blog < /h2> < div className = "blog_container" style = { { marginBottom : "2rem" } } > { posts . map ( ( blog , index ) => { return ( < BlogItem key = { index } title = { blog . title } subtitle = { blog . subtitle } permalink = { blog . permalink } timestamp = { blog . timestamp } / > ) ; } ) } < /div> < /div> < /Layout>); } export const getStaticProps = async ( ctx ) => { const allPost = getAllPosts ( ) ; const posts = allPost . map ( ( { data , content , permalink } ) => ( { ... data , content , permalink , } ) ) ; return { props : { posts : posts . sort ( ( a , b ) => ( a . order > b . order ? - 1 : 1 ) ) , } , } ; } ;