diff --git a/apps/website/app/[locale]/blog/[slug]/page.tsx b/apps/website/app/[locale]/blog/[slug]/page.tsx
index f9a8531..d9c045a 100644
--- a/apps/website/app/[locale]/blog/[slug]/page.tsx
+++ b/apps/website/app/[locale]/blog/[slug]/page.tsx
@@ -11,6 +11,7 @@ import ReactMarkdown from "react-markdown";
import type { Components } from "react-markdown";
import rehypeRaw from "rehype-raw";
import remarkGfm from "remark-gfm";
+import TurndownService from "turndown";
import { CodeBlock } from "../components/CodeBlock";
import { ZoomableImage } from "./components/ZoomableImage";
@@ -76,6 +77,13 @@ export default async function BlogPostPage({ params }: Props) {
notFound();
}
+ // Convertir HTML a Markdown
+ const turndownService = new TurndownService({
+ headingStyle: "atx",
+ codeBlockStyle: "fenced",
+ });
+ const markdown = turndownService.turndown(post.html);
+
const formattedDate = new Date(post.published_at).toLocaleDateString(locale, {
year: "numeric",
month: "long",
@@ -152,60 +160,14 @@ export default async function BlogPostPage({ params }: Props) {
),
code: ({ inline, className, children, ...props }: CodeProps) => {
- if (inline) {
- return (
-
- {children}
-
- );
- }
-
const match = /language-(\w+)/.exec(className || "");
- // Extraer el contenido del código de la estructura anidada
- const extractCodeContent = (children: React.ReactNode): string => {
- if (typeof children === "string") {
- return children;
- }
- if (Array.isArray(children)) {
- return children
- .map((child) => {
- if (typeof child === "string") {
- return child;
- }
- if (child && typeof child === "object" && "props" in child) {
- return extractCodeContent(child.props.children);
- }
- return "";
- })
- .join("");
- }
- if (children && typeof children === "object" && "props" in children) {
- return extractCodeContent(children.props.children);
- }
- return "";
- };
-
- const codeContent = extractCodeContent(children)
- .replace(/</g, "<")
- .replace(/>/g, ">")
- .replace(/"/g, '"')
- .replace(/'/g, "'")
- .replace(/&/g, "&")
- .trim();
-
- // Wrap CodeBlock in a div to prevent it from being inside a p tag
return (
-
--