Skip to content

Commit

Permalink
feat: Automatically link @mentions (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnRG authored Aug 1, 2023
1 parent 035bafb commit 09922f1
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 1 deletion.
5 changes: 4 additions & 1 deletion VocaDbWeb/New/components/Markdown/MarkownRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
import rehypeStringify from 'rehype-stringify';
import remarkBreaks from 'remark-breaks';
import remarkMentions from 'remark-mentions';
import parse from '@/Helpers/markdown';
import { TypographyStylesProvider } from '@mantine/core';

Expand All @@ -14,10 +15,12 @@ export default function MarkdownRenderer({ children }: MarkdownProps) {
const processer = unified()
.use(remarkParse)
.use(remarkBreaks)
.use(remarkMentions, { usernameLink: (username) => `/Profile/${username}` })
.use(remarkRehype)
.use(rehypeStringify);

return (
<TypographyStylesProvider className="description">
<TypographyStylesProvider fz="sm" className="description">
{parse(String(processer.processSync(children)))}
</TypographyStylesProvider>
);
Expand Down
159 changes: 159 additions & 0 deletions VocaDbWeb/New/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions VocaDbWeb/New/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"rehype-sanitize": "^5.0.1",
"rehype-stringify": "^9.0.3",
"remark-breaks": "^3.0.3",
"remark-mentions": "^1.0.2",
"remark-parse": "^10.0.2",
"remark-rehype": "^10.1.0",
"sharp": "^0.32.1",
Expand Down

0 comments on commit 09922f1

Please sign in to comment.