From 76f6bcea7158a954093e7fd4b2022b9becb16b4d Mon Sep 17 00:00:00 2001 From: Mocca101 NB <49754596+Mocca101@users.noreply.github.com> Date: Tue, 29 Aug 2023 09:31:03 +0200 Subject: [PATCH] Added Favicon support to config --- App.vue | 6 +++++- composables/utils.ts | 20 ++++++++++++++++++++ config/discoveryConfig.ts | 10 ++++++++++ nuxt.config.ts | 10 +--------- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/App.vue b/App.vue index f8c5bbb8..11fa08b3 100644 --- a/App.vue +++ b/App.vue @@ -6,11 +6,15 @@ diff --git a/composables/utils.ts b/composables/utils.ts index 93a29b20..876a0432 100644 --- a/composables/utils.ts +++ b/composables/utils.ts @@ -21,3 +21,23 @@ export function getHeaderLogo () : string { return ($discoveryConfig.headerLogo ?? $discoveryConfig.logo) ?? '/header_logo.svg'; } + +export function getFavicon () : { rel: string; type: string; href: string; sizes: string } { + const { $discoveryConfig } = useNuxtApp(); + + const favicon = { + rel: 'icon', + type: 'image/svg+xml', + href: '/favicon.svg', + sizes: 'any' + }; + const faviconExt = $discoveryConfig.favicon?.split('.').pop(); + + // Can Handle SVGs, .ico + if (faviconExt === 'ico') { + favicon.type = 'image/x-icon'; + favicon.href = '/' + $discoveryConfig.favicon; + } + + return favicon; +} diff --git a/config/discoveryConfig.ts b/config/discoveryConfig.ts index f062c8b4..ccaae77e 100644 --- a/config/discoveryConfig.ts +++ b/config/discoveryConfig.ts @@ -51,12 +51,22 @@ export interface DiscoveryConfig { */ headerLogo?: string; +// Favicon + + /** + * The favicon of the website. + * Specifies the favicon that will be used for the Discovery website. + * @supportedTypes image/svg+xml, image/x-icon + */ + favicon?: string; + /** * The title of the website. * Specifies the title that will be used for the Discovery website. * @default OpenAtlas Discovery */ title: string; + } export const defaultDiscoveryConfig: DiscoveryConfig = { diff --git a/nuxt.config.ts b/nuxt.config.ts index ab3f87f0..98314269 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -13,15 +13,7 @@ export default defineNuxtConfig({ head: { meta: [{ name: config.title ?? 'OpenAtlas Discovery' - }], - link: [ - { - rel: 'icon', - type: 'image/svg+xml', - href: '/favicon.svg', - sizes: 'any' - } - ] + }] } }, runtimeConfig: {