@@ -14,7 +14,10 @@ import remarkGfm from "remark-gfm";
14
14
import { codeToHtml } from "shiki" ;
15
15
import type { BundledLanguage } from "shiki/bundle/web" ;
16
16
import TurndownService from "turndown" ;
17
+ // @ts -ignore
18
+ import * as turndownPluginGfm from "turndown-plugin-gfm" ;
17
19
import { ZoomableImage } from "./components/ZoomableImage" ;
20
+
18
21
type Props = {
19
22
params : { locale : string ; slug : string } ;
20
23
} ;
@@ -128,39 +131,13 @@ export default async function BlogPostPage({ params }: Props) {
128
131
headingStyle : "atx" ,
129
132
codeBlockStyle : "fenced" ,
130
133
} ) ;
131
-
132
- // Configurar el manejo de tablas
133
- turndownService . addRule ( "table" , {
134
- filter : [ "table" ] ,
135
- replacement : ( content , node ) => {
136
- const rows = node . rows ;
137
- let markdown = "\n" ;
138
-
139
- // Headers
140
- if ( rows . length > 0 ) {
141
- const headers = Array . from ( rows [ 0 ] . cells ) . map ( ( cell ) =>
142
- cell . textContent . trim ( ) ,
143
- ) ;
144
- markdown += `| ${ headers . join ( " | " ) } |\n` ;
145
- markdown += `| ${ headers . map ( ( ) => "---" ) . join ( " | " ) } |\n` ;
146
- }
147
-
148
- // Body
149
- for ( let i = 1 ; i < rows . length ; i ++ ) {
150
- const cells = Array . from ( rows [ i ] . cells ) . map ( ( cell ) =>
151
- cell . textContent . trim ( ) ,
152
- ) ;
153
- markdown += `| ${ cells . join ( " | " ) } |\n` ;
154
- }
155
-
156
- return `${ markdown } \n` ;
157
- } ,
158
- } ) ;
134
+ const gfm = turndownPluginGfm . gfm ;
135
+ const tables = turndownPluginGfm . tables ;
136
+ const strikethrough = turndownPluginGfm . strikethrough ;
137
+ turndownService . use ( [ tables , strikethrough , gfm ] ) ;
159
138
160
139
const markdown = turndownService . turndown ( post . html ) ;
161
140
162
- console . log ( markdown ) ;
163
-
164
141
const formattedDate = new Date ( post . published_at ) . toLocaleDateString ( locale , {
165
142
year : "numeric" ,
166
143
month : "long" ,
@@ -232,9 +209,11 @@ export default async function BlogPostPage({ params }: Props) {
232
209
< td className = "p-4 text-muted-foreground" { ...props } />
233
210
) ,
234
211
img : ( { node, src, alt } ) => (
235
- < span className = "relative w-64 h-64 my-6 rounded-lg " >
236
- { src && < ZoomableImage src = { src } alt = { alt || "" } /> }
237
- </ span >
212
+ < ZoomableImage
213
+ src = { src || "" }
214
+ alt = { alt || "" }
215
+ className = "object-cover max-w-lg mx-auto rounded-lg border border-border"
216
+ />
238
217
) ,
239
218
code : ( { inline, className, children, ...props } : CodeProps ) => {
240
219
const match = / l a n g u a g e - ( \w + ) / . exec ( className || "" ) ;
@@ -319,11 +298,11 @@ export default async function BlogPostPage({ params }: Props) {
319
298
</ div >
320
299
</ div >
321
300
{ post . feature_image && (
322
- < div className = "relative w-full h-[400px] mb-8" >
301
+ < div className = "relative w-full h-[400px] mb-8" >
323
302
< ZoomableImage
324
303
src = { post . feature_image }
325
304
alt = { post . title }
326
- className = "rounded-lg"
305
+ className = "rounded-lg h-full w-full object-cover "
327
306
/>
328
307
</ div >
329
308
) }
0 commit comments