21 |
{post.title}
22 |

23 |
24 | {RichText.render(post.content)}
25 |
26 | );
27 | }
28 |
29 | export async function getStaticProps(ctx: GetStaticPropsContext) {
30 | const post = await fetchAPI(
31 | `
32 | query($slug: String!, $lang: String!) {
33 | post(uid: $slug, lang: $lang) {
34 | title
35 | thumbnail
36 | content
37 | }
38 | }
39 | `,
40 | {
41 | slug: ctx.params.id,
42 | lang: 'pt-br',
43 | }
44 | );
45 |
46 | return {
47 | props: {
48 | post: post.post,
49 | },
50 | revalidate: 1,
51 | };
52 | }
53 |
54 | export async function getStaticPaths() {
55 | const {
56 | allPosts: { edges },
57 | } = await fetchAPI(
58 | `
59 | query {
60 | allPosts {
61 | edges {
62 | node {
63 | _meta {
64 | uid
65 | }
66 | }
67 | }
68 | }
69 | }
70 | `,
71 | {}
72 | );
73 |
74 | return {
75 | paths: edges.map(({ node }) => `/posts/${node._meta.uid}`) || [],
76 | fallback: false,
77 | };
78 | }
79 |
80 | export default Post;
81 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rocketseat-content/contrib-nextjs/a6ad30078601a05c4aaf07c45d26672e03b799e0/public/favicon.ico
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |