Skip to content

Commit 5952d5c

Browse files
authored
Merge pull request #166 from vim-jp/feature/switch
2 parents 7e1d4cb + d88a45e commit 5952d5c

File tree

7 files changed

+73
-62
lines changed

7 files changed

+73
-62
lines changed

2025/src/components/Footer.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<footer style="background: linear-gradient(240deg, #9ebd13 0%, #069700 100%); color: #fff; text-align: center; padding: 20px 0;"/>

2025/src/components/Header.astro

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
import LanguagePicker from '../components/LanguagePicker.astro'
3+
---
4+
5+
<header class="hero">
6+
<LanguagePicker />
7+
<div class="container">
8+
<h1>VimConf <wbr />2025</h1>
9+
</div>
10+
</header>
11+
12+
<style>
13+
/* Hero Section */
14+
.hero {
15+
background: linear-gradient(110deg, #9ebd13 0%, #069700 100%);
16+
color: #fff;
17+
text-align: center;
18+
19+
h1 {
20+
font-size: 4rem;
21+
margin-bottom: 16px;
22+
font-family: "Cardo", serif;
23+
font-weight: 400;
24+
font-style: italic;
25+
}
26+
}
27+
28+
/* Container */
29+
.container {
30+
width: 90%;
31+
max-width: 960px;
32+
margin: auto;
33+
padding: 24px 0;
34+
}
35+
</style>
Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,49 @@
11
---
2-
import { languages } from '../i18n/ui';
32
import { base } from "astro:config/client"
43
4+
const languages = Object.keys(import.meta.glob('../pages/*.astro')).map(p=>p.split("/").at(-1).replace(".astro", "")).sort();
55
const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, "");
6+
const currentLang = pathname.split("/")[1];
67
---
7-
<ul class="language-picker">
8-
{Object.entries(languages).sort((a, b) => a < b ? 0 : -1).map(([lang, label]) => (
9-
<li class:list= {[{ active: pathname.startsWith(`/${label}`) }]} >
10-
<a href={`${base}/${lang}/`}>{label}</a>
11-
</li>
8+
<div class="language-switcher">
9+
{languages.map((lang, i) => (
10+
<>
11+
<a href={`${base}/${lang}/`} class:list={{active: lang === currentLang}}>
12+
{lang.toUpperCase()}
13+
</a>
14+
{i < languages.length - 1 && <span class="separator">/</span>}
15+
</>
1216
))}
13-
</ul>
17+
</div>
1418

1519
<style>
16-
ul {
17-
list-style: none;
18-
padding: 0;
19-
margin: 0;
20-
display: flex;
21-
justify-content: flex-end;
22-
margin-right: 1rem;
23-
24-
a {
25-
text-decoration: none;
26-
}
20+
.language-switcher {
21+
position: absolute;
22+
top: 1rem;
23+
right: 1rem;
24+
font-size: 1.5rem;
25+
font-weight: 500;
26+
}
2727

28+
.language-switcher a {
29+
color: rgba(255, 255, 255, 0.7);
30+
text-decoration: none;
31+
transition: color 0.2s ease;
2832
}
2933

30-
li:first-child::after {
31-
content: '/';
32-
display: 'inline block'
33-
margin: 0 8px;
34-
color: #333;
34+
.language-switcher a:hover {
35+
color: #ffffff;
36+
text-decoration: underline;
37+
}
3538

39+
.language-switcher .separator {
40+
color: rgba(255, 255, 255, 0.5);
41+
margin: 0 0.3rem;
3642
}
3743

38-
li.active > a {
39-
font-weight: bold;
40-
text-decoration: underline;
44+
/* Active language style */
45+
.language-switcher a.active {
46+
color: #ffffff;
47+
font-weight: 600;
4148
}
4249
</style>

2025/src/i18n/ui.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

2025/src/layouts/Layout.astro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
---
22
import { GoogleFontsOptimizer } from "astro-google-fonts-optimizer";
3+
import Header from "../components/Header.astro";
4+
import Footer from '../components/Footer.astro';
35
46
const { lang = 'ja' } = Astro.props;
57
---
@@ -17,7 +19,9 @@ const { lang = 'ja' } = Astro.props;
1719
<title>VimConf 2025</title>
1820
</head>
1921
<body>
22+
<Header />
2023
<slot />
24+
<Footer />
2125
</body>
2226
</html>
2327

2025/src/pages/en.astro

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
---
22
import Layout from '../layouts/Layout.astro';
3-
import LanguagePicker from '../components/LanguagePicker.astro'
43
---
54

65
<Layout lang="en">
7-
<header class="hero">
8-
<LanguagePicker />
9-
<div class="container">
10-
<h1>VimConf <wbr />2025</h1>
11-
</div>
12-
</header>
13-
146
<section>
157
<div class="container">
168
<h2 id="what-is-vimconf-2025" class="section-title"><a href="#what-is-vimconf-2025">What is VimConf 2025?</a></h2>
@@ -83,8 +75,6 @@ import LanguagePicker from '../components/LanguagePicker.astro'
8375
</p>
8476
</div>
8577
</section>
86-
<footer style="background: linear-gradient(240deg, #9ebd13 0%, #069700 100%); color: #fff; text-align: center; padding: 20px 0;">
87-
</footer>
8878
</Layout>
8979

9080
<style>
@@ -100,20 +90,6 @@ h3 {
10090
padding: 24px 0;
10191
}
10292

103-
/* Hero Section */
104-
.hero {
105-
background: linear-gradient(110deg, #9ebd13 0%, #069700 100%);
106-
color: #fff;
107-
text-align: center;
108-
109-
h1 {
110-
font-size: 4rem;
111-
margin-bottom: 16px;
112-
font-family: "Cardo", serif;
113-
font-weight: 400;
114-
font-style: italic;
115-
}
116-
}
11793

11894
/* Section Title */
11995
.section-title {

2025/src/pages/ja.astro

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
---
22
import Layout from '../layouts/Layout.astro';
3-
import LanguagePicker from '../components/LanguagePicker.astro'
43
---
54

65
<Layout>
7-
<header class="hero">
8-
<LanguagePicker />
9-
<div class="container">
10-
<h1>VimConf <wbr />2025</h1>
11-
</div>
12-
</header>
13-
146
<section>
157
<div class="container">
168
<h2 id="what-is-vimconf-2025" class="section-title"><a href="#what-is-vimconf-2025">VimConf 2025 とは?</a></h2>

0 commit comments

Comments
 (0)