-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from johanesPao/dev
Pengerjaan Tulisan dan TulisanCard dan markdown
- Loading branch information
Showing
10 changed files
with
1,980 additions
and
237 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const SkeletonTulisan = () => { | ||
return ( | ||
<div className="w-full p-2 first:pt-0 last:pb-0"> | ||
<div className="flex flex-col animate-pulse gap-2"> | ||
<div className="rounded-sm bg-emerald-950 h-8 max-w-[300px]"></div> | ||
<div className="rounded-sm bg-stone-800 h-3 max-w-[240px]"></div> | ||
<div className="rounded-sm bg-zinc-800 h-3 max-w-[180px]"></div> | ||
<div className="rounded-sm bg-zinc-800 h-3 max-w-[160px]"></div> | ||
<div className="rounded-sm bg-zinc-800 h-3 max-w-[190px]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[70rem]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[72rem]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[68rem]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[70rem]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[71rem]"></div> | ||
<div className="rounded-sm bg-zinc-700 h-4 max-w-[66rem]"></div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default SkeletonTulisan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,60 @@ | ||
import { useParams } from "react-router-dom"; | ||
import Markdown from 'react-markdown'; | ||
import remarkGfm from "remark-gfm"; | ||
import remarkMath from "remark-math"; | ||
import rehypeKatex from "rehype-katex"; | ||
import 'katex/dist/katex.min.css'; | ||
import { TulisanProps } from "../props/Tulisan.props"; | ||
import { useEffect, useState } from "react"; | ||
import { fetchTulisan } from "../fungsi/tulisan"; | ||
import { opsiStringDate } from "../interface"; | ||
import KategoriCard from "./KategoriCard"; | ||
import SkeletonTulisan from "./SkeletonTulisan"; | ||
|
||
const Tulisan = () => { | ||
const { idTulisan } = useParams(); | ||
|
||
const [tulisan, setTulisan] = useState<TulisanProps | null>(null) | ||
const [tulisan, setTulisan] = useState<TulisanProps | null>(null); | ||
const [memuat, setMemuat] = useState<boolean>(false); | ||
|
||
useEffect(() => { | ||
if (idTulisan !== undefined) { | ||
fetchTulisan(idTulisan, setTulisan); | ||
fetchTulisan(idTulisan, setTulisan, setMemuat); | ||
} | ||
}, []) | ||
|
||
return tulisan ? | ||
( | ||
<div className="flex flex-col px-2 gap-1"> | ||
<div className="text-2xl font-sans font-semibold subpixel-antialiased text-emerald-400"> | ||
{tulisan.judul} | ||
return ( | ||
<> | ||
{memuat ? ( | ||
<SkeletonTulisan /> | ||
) : tulisan ? | ||
( | ||
<div className="flex flex-col px-2 gap-1"> | ||
<div className="text-2xl font-sans font-semibold subpixel-antialiased text-emerald-400"> | ||
{tulisan.judul} | ||
</div> | ||
<div className="text-stone-400 text-sm italic"> | ||
{tulisan.dibuat.toLocaleDateString('en-ID', opsiStringDate)} | ||
</div> | ||
<div> | ||
{tulisan.kategori?.map(itemKategori => ( | ||
<KategoriCard props={itemKategori} /> | ||
))} | ||
</div> | ||
<div className="xl:text-base text-sm break-words hyphens-auto indent-8 text-justify"> | ||
{tulisan.konten ? ( | ||
<Markdown | ||
remarkPlugins={[remarkGfm, remarkMath]} | ||
rehypePlugins={[rehypeKatex]} | ||
> | ||
{tulisan.konten} | ||
</Markdown> | ||
) : null} | ||
</div> | ||
</div> | ||
<div className="text-stone-400 text-sm italic"> | ||
{tulisan.dibuat.toLocaleDateString('en-ID', opsiStringDate)} | ||
</div> | ||
<div> | ||
{tulisan.kategori?.map(itemKategori => ( | ||
<KategoriCard props={itemKategori} /> | ||
))} | ||
</div> | ||
<div className="xl:text-base text-xs"> | ||
{tulisan.konten} | ||
</div> | ||
</div> | ||
) : null | ||
) : null} | ||
</> | ||
) | ||
} | ||
|
||
export default Tulisan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters