From b13bb738cefeed3e77d7f0c31767222146c25b30 Mon Sep 17 00:00:00 2001 From: klemek Date: Fri, 24 Jul 2026 12:32:40 +0200 Subject: [PATCH] fix: favicon path --- articles.example/config.json | 3 ++- index.html | 2 +- post-build.ts | 27 ++++++++++----------------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/articles.example/config.json b/articles.example/config.json index 63b800f..100a55b 100644 --- a/articles.example/config.json +++ b/articles.example/config.json @@ -12,5 +12,6 @@ "updated_on": "Updated on", "authored": "By", "copyright": "CC BY-NC", - "footer": "" + "footer": "", + "favicon_ico": "" } diff --git a/index.html b/index.html index 3ae6756..6d161ce 100644 --- a/index.html +++ b/index.html @@ -2,10 +2,10 @@ - %VITE_APP_TITLE_NO_HTML% + diff --git a/post-build.ts b/post-build.ts index 49ce95b..015d7b7 100644 --- a/post-build.ts +++ b/post-build.ts @@ -37,10 +37,7 @@ function readArticleMetadata(path: string): Record | null { return metadata; } -function formatArticlePage( - metadata: Record, - baseHtml: string, -): string { +function formatArticlePage(metadata: Record, baseHtml: string): string { let outHtml = baseHtml; outHtml = outHtml.replace(/<.*?property="og:url".*?>/gm, ""); outHtml = outHtml.replace( @@ -50,10 +47,7 @@ function formatArticlePage( const blog_title = articlesConfig.title.replace(/(<([^>]+)>)/gi, "").trim(); if (metadata.title) { const title = metadata.title.replace(/(<([^>]+)>)/gi, "").trim(); - outHtml = outHtml.replace( - /.*?<\/title>/gm, - `<title>${blog_title} — ${title}`, - ); + outHtml = outHtml.replace(/.*?<\/title>/gm, `<title>${blog_title} — ${title}`); outHtml = outHtml.replace(/<.*?property="og:title".*?>/gm, ""); outHtml = outHtml.replace( /<\/head>/gm, @@ -82,10 +76,7 @@ function addFeedArticle(metadata: Record, feed: Feed) { id: metadata.path, link: `${articlesConfig.base_url}${metadata.path}/`, date: new Date(Date.parse(metadata.date)), - image: metadata.thumbnail.replace( - "./", - articlesConfig.base_url + metadata.path + "/", - ), + image: metadata.thumbnail.replace("./", articlesConfig.base_url + metadata.path + "/"), }); } } @@ -107,7 +98,7 @@ const feed = new Feed({ id: articlesConfig.base_url, link: articlesConfig.base_url, language: articlesConfig.lang, - favicon: articlesConfig.base_url + "articles/favicon.ico", + favicon: articlesConfig.base_url + "/favicon.ico", generator: "md-blog", feedLinks: { json: articlesConfig.base_url + "feed.json", @@ -125,10 +116,7 @@ const feed = new Feed({ }); metadatas.forEach((metadata) => { - fs.writeFileSync( - `dist/${metadata.path}/index.html`, - formatArticlePage(metadata, indexContent), - ); + fs.writeFileSync(`dist/${metadata.path}/index.html`, formatArticlePage(metadata, indexContent)); console.info(`Wrote dist/${metadata.path}/index.html`); addFeedArticle(metadata, feed); }); @@ -139,3 +127,8 @@ fs.writeFileSync("dist/atom.xml", feed.atom1()); console.info(`Wrote dist/atom.xml`); fs.writeFileSync("dist/rss.xml", feed.rss2()); console.info(`Wrote dist/rss.xml`); + +if (articlesConfig.favicon_ico) { + fs.copyFileSync(`articles/${articlesConfig.favicon_ico}`, "dist/favicon.ico"); + console.info(`Wrote dist/favicon.ico`); +}