Test
27 Des 2022By Mihdan AdvaniReading time ± 1 min
tes | s | ssfsf | header |
dds | svs | vsvsv | ok |
aas | sas | as | asa |
as | asass | dsd | dsd |
okeee
ini copy
ini bbiassaja
ini quote
ini link
import { hygraph } from "@/lib/hygraph";
import { gql } from "graphql-request";
import { notFound } from "next/navigation";
import { formatDate } from "@/lib/format";
import RichText from "@/components/RichText";
export const revalidate = 60;
// pre-generate daftar slug
export async function generateStaticParams() {
const { posts } = await hygraph.request<{ posts: { slug: string }[] }>(gql`
query {
posts(stage: PUBLISHED, where: { slug_not: null }) {
slug
}
}
`);
return posts.map((p) => ({ slug: p.slug }));
}
const POST = gql`
query PostBySlug($slug: String!) {
post(stage: PUBLISHED, where: { slug: $slug }) {
title
date
coverImage {
url
}
content {
html
}
}
}
`;
import { hygraph } from "@/lib/hygraph";
import { gql } from "graphql-request";
import { notFound } from "next/navigation";
import { formatDate } from "@/lib/format";
import RichText from "@/components/RichText";
Method | Route | Description |
---|---|---|
GET | /books | Mengambil semua buku. |
POST | /book/new | Membuat buku baru. |
GET | /book/:id | Mengambil detail buku. |
PUT | /book/update/:id | Mengupdate buku. |
DELETE | /book/delete/:id | Menghapus buku. |
Method | Route | Description |
---|---|---|
GET | /books | Mengambil semua buku. |
POST | /book/new | Membuat buku baru. |
GET | /book/:id | Mengambil detail buku. |
PUT | /book/update/:id | Mengupdate buku. |
DELETE | /book/delete/:id | Menghapus buku. |