From bd468054c2126aedd7a0c1cb20fca6cf74cebe5c Mon Sep 17 00:00:00 2001 From: Joey Chen <142381267+JoeyC-Dev@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:52:45 +0800 Subject: [PATCH] feat: allow user to customize favicon (#47) * feat: add basic custom favicon feature * add auto-switch icon * revert to the original setting `false` --- src/config.ts | 8 ++++++++ src/layouts/Layout.astro | 5 ++++- src/types/config.ts | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index 338190b..c84c012 100644 --- a/src/config.ts +++ b/src/config.ts @@ -15,6 +15,14 @@ export const siteConfig: SiteConfig = { enable: false, src: 'assets/images/demo-banner.png', }, + favicon: { + enable: false, + size: '32x32', + src: { + light: '/favicon/favicon-light-32.png', + dark: '/favicon/favicon-dark-32.png', + } + }, } export const navBarConfig: NavBarConfig = { diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 60841bd..63598b1 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -54,6 +54,7 @@ if (!banner || typeof banner !== 'string' || banner.trim() === '') { banner = siteConfig.banner.src; const enableBanner = siteConfig.banner.enable; +const enableFavicon = siteConfig.favicon.enable; let pageTitle; if (title) { @@ -74,6 +75,8 @@ if (title) { + {enableFavicon ? + : @@ -81,7 +84,7 @@ if (title) { - + } diff --git a/src/types/config.ts b/src/types/config.ts index 965456d..c068600 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -9,6 +9,15 @@ export type SiteConfig = { enable: boolean src: string } + + favicon: { + enable: boolean + size: string + src: { + light: string + dark: string + } + } } export enum LinkPreset {