Skip to content

Commit d16630f

Browse files
authored
docs: add viteconf2025 banner (#2065)
1 parent da64132 commit d16630f

File tree

4 files changed

+293
-1
lines changed

4 files changed

+293
-1
lines changed

.vitepress/config.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import type { DefaultTheme } from 'vitepress'
1+
import path from 'node:path'
2+
import fs from 'node:fs'
3+
import type { DefaultTheme, HeadConfig } from 'vitepress'
24
import { defineConfig } from 'vitepress'
35
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
46
import {
@@ -77,6 +79,17 @@ const versionLinks = ((): DefaultTheme.NavItemWithLink[] => {
7779
}
7880
})()
7981

82+
function inlineScript(file: string): HeadConfig {
83+
return [
84+
'script',
85+
{},
86+
fs.readFileSync(
87+
path.resolve(__dirname, `./inlined-scripts/${file}`),
88+
'utf-8',
89+
),
90+
]
91+
}
92+
8093
export default defineConfig({
8194
title: `Vite${additionalTitle}`,
8295
description: '次世代フロントエンドツール',
@@ -111,6 +124,7 @@ export default defineConfig({
111124
href: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@600&family=IBM+Plex+Mono:wght@400&display=swap',
112125
},
113126
],
127+
inlineScript('banner.js'),
114128
['link', { rel: 'me', href: 'https://m.webtoo.ls/@vite' }],
115129
['meta', { property: 'og:type', content: 'website' }],
116130
['meta', { property: 'og:title', content: ogTitle }],

.vitepress/inlined-scripts/banner.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
;(() => {
2+
const restore = (key, cls, def = false) => {
3+
const saved = localStorage.getItem(key)
4+
if (saved ? saved !== 'false' : def) {
5+
document.documentElement.classList.add(cls)
6+
}
7+
}
8+
9+
window.__VITE_BANNER_ID__ = 'viteconf2025'
10+
restore(`vite-docs-banner-${__VITE_BANNER_ID__}`, 'banner-dismissed')
11+
})()
Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
<script setup>
2+
/**
3+
* 新しいバナーを追加する場合:
4+
* 1. ../index.ts のバナースロットのコメントを解除
5+
* 2. ../../inlined-scripts/restorePreferences.ts の BANNER_ID のコメントを解除して更新
6+
* 3. 必要に応じて --vp-layout-top-height を更新
7+
*/
8+
import { ref } from 'vue'
9+
10+
const open = ref(true)
11+
12+
/**
13+
* バナーが削除可能な場合はこれを呼び出す
14+
*/
15+
function dismiss() {
16+
open.value = false
17+
document.documentElement.classList.add('banner-dismissed')
18+
localStorage.setItem(`vite-docs-banner-${__VITE_BANNER_ID__}`, 'true')
19+
}
20+
</script>
21+
22+
<template>
23+
<div class="banner" v-if="open">
24+
<svg
25+
style="margin-right: 0.5rem"
26+
width="20"
27+
height="20"
28+
viewBox="0 0 30 30"
29+
fill="none"
30+
xmlns="http://www.w3.org/2000/svg"
31+
>
32+
<g>
33+
<path
34+
d="M20.3653 1.01733L11.1779 2.87249C11.0895 2.87249 11.0012 2.96082 11.0012 2.96082C10.9128 3.04916 10.9128 3.13751 10.9128 3.13751L10.3828 13.2083C10.3828 13.2967 10.3828 13.2967 10.3828 13.3851C10.3828 13.4734 10.4711 13.4734 10.4711 13.4734C10.4711 13.4734 10.5595 13.5618 10.6478 13.5618C10.7361 13.5618 10.7361 13.5618 10.8245 13.5618L13.3864 12.9433C13.6514 12.855 13.8281 13.12 13.8281 13.3851L13.033 17.3603C12.9447 17.6254 13.2097 17.8905 13.4748 17.8021L15.0648 17.272C15.3299 17.1837 15.5066 17.4487 15.5066 17.7137L14.2697 23.8976C14.1815 24.251 14.7115 24.5159 14.8882 24.1626L15.0648 23.8976L22.5738 8.08458C22.5738 7.90789 22.3088 7.55453 22.0438 7.64287L19.3935 8.17292C19.1286 8.26125 18.9519 7.99624 19.0402 7.73122L20.7187 1.45903C20.807 1.19401 20.6304 0.928988 20.3653 1.01733Z"
35+
fill="url(#paint0_linear_648_13)"
36+
/>
37+
<path
38+
d="M29.6424 3.75619C29.2891 3.22614 28.5824 2.96112 27.964 3.04945L20.985 4.37457L20.72 5.43465L28.2289 4.10955C28.494 4.02121 28.7591 4.19788 28.9357 4.37457C29.1124 4.63959 29.1124 4.90462 28.9357 5.16964L15.773 28.5799C15.6846 28.845 15.4196 28.9332 15.1545 28.9332C14.8896 28.9332 14.6245 28.7566 14.5361 28.5799L1.10836 5.08129C0.931674 4.90462 0.931674 4.55125 1.10836 4.37457C1.28504 4.19788 1.46172 4.10955 1.72674 4.10955C1.72674 4.10955 1.81508 4.10955 1.90342 4.10955L9.85411 5.523L9.94246 4.55125L1.99176 3.04945C1.28504 2.96112 0.666654 3.22614 0.313291 3.75619C-0.0400717 4.28623 -0.128412 4.99295 0.22495 5.61134L13.6528 29.1099C13.9178 29.64 14.5361 29.9933 15.1545 29.9933C15.773 29.9933 16.303 29.64 16.6563 29.1099L29.8191 5.61134C30.0842 4.99295 30.0842 4.28623 29.6424 3.75619Z"
39+
fill="url(#paint1_linear_648_13)"
40+
/>
41+
</g>
42+
<defs>
43+
<linearGradient
44+
id="paint0_linear_648_13"
45+
x1="10.5947"
46+
y1="3.97762"
47+
x2="20.9471"
48+
y2="17.0584"
49+
gradientUnits="userSpaceOnUse"
50+
>
51+
<stop stop-color="#B047FF" />
52+
<stop offset="0.75" stop-color="#FFD0D0" />
53+
<stop offset="0.9167" stop-color="#FFF3E6" />
54+
</linearGradient>
55+
<linearGradient
56+
id="paint1_linear_648_13"
57+
x1="8.078"
58+
y1="1.32911"
59+
x2="23.118"
60+
y2="18.0977"
61+
gradientUnits="userSpaceOnUse"
62+
>
63+
<stop stop-color="#57CCFF" />
64+
<stop offset="1" stop-color="#AF48FF" />
65+
</linearGradient>
66+
</defs>
67+
</svg>
68+
<p class="vt-banner-text">
69+
<span class="vt-main">ViteConf 2025</span>
70+
<span class="vt-tagline">
71+
· 初の<span style="font-weight: 900">対面開催</span></span
72+
>
73+
<span class="vt-place"> · Amsterdam</span>
74+
<span class="vt-date"> · 10月09-10日</span>
75+
<a
76+
target="_blank"
77+
class="vt-primary-action"
78+
href="https://viteconf.amsterdam/?utm_source=vite&utm_content=top_banner"
79+
>
80+
登録
81+
</a>
82+
</p>
83+
<button @click="dismiss">
84+
<svg
85+
class="close"
86+
xmlns="http://www.w3.org/2000/svg"
87+
aria-hidden="true"
88+
focusable="false"
89+
viewBox="0 0 24 24"
90+
>
91+
<path
92+
d="M18.9,10.9h-6v-6c0-0.6-0.4-1-1-1s-1,0.4-1,1v6h-6c-0.6,0-1,0.4-1,1s0.4,1,1,1h6v6c0,0.6,0.4,1,1,1s1-0.4,1-1v-6h6c0.6,0,1-0.4,1-1S19.5,10.9,18.9,10.9z"
93+
/>
94+
</svg>
95+
</button>
96+
<div class="glow glow--purple"></div>
97+
<div class="glow glow--blue"></div>
98+
</div>
99+
</template>
100+
101+
<style>
102+
html:not(.banner-dismissed) {
103+
--vp-layout-top-height: 30px;
104+
}
105+
</style>
106+
107+
<style scoped>
108+
.banner {
109+
position: fixed;
110+
z-index: 10;
111+
box-sizing: border-box;
112+
top: 0;
113+
left: 0;
114+
right: 0;
115+
height: var(--vp-layout-top-height);
116+
line-height: var(--vp-layout-top-height);
117+
text-align: center;
118+
font-size: 12px;
119+
font-weight: 600;
120+
color: white;
121+
background: #262626;
122+
display: flex;
123+
justify-content: center;
124+
align-items: center;
125+
overflow: hidden;
126+
}
127+
128+
.glow.glow--purple {
129+
position: absolute;
130+
bottom: -15%;
131+
left: -75%;
132+
width: 80%;
133+
aspect-ratio: 1.5;
134+
pointer-events: none;
135+
border-radius: 100%;
136+
background: linear-gradient(270deg, #7a23a1, #715ebde6 60% 80%, #bd34fe00);
137+
filter: blur(15vw);
138+
transform: none;
139+
opacity: 0.6;
140+
}
141+
142+
.glow.glow--blue {
143+
position: absolute;
144+
bottom: -15%;
145+
right: -40%;
146+
width: 80%;
147+
aspect-ratio: 1.5;
148+
pointer-events: none;
149+
border-radius: 100%;
150+
background: linear-gradient(180deg, #61d9ff, #0000);
151+
filter: blur(15vw);
152+
transform: none;
153+
opacity: 0.3;
154+
}
155+
156+
@media (min-width: 768px) {
157+
.glow.glow--blue {
158+
top: -15%;
159+
right: -40%;
160+
width: 80%;
161+
}
162+
163+
.glow.glow--purple {
164+
bottom: -15%;
165+
left: -40%;
166+
width: 80%;
167+
}
168+
}
169+
170+
@media (min-width: 1025px) {
171+
.glow.glow--blue {
172+
top: -15%;
173+
right: -40%;
174+
width: 80%;
175+
}
176+
177+
.glow.glow--purple {
178+
bottom: -15%;
179+
left: -40%;
180+
width: 80%;
181+
}
182+
}
183+
184+
.banner-dismissed .banner {
185+
display: none;
186+
}
187+
188+
button {
189+
position: absolute;
190+
right: 0;
191+
top: 0;
192+
padding: 5px 5px;
193+
}
194+
195+
.close {
196+
width: 20px;
197+
height: 20px;
198+
fill: #fff;
199+
transform: rotate(45deg);
200+
}
201+
202+
.vt-banner-text {
203+
color: #fff;
204+
font-size: 12px;
205+
}
206+
207+
.vt-main {
208+
color: transparent;
209+
background-image: linear-gradient(120deg, #b047ff 16%, #9499ff, #9499ff);
210+
background-clip: text;
211+
}
212+
213+
.vt-primary-action {
214+
background:
215+
radial-gradient(141.42% 141.42% at 100% 0%, #ffffff80, #fff0),
216+
radial-gradient(140.35% 140.35% at 100% 94.74%, #bd34fe, #bd34fe00),
217+
radial-gradient(89.94% 89.94% at 18.42% 15.79%, #41d1ff, #41d1ff00);
218+
color: #fff;
219+
padding: 4px 8px;
220+
border-radius: 5px;
221+
font-size: 10px;
222+
text-decoration: none;
223+
margin: 0 10px;
224+
transition: all 0.2s ease-in-out;
225+
226+
&:hover {
227+
box-shadow: 0 1px #fffc inset;
228+
}
229+
}
230+
231+
@media (max-width: 1280px) {
232+
.banner .vt-banner-text {
233+
font-size: 14px;
234+
}
235+
236+
.vt-tagline {
237+
display: none;
238+
}
239+
}
240+
241+
@media (max-width: 780px) {
242+
.vt-tagline {
243+
display: none;
244+
}
245+
246+
.vt-coupon {
247+
display: none;
248+
}
249+
250+
.vt-primary-action {
251+
margin: 0 10px;
252+
padding: 4px 8px;
253+
}
254+
255+
.vt-time-now {
256+
display: none;
257+
}
258+
}
259+
260+
@media (max-width: 560px) {
261+
.vt-place {
262+
display: none;
263+
}
264+
}
265+
</style>

.vitepress/theme/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import './styles/landing.css'
88
import AsideSponsors from './components/AsideSponsors.vue'
99
import SvgImage from './components/SvgImage.vue'
1010
import YouTubeVideo from './components/YouTubeVideo.vue'
11+
import SponsorBanner from './components/SponsorBanner.vue'
1112
import 'virtual:group-icons.css'
1213

1314
export default {
1415
extends: DefaultTheme,
1516
Layout() {
1617
return h(DefaultTheme.Layout, null, {
18+
'layout-top': () => h(SponsorBanner),
1719
'aside-ads-before': () => h(AsideSponsors),
1820
})
1921
},

0 commit comments

Comments
 (0)