Skip to content

Commit

Permalink
fix: markdown copy codeblock issue (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
moonlitgrace authored Sep 19, 2024
1 parent b20ff6f commit 826aaaa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
25 changes: 9 additions & 16 deletions app/_components/_admin/admin-blog-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,16 @@ import Markdown from '@/components/markdown';
import { Checkbox } from '@/components/ui/checkbox';
import { revalidatePathClient } from '@/helpers/revalidate-path-client';

type Props = {
id?: number;
title?: string;
tag?: string;
content?: string;
cover?: string | null;
draft?: boolean;
};
type Props = Partial<{
id: number;
title: string;
tag: string;
content: string;
cover: string | null;
draft: boolean;
}>;

export default function AdminBlogForm({
id,
title = '',
tag = '',
content = '',
cover,
draft = false,
}: Props) {
export default function AdminBlogForm({ id, title, tag, content, cover, draft = false }: Props) {
const [state, action] = useFormState(adminBlogSubmit, undefined);
const [contentState, setContentState] = useState(content);

Expand Down
1 change: 1 addition & 0 deletions components/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const Markdown = ({ markdown }: { markdown: string }) => {
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(marked.parse(markdown) as string, {
USE_PROFILES: { html: true },
ADD_ATTR: ['onclick'],
}),
}}
></article>
Expand Down

0 comments on commit 826aaaa

Please sign in to comment.