wip: test versions of pnpm and nodejs
This commit is contained in:
parent
6d3dab582a
commit
cf0579023e
@ -1,54 +1,75 @@
|
||||
import { getPost } from "@/backend/post";
|
||||
import DOMPurify from "dompurify";
|
||||
import { JSDOM } from "jsdom";
|
||||
import {nunito_sans, raleway} from "@/app/fonts";
|
||||
import parse, {domToReact, Element, HTMLReactParserOptions} from "html-react-parser";
|
||||
import { nunito_sans, raleway } from "@/app/fonts";
|
||||
import parse, {
|
||||
domToReact,
|
||||
Element,
|
||||
HTMLReactParserOptions,
|
||||
} from "html-react-parser";
|
||||
import { DummyPostSlug, DummyPostString } from "@/components/dummyPost";
|
||||
|
||||
const options: HTMLReactParserOptions = {
|
||||
replace: (domNode) => {
|
||||
if (domNode instanceof Element && domNode.attribs) {
|
||||
// console.log(domNode.attribs)
|
||||
if (domNode.name === 'h1') {
|
||||
if (domNode.attribs.class === 'title') {
|
||||
if (domNode.name === "h1") {
|
||||
if (domNode.attribs.class === "title") {
|
||||
return (
|
||||
<div className={`flex flex-row justify-stretch`}>
|
||||
<h1 className={`${raleway.className} mx-auto max-w-4xl text-4xl`}>{domToReact(domNode.children)}</h1>
|
||||
</div>
|
||||
)
|
||||
<h1 className={`${raleway.className} mx-auto w-224 text-4xl`}>
|
||||
{domToReact(domNode.children)}
|
||||
</h1>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className={`flex flex-row justify-stretch`}>
|
||||
<h1 className={`${raleway.className} max-w-4xl mx-auto text-3xl`}>{domToReact(domNode.children)}</h1>
|
||||
</div>
|
||||
)
|
||||
<h1 className={`${raleway.className} mx-auto w-224 text-3xl`}>
|
||||
{domToReact(domNode.children)}
|
||||
</h1>
|
||||
);
|
||||
}
|
||||
} else if (domNode.name === 'h2') {
|
||||
|
||||
} else if (domNode.name === 'h3') {
|
||||
|
||||
} else if (domNode.name === 'p') {
|
||||
if (domNode.attribs.class === 'paragraph') {
|
||||
} else if (domNode.name === "h2") {
|
||||
return (
|
||||
<h1 className={`${raleway.className} mx-auto w-224 text-2xl`}>
|
||||
{domToReact(domNode.children)}
|
||||
</h1>
|
||||
);
|
||||
} else if (domNode.name === "h3") {
|
||||
return (
|
||||
<h1 className={`${raleway.className} mx-auto w-224 text-xl`}>
|
||||
{domToReact(domNode.children)}
|
||||
</h1>
|
||||
);
|
||||
} else if (domNode.name === "p") {
|
||||
if (domNode.attribs.class === "paragraph") {
|
||||
return (
|
||||
<div className={`flex flex-row justify-center`}>
|
||||
<h1 className={`${nunito_sans.className} w-224`}>{domToReact(domNode.children)}</h1>
|
||||
</div>
|
||||
)
|
||||
} else if (domNode.attribs.class === 'code') {
|
||||
<h1 className={`${nunito_sans.className} mx-auto w-224`}>
|
||||
{domToReact(domNode.children)}
|
||||
</h1>
|
||||
);
|
||||
} else {
|
||||
const classes = domNode.attribs.class.split(" ");
|
||||
if (classes.includes("code")) {
|
||||
if (classes.includes("shell")) {
|
||||
|
||||
} else if (classes.includes("go") || classes.includes("golang")) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default async function Post({ params }: { params: { slug: string } }) {
|
||||
let content = ""
|
||||
let content = "";
|
||||
|
||||
const dummySlug = await DummyPostSlug()
|
||||
const dummySlug = await DummyPostSlug();
|
||||
if (dummySlug === params.slug) {
|
||||
content = await DummyPostString()
|
||||
console.log(content)
|
||||
content = await DummyPostString();
|
||||
console.log(content);
|
||||
} else {
|
||||
content = await getPost(params.slug);
|
||||
}
|
||||
@ -57,9 +78,5 @@ export default async function Post({ params }: { params: { slug: string } }) {
|
||||
// console.log(content)
|
||||
const elem = parse(content, options);
|
||||
|
||||
return (
|
||||
<div className={`flex flex-col`}>
|
||||
{elem}
|
||||
</div>
|
||||
);
|
||||
return <div className={`flex flex-col`}>{elem}</div>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user