mirror of
https://github.com/Dokploy/website
synced 2025-06-26 18:16:01 +00:00
feat: add table markdown conversion support in blog post rendering
This commit is contained in:
@@ -128,8 +128,39 @@ export default async function BlogPostPage({ params }: Props) {
|
||||
headingStyle: "atx",
|
||||
codeBlockStyle: "fenced",
|
||||
});
|
||||
|
||||
// Configurar el manejo de tablas
|
||||
turndownService.addRule("table", {
|
||||
filter: ["table"],
|
||||
replacement: (content, node) => {
|
||||
const rows = node.rows;
|
||||
let markdown = "\n";
|
||||
|
||||
// Headers
|
||||
if (rows.length > 0) {
|
||||
const headers = Array.from(rows[0].cells).map((cell) =>
|
||||
cell.textContent.trim(),
|
||||
);
|
||||
markdown += `| ${headers.join(" | ")} |\n`;
|
||||
markdown += `| ${headers.map(() => "---").join(" | ")} |\n`;
|
||||
}
|
||||
|
||||
// Body
|
||||
for (let i = 1; i < rows.length; i++) {
|
||||
const cells = Array.from(rows[i].cells).map((cell) =>
|
||||
cell.textContent.trim(),
|
||||
);
|
||||
markdown += `| ${cells.join(" | ")} |\n`;
|
||||
}
|
||||
|
||||
return `${markdown}\n`;
|
||||
},
|
||||
});
|
||||
|
||||
const markdown = turndownService.turndown(post.html);
|
||||
|
||||
console.log(markdown);
|
||||
|
||||
const formattedDate = new Date(post.published_at).toLocaleDateString(locale, {
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
|
||||
Reference in New Issue
Block a user