Skip to content

Commit 5699257

Browse files
committed
avoid uwu logo layout shift
1 parent 7ae6897 commit 5699257

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

.vitepress/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,14 @@ export default defineConfigWithTheme<ThemeConfig>({
605605
'utf-8'
606606
)
607607
],
608+
[
609+
'script',
610+
{},
611+
fs.readFileSync(
612+
path.resolve(__dirname, './inlined-scripts/uwu.js'),
613+
'utf-8'
614+
)
615+
],
608616
[
609617
'script',
610618
{

.vitepress/inlined-scripts/uwu.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (location.search.includes('?uwu')) {
2+
document.documentElement.classList.add('uwu')
3+
}

.vitepress/theme/components/Home.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,12 @@ import { load, data, base } from './sponsors'
66
import SponsorsGroup from './SponsorsGroup.vue'
77
import VueMasteryModal from './VueMasteryModal.vue'
88
9-
const uwu = ref(false)
10-
11-
onMounted(async () => {
12-
uwu.value = location.search.includes('?uwu')
13-
await load()
14-
})
9+
onMounted(load)
1510
</script>
1611

1712
<template>
1813
<section id="hero">
19-
<img
20-
v-if="uwu"
21-
src="/logo-uwu.svg"
22-
style="width: 100%; max-width: 580px; margin: -80px auto -20px"
23-
/>
14+
<img id="uwu" />
2415
<h1 class="tagline">
2516
The
2617
<span class="accent">Progressive</span>
@@ -317,4 +308,13 @@ html:not(.dark) .accent,
317308
font-size: 36px;
318309
}
319310
}
311+
312+
:global(.uwu #uwu) {
313+
display: block;
314+
width: 100%;
315+
max-width: 580px;
316+
margin: -80px auto -20px;
317+
aspect-ratio: 145 / 91;
318+
content: url(/logo-uwu.svg);
319+
}
320320
</style>

0 commit comments

Comments
 (0)