This commit is contained in:
Janis
2023-01-21 20:32:10 +01:00
parent e048fc5d17
commit bead72cde7
15 changed files with 6320 additions and 208 deletions

View File

@@ -1,41 +0,0 @@
"use client";
import React from "react";
import { useEffect } from "react";
import Prism from "prismjs";
import "../../../../styles/prism_themes/prism-one-dark.css";
//import "../../../styles/prism_themes/prism-one-light.css";
export default function LoadMarkdown() {
useEffect(() => {
document.querySelectorAll("pre").forEach((pre) => {
if (pre.classList.length < 1) {
pre.classList.add("language-");
}
});
document.querySelectorAll("code").forEach((c) => {
if (c.classList.length < 1) {
c.classList.add("language-");
}
});
document.querySelectorAll("blockquote").forEach((bq) => {
bq.classList.add("blockquote");
});
document.querySelectorAll("li").forEach((li) => {
let paragraphText = "";
li.querySelectorAll("p").forEach((p) => {
paragraphText = p.innerHTML;
});
if (paragraphText != "") {
li.innerHTML = paragraphText;
}
});
Prism.highlightAll();
}, []);
return <div></div>;
}

View File

@@ -1,4 +1,3 @@
import "../../../../styles/markdown.scss";
export default function Layout({ children }) {
return <div>{children}</div>;
return <div>{children}</div>;
}

View File

@@ -2,7 +2,7 @@ import { marked } from "marked";
import ContentTable from "./ContentTable";
import Sidebar from "./Sidebar";
import styles from "../../../../styles/modules/Article.module.scss";
import LoadMarkdown from "./LoadMarkdown";
import { Article, Category, ContentTableEntry } from "@prisma/client";
import Image from "next/image";
import urlJoin from "url-join";
@@ -23,15 +23,11 @@ export async function GetArticle(articleName: string): Promise<any> {
return result.json();
}
function ParseMarkdown(markdown: string): string {
let result = marked.parse(markdown);
return result;
}
//* MAIN
export default async function ArticlePage({ params }: { params: { articleName: string; categoryName: string } }) {
const articleName: string = params.articleName.toLowerCase().replaceAll("%20", " ");
const article: ArticleWithIncludes = await GetArticle(articleName);
const dateUpdated: Date = new Date(article.dateUpdated);
const dateCreated: Date = new Date(article.dateCreated);
const dateOptions: Intl.DateTimeFormatOptions = { month: "long", day: "numeric", year: "numeric" };