Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions app/(app)/articles/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ import ArticleAdminPanel from "@/components/ArticleAdminPanel/ArticleAdminPanel"
import { type Metadata } from "next";
import { getPost } from "@/server/lib/posts";
import { getCamelCaseFromLower } from "@/utils/utils";
import { generateHTML } from "@tiptap/html";
import { generateHTML } from "@tiptap/core";
import { TiptapExtensions } from "@/components/editor/editor/extensions";
import DOMPurify from "isomorphic-dompurify";
import type { JSONContent } from "@tiptap/core";
import NotFound from "@/components/NotFound/NotFound";

type Props = { params: { slug: string } };

Expand Down Expand Up @@ -119,11 +120,17 @@ const ArticlePage = async ({ params }: Props) => {

{isTiptapContent ? (
<div
dangerouslySetInnerHTML={{ __html: renderedContent }}
dangerouslySetInnerHTML={{
__html: renderedContent ?? <NotFound />,
}}
Comment on lines +123 to +125
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix NotFound component implementation.

The current implementation attempts to use JSX within dangerouslySetInnerHTML which won't work as expected. The NotFound component should be rendered conditionally.

-              dangerouslySetInnerHTML={{
-                __html: renderedContent ?? <NotFound />,
-              }}
+              {...(renderedContent
+                ? {
+                    dangerouslySetInnerHTML: {
+                      __html: renderedContent,
+                    },
+                  }
+                : {}
+              )}
+            >
+              {!renderedContent && <NotFound />}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dangerouslySetInnerHTML={{
__html: renderedContent ?? <NotFound />,
}}
{...(renderedContent
? {
dangerouslySetInnerHTML: {
__html: renderedContent,
},
}
: {}
)}
>
{!renderedContent && <NotFound />}
🧰 Tools
🪛 Biome

[error] 123-123: Avoid passing content using the dangerouslySetInnerHTML prop.

Setting content using code can expose users to cross-site scripting (XSS) attacks

(lint/security/noDangerouslySetInnerHtml)

className="tiptap-content"
/>
) : (
<div>{renderedContent}</div>
<div>
{Markdoc.renderers.react(renderedContent, React, {
components: markdocComponents,
})}
</div>
)}
</article>
{post.tags.length > 0 && (
Expand Down
2 changes: 1 addition & 1 deletion 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
"@svgr/webpack": "^8.1.0",
"@tailwindcss/typography": "^0.5.13",
"@types/chance": "^1.1.6",
"@types/dompurify": "^3.0.5",
"@types/node": "^22.7.5",
"@types/nodemailer": "^6.4.15",
"@types/pg": "^8.11.5",
Expand Down
Loading