ASF-admin: gebruik het echte favicon.png van de website als themafavicon
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,20 +17,21 @@ function themeFor(mode: string) {
|
||||
* Build emits it as an asset; the dev server serves it from the theme folder.
|
||||
*/
|
||||
function themeFavicon(faviconPath: string | null): Plugin {
|
||||
const publicName = 'favicon-theme.svg';
|
||||
const publicName = 'favicon-theme.png';
|
||||
return {
|
||||
name: 'cms-theme-favicon',
|
||||
// 'post': Vite has already prefixed the base path (/admin/) by then, so match any prefix.
|
||||
transformIndexHtml: {
|
||||
order: 'post',
|
||||
handler(html) {
|
||||
return faviconPath === null ? html : html.replace(/href="([^"]*)favicon\.svg"/, `href="$1${publicName}"`);
|
||||
return faviconPath === null ? html : html.replace(/<link rel="icon"[^>]*favicon\.svg"[^>]*>/, (tag) =>
|
||||
tag.replace(/type="[^"]*"/, 'type="image/png"').replace(/href="([^"]*)favicon\.svg"/, `href="$1${publicName}"`));
|
||||
},
|
||||
},
|
||||
configureServer(server) {
|
||||
if (faviconPath === null) return;
|
||||
server.middlewares.use(`/${publicName}`, (_req, res) => {
|
||||
res.setHeader('Content-Type', 'image/svg+xml');
|
||||
res.setHeader('Content-Type', 'image/png');
|
||||
res.end(fs.readFileSync(faviconPath));
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user