Skip to content

Instantly share code, notes, and snippets.

@Macxim
Created October 14, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Macxim/48e73232dbc9fed58bd5b24e0b00d4df to your computer and use it in GitHub Desktop.
Save Macxim/48e73232dbc9fed58bd5b24e0b00d4df to your computer and use it in GitHub Desktop.
import React from "react";
import Head from "next/head";
import Image from 'next/image';
import Prismic from '@prismicio/client';
import { Client } from "../../prismic-configuration";
import { PostList } from "../../components/blog/home";
const Home = ({ blogHome, posts }) => {
return (
<div className="flex flex-col min-h-screen font-sans">
<h1 className="sr-only">{blogHome.data.headline}</h1>
<p className="text-lg text-gray-100">{blogHome.data.description}</p>
<PostList posts={posts} />
</div>
)
};
export async function getStaticProps() {
const blogHome = await Client().getSingle("blog_home") || {}
const posts = await Client().query(Prismic.Predicates.at("document.type", "post"), { orderings: "[my.post.date desc]"})
return {
props: {
blogHome,
posts: posts ? posts.results : [],
}
}
}
export default Home;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment