Skip to content

Commit e841099

Browse files
authored
fix: banner in prod (FabricMC#523)
1 parent 67d1bc3 commit e841099

2 files changed

Lines changed: 7 additions & 24 deletions

File tree

.vitepress/theme/components/BannerComponent.vue

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ const strings = computed(() => {
3131
}
3232
});
3333
34-
watch(height, () =>
35-
document.documentElement.style.setProperty("--vp-layout-top-height", `${height.value + 16}px`)
34+
watch([height, strings], () =>
35+
document.documentElement.style.setProperty(
36+
"--vp-layout-top-height",
37+
`${strings.value.length ? height.value + 16 : 0}px`
38+
)
3639
);
3740
</script>
3841

@@ -47,24 +50,6 @@ watch(height, () =>
4750
</div>
4851
</template>
4952

50-
<style>
51-
html {
52-
--vp-layout-top-height: 88px;
53-
}
54-
55-
@media (min-width: 375px) {
56-
html {
57-
--vp-layout-top-height: 64px;
58-
}
59-
}
60-
61-
@media (min-width: 768px) {
62-
html {
63-
--vp-layout-top-height: 40px;
64-
}
65-
}
66-
</style>
67-
6853
<style scoped>
6954
div {
7055
align-items: center;

.vitepress/theme/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import mediumZoom from "medium-zoom";
22
import { type Theme, useData, useRouter } from "vitepress";
33
import { enhanceAppWithTabs } from "vitepress-plugin-tabs/client";
44
import DefaultTheme from "vitepress/theme";
5-
import { defineAsyncComponent, h, nextTick, onMounted, watch } from "vue";
5+
import { h, nextTick, onMounted, watch } from "vue";
66

77
import AuthorsComponent from "./components/AuthorsComponent.vue";
8+
import BannerComponent from "./components/BannerComponent.vue";
89
import ChoiceComponent from "./components/ChoiceComponent.vue";
910
import ColorSwatch from "./components/ColorSwatch.vue";
1011
import DownloadEntry from "./components/DownloadEntry.vue";
@@ -45,9 +46,6 @@ export default {
4546
};
4647

4748
if (theme.value.env !== "github") {
48-
const BannerComponent = defineAsyncComponent(
49-
() => import("./components/BannerComponent.vue")
50-
);
5149
(children as any)["layout-top"] = () => h(BannerComponent);
5250
}
5351

0 commit comments

Comments
 (0)