Skip to content

Commit 7258ba0

Browse files
committed
fix: favicon with prefix for github preview
1 parent 5e0c7a9 commit 7258ba0

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app/app.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script setup lang="ts">
2+
import { joinURL } from 'ufo'
3+
24
useHead({
35
titleTemplate: (title) =>
46
title
@@ -7,11 +9,22 @@ useHead({
79
})
810
911
if (import.meta.server) {
12+
// public/ assets are served under the app baseURL in production (GitHub Pages
13+
// serves the site at /litestar.dev-v2/), but Vite serves them at root in dev.
14+
// Build the href per environment, otherwise the favicon 404s on the deploy.
15+
const baseURL = import.meta.dev ? '/' : useRuntimeConfig().app.baseURL
16+
1017
useHead({
1118
meta: [
1219
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
1320
],
14-
link: [{ rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }],
21+
link: [
22+
{
23+
rel: 'icon',
24+
type: 'image/svg+xml',
25+
href: joinURL(baseURL, 'logo.svg'),
26+
},
27+
],
1528
htmlAttrs: {
1629
lang: 'en',
1730
},

0 commit comments

Comments
 (0)