Skip to content

Commit b0ffaef

Browse files
Fix/markdown table rendering (#3)
* env: install remark-gfm * refactor: update markdown processing to include gfm * style: add table style
1 parent 28799b3 commit b0ffaef

File tree

4 files changed

+281
-1
lines changed

4 files changed

+281
-1
lines changed

app/globals.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,19 @@ h6 {
8484
.logo-image:hover {
8585
animation: shake 0.5s ease-in-out;
8686
}
87+
88+
.prose table {
89+
width: 100%;
90+
border-collapse: collapse;
91+
}
92+
93+
.prose th,
94+
.prose td {
95+
border: 1px solid #ddd;
96+
padding: 8px;
97+
text-align: left;
98+
}
99+
100+
.prose th {
101+
background-color: #f2f2f2;
102+
}

lib/mdx.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from "path";
55
import matter from "gray-matter";
66
import { remark } from "remark";
77
import html from "remark-html";
8+
import gfm from "remark-gfm";
89
import { getGroupOrder, GroupId } from "@/constants/group";
910

1011
const contentDirectory = path.join(process.cwd(), "content", "guide");
@@ -45,7 +46,7 @@ function getAllDocumentsRecursive(dir: string, lang: string): Document[] {
4546
const fileContents = fs.readFileSync(entryPath, "utf8");
4647
const { data, content } = matter(fileContents);
4748
const groupOrder = getGroupOrder(data.group as GroupId);
48-
const processedContent = remark().use(html).processSync(content);
49+
const processedContent = remark().use(gfm).use(html).processSync(content);
4950
const contentHtml = processedContent.toString();
5051

5152
documents.push({

package-lock.json

Lines changed: 262 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"rehype-highlight": "7.0.0",
2222
"rehype-raw": "7.0.0",
2323
"remark": "15.0.1",
24+
"remark-gfm": "4.0.0",
2425
"remark-html": "16.0.1"
2526
},
2627
"devDependencies": {

0 commit comments

Comments
 (0)