@@ -3,6 +3,7 @@ import path from 'path';
33import { fileURLToPath } from 'url' ;
44import MarkdownIt from 'markdown-it' ;
55import yaml from 'js-yaml' ;
6+ import { error } from 'console' ;
67
78const __filename = fileURLToPath ( import . meta. url ) ;
89const __dirname = path . dirname ( __filename ) ;
@@ -139,11 +140,16 @@ function generatePostHTML(post) {
139140 <meta charset="UTF-8">
140141 <meta name="viewport" content="width=device-width, initial-scale=1.0">
141142 <title>${ frontmatter . title } - Mimolet</title>
142- <link rel="stylesheet" href="../ style.css">
143+ <link rel="stylesheet" href="/assets/ style/posts .css">
143144</head>
144145<body>
145146 <main>
146- <article>
147+ <h1>the mimolet updates.</h1>
148+ <div id="links">
149+ <a href="/" rel="noopener noreferrer">Home</a><br>
150+ <a href="/feed.xml" target="_blank" rel="noopener noreferrer">Subscribe (RSS)</a>
151+ </div>
152+ <article class="feed-item">
147153 <h1>${ frontmatter . title } </h1>
148154 <p class="post-meta">
149155 <time datetime="${ frontmatter . date } ">${ new Date ( frontmatter . date ) . toLocaleDateString ( 'en-US' , {
@@ -154,39 +160,43 @@ function generatePostHTML(post) {
154160 </p>
155161 ${ html }
156162 </article>
157- <a href="../index.html">β Retour Γ l'accueil</a>
158163 </main>
159164</body>
160165</html>` ;
161166}
162167
163168// Fonction principale
164169function main ( ) {
165- const postsDir = path . join ( __dirname , '.. /posts' ) ;
166- const outputDir = path . join ( __dirname , '../.. /posts' ) ;
170+ const markdownDir = path . join ( __dirname , '/posts/md ' ) ;
171+ const outputDir = path . join ( __dirname , '/posts' ) ;
167172
168173 // CrΓ©er le dossier posts s'il n'existe pas
169174 if ( ! fs . existsSync ( outputDir ) ) {
170175 fs . mkdirSync ( outputDir , { recursive : true } ) ;
171176 }
172177
173178 // Lire tous les fichiers markdown
174- const files = fs . readdirSync ( postsDir )
179+ const files = fs . readdirSync ( markdownDir )
175180 . filter ( file => file . endsWith ( '.md' ) )
176181 . sort ( )
177182 . reverse ( ) ; // Les plus rΓ©cents en premier
178183
179184 // Parser tous les posts
180185 const posts = files . map ( file => {
181- const content = fs . readFileSync ( path . join ( postsDir , file ) , 'utf-8' ) ;
186+ const content = fs . readFileSync ( path . join ( markdownDir , file ) , 'utf-8' ) ;
182187 const parsed = parseMarkdown ( content ) ;
183188 return { ...parsed , filename : file } ;
184189 } ) ;
185190
186191 // GΓ©nΓ©rer le RSS
187192 const rss = generateRSS ( posts ) ;
188- fs . writeFileSync ( path . join ( __dirname , '../../feed.xml' ) , rss ) ;
189- console . log ( 'β
feed.xml gΓ©nΓ©rΓ©' ) ;
193+ try {
194+ fs . writeFileSync ( path . join ( __dirname , '/feed.xml' ) , rss ) ;
195+ } catch ( e ) {
196+ print . error ( e . message )
197+ } finally {
198+ console . log ( 'β
feed.xml gΓ©nΓ©rΓ©' ) ;
199+ }
190200
191201 // GΓ©nΓ©rer les pages HTML individuelles
192202 posts . forEach ( post => {
0 commit comments