From 2393d8acc1a085a8ded60098f4fb236f7ce865a6 Mon Sep 17 00:00:00 2001 From: Daniel Kluge Date: Fri, 4 Feb 2022 23:29:51 +0100 Subject: [PATCH] Better Asciidoc rendering --- components/ProjectModal.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/components/ProjectModal.tsx b/components/ProjectModal.tsx index f8ca0c5..bc58a81 100644 --- a/components/ProjectModal.tsx +++ b/components/ProjectModal.tsx @@ -19,16 +19,26 @@ const ProjectModal: NextPage = ({ project, visible, setVisible }) => const projectNotFoundHtml = `
Sorry! There is no data for this project. Please check back later to see if that changed!
`; const projectServerErrorHtml = `
Sorry! A server error happend when the project data was fetched!
`; + const generateFooter = (project: string, lastUpdate: string) => `
+ + `; + useEffect(() => { if (project && project !== "") { // TODO // set Spinner + setProjectData("Loading..."); fetch(`/api/projects/${project}`).then((res) => { if (res.status === 404) setProjectData(projectNotFoundHtml); if (res.status !== 200) setProjectData(projectServerErrorHtml); res.text().then(data => { try { - setProjectData(ad.convert(data).toString()); + const adDoc = ad.load(data, {attributes: {showtitle: true}}); + setProjectData(adDoc.convert(adDoc).toString() + generateFooter(project, adDoc.getAttribute("docdatetime"))); } catch { setProjectData(projectServerErrorHtml); } @@ -54,7 +64,7 @@ const ProjectModal: NextPage = ({ project, visible, setVisible }) => if (!visible) return <>; return
-
+
; };