From 5d4d87c8bdb42c19e57a458fdc4d05de1ade4546 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Tue, 7 Mar 2023 15:03:35 +0700
Subject: add dynamic content

---
 src/lib/content/components/PageContent.jsx | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 src/lib/content/components/PageContent.jsx

(limited to 'src/lib/content/components/PageContent.jsx')

diff --git a/src/lib/content/components/PageContent.jsx b/src/lib/content/components/PageContent.jsx
new file mode 100644
index 00000000..724f99c1
--- /dev/null
+++ b/src/lib/content/components/PageContent.jsx
@@ -0,0 +1,26 @@
+import { useEffect } from 'react'
+import { useState } from 'react'
+import pageContentApi from '../api/pageContentApi'
+
+const PageContent = ({ path }) => {
+  const [content, setContent] = useState(<></>)
+
+  useEffect(() => {
+    const loadContent = async () => {
+      const dataContent = await pageContentApi({ path })
+      if (dataContent) {
+        setContent(
+          <div
+            className='p-4 prose prose-gray prose-a:text-red_r-10 prose-p:my-0'
+            dangerouslySetInnerHTML={{ __html: dataContent.content }}
+          />
+        )
+      }
+    }
+    loadContent()
+  }, [path])
+
+  return content
+}
+
+export default PageContent
-- 
cgit v1.2.3

