wip: testing remark; trying to downgrade some libs
This commit is contained in:
parent
cbcf6a731b
commit
0ca7a97d26
21
app/mark/page.tsx
Normal file
21
app/mark/page.tsx
Normal file
@ -0,0 +1,21 @@
|
||||
import { MarkPostString } from '@/components/dummyPost';
|
||||
import remarkGfm from "remark-gfm";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import rehypeHighlight from "rehype-highlight";
|
||||
import remarkRehype from "remark-rehype";
|
||||
import remarkParse from "remark-parse";
|
||||
import { unified } from 'unified';
|
||||
import rehypeReact from "rehype-react";
|
||||
import * as prod from 'react/jsx-runtime';
|
||||
|
||||
export default async function Mark() {
|
||||
let content = await MarkPostString();
|
||||
let result = unified()
|
||||
.use(remarkParse)
|
||||
.use(remarkGfm)
|
||||
.use(remarkRehype)
|
||||
.use(rehypeSanitize)
|
||||
.use(rehypeHighlight)
|
||||
.processSync(content)
|
||||
|
||||
}
|
@ -25,16 +25,14 @@ const options: HTMLReactParserOptions = {
|
||||
export default async function Post({ params }: { params: { slug: string } }) {
|
||||
let content;
|
||||
|
||||
const dummySlug = await DummyPostSlug();
|
||||
const dummySlug = DummyPostSlug();
|
||||
if (dummySlug === params.slug) {
|
||||
content = await DummyPostString();
|
||||
// console.log(content);
|
||||
} else {
|
||||
content = await getPost(params.slug);
|
||||
}
|
||||
|
||||
content = DOMPurify(new JSDOM("<!DOCTYPE html>").window).sanitize(content);
|
||||
// console.log(content)
|
||||
const elem = parse(content, options);
|
||||
|
||||
return (
|
||||
|
@ -1,13 +1,21 @@
|
||||
import { promises as fsp } from 'fs'
|
||||
import { readFile } from 'node:fs/promises';
|
||||
|
||||
export async function MarkPostString() {
|
||||
let path = ""
|
||||
if ('DUMMY_HTML_DIR' in process.env && typeof process.env.DUMMY_HTML_DIR === "string") {
|
||||
path = process.env.DUMMY_HTML_DIR + "test1.md";
|
||||
}
|
||||
return await readFile(path, "utf-8")
|
||||
}
|
||||
|
||||
export async function DummyPostString() {
|
||||
let path = ""
|
||||
if ('DUMMY_HTML_DIR' in process.env && typeof process.env.DUMMY_HTML_DIR === "string") {
|
||||
path = process.env.DUMMY_HTML_DIR + "test1.html";
|
||||
}
|
||||
return await fsp.readFile(path, "utf-8")
|
||||
return await readFile(path, "utf-8")
|
||||
}
|
||||
|
||||
export async function DummyPostSlug() {
|
||||
export function DummyPostSlug() {
|
||||
return "dummy-post"
|
||||
}
|
15
dummies/test1.md
Normal file
15
dummies/test1.md
Normal file
@ -0,0 +1,15 @@
|
||||
# Post Title
|
||||
|
||||
## Introduction
|
||||
|
||||
Hi there! Do you see me?
|
||||
|
||||
```go
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello world")
|
||||
}
|
||||
```
|
||||
|
||||
That's the `hello world` code!
|
Loading…
x
Reference in New Issue
Block a user