Skip to content

Commit d79ad17

Browse files
committed
Add remark-gfm (GitHub flavored markdown) plugin
Adds support for adds support for tables, tasklists, strikethrough, and auto-URLs. Also added some CSS for tables to auto-width and set text colors.
1 parent c179c80 commit d79ad17

File tree

3 files changed

+300
-2
lines changed

3 files changed

+300
-2
lines changed

package-lock.json

+294
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"react-markdown": "^9.0.1",
2020
"react-router-dom": "^6.28.0",
2121
"react-syntax-highlighter": "^15.6.1",
22+
"remark-gfm": "^4.0.0",
2223
"tailwindcss": "^3.4.14"
2324
},
2425
"devDependencies": {

src/pages/Documentation.jsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect } from 'react';
22
import { useParams, Navigate } from 'react-router-dom';
33
import ReactMarkdown from 'react-markdown';
4+
import remarkGfm from 'remark-gfm'
45
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
56
import { tomorrow } from 'react-syntax-highlighter/dist/esm/styles/prism';
67
import DocSidebar from '../components/DocSidebar';
@@ -49,8 +50,9 @@ export default function Documentation() {
4950
<div className="max-w-4xl mx-auto">
5051
<article className="prose dark:prose-invert prose-lg max-w-none">
5152
<ReactMarkdown
53+
remarkPlugins={[remarkGfm]}
5254
components={{
53-
code({inline, className, children, ...props}) {
55+
code({ inline, className, children, ...props }) {
5456
const match = /language-(\w+)/.exec(className || '');
5557
return !inline && match ? (
5658
<SyntaxHighlighter
@@ -75,11 +77,12 @@ export default function Documentation() {
7577
ul: (props) => <ul className="list-disc pl-6 mb-4 text-gray-700 dark:text-gray-300" {...props} />,
7678
ol: (props) => <ol className="list-decimal pl-6 mb-4 text-gray-700 dark:text-gray-300" {...props} />,
7779
a: (props) => (
78-
<a
80+
<a
7981
className="text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300"
8082
{...props}
8183
/>
8284
),
85+
table: (props) => <table className="table-auto w-auto text-gray-700 dark:text-gray-300" {...props} />,
8386
}}
8487
>
8588
{content}

0 commit comments

Comments
 (0)