Skip to content

Commit 597d1eb

Browse files
committed
Revert "Merge pull request #2 from r0hitm:i18n"
This reverts commit 092ae0d, reversing changes made to e8e49f8. Reason: Because of SEO issues introduced, and flakey project structure.
1 parent 092ae0d commit 597d1eb

22 files changed

+67
-718
lines changed

TODO.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [ ] i18n
2+
- [ ] ics + CSAPP 新記事

astro.config.mjs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,15 @@ import remarkToc from "remark-toc";
88
import rehypeExternalLinks from "rehype-external-links";
99
import { SITE } from "./src/consts";
1010

11-
const isProd = import.meta.env.PROD;
12-
1311
// https://astro.build/config
1412
export default defineConfig({
15-
site: isProd ? SITE.website : "http://localhost:4321",
13+
site: SITE.website,
1614
i18n: {
17-
locales: ["en", "ja"],
18-
defaultLocale: "en",
19-
fallback: {
20-
ja: "en"
21-
},
22-
routing: {
23-
prefixDefaultLocale: false,
24-
fallbackType: "rewrite" // TODO: later add not-translated warning to those pages
25-
}
15+
locales: ["en", "ja-JP"],
16+
defaultLocale: "en"
2617
},
2718
prefetch: true,
28-
integrations: [
29-
mdx(),
30-
sitemap({
31-
i18n: {
32-
defaultLocale: "en",
33-
locales: {
34-
en: "en",
35-
ja: "ja-JP"
36-
}
37-
}
38-
}),
39-
react()
40-
],
19+
integrations: [mdx(), sitemap(), react()],
4120
markdown: {
4221
shikiConfig: {
4322
theme: "one-dark-pro",

src/components/Card.astro

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
import type { CollectionEntry } from "astro:content";
33
import FormattedDate from "./FormattedDate.astro";
44
import { Calendar } from "@lucide/astro";
5-
import { getLangFromUrl, useTranslations } from "@/i18n";
6-
import { getRelativeLocaleUrl } from "astro:i18n";
75
86
export interface Props {
97
href?: string;
@@ -14,13 +12,10 @@ export interface Props {
1412
const { href, postId, frontmatter } = Astro.props;
1513
1614
const { title, description, pubDatetime, modDatetime, draft } = frontmatter;
17-
18-
const lang = getLangFromUrl(Astro.url);
19-
const t = useTranslations(lang);
2015
---
2116

2217
<li class="my-6 list-none">
23-
<a href={getRelativeLocaleUrl(lang, href)}>
18+
<a href={href}>
2419
<!-- <img width={720} height={360} src={} alt="" /> -->
2520
<h2
2621
class="text-d-accent inline-block text-lg font-semibold decoration-dashed underline-offset-4 hover:underline hover:decoration-dashed hover:underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0"
@@ -32,13 +27,11 @@ const t = useTranslations(lang);
3227

3328
{
3429
draft ? (
35-
<div class="text-d-card-muted text-sm uppercase">
36-
[{t("page.draft")}]
37-
</div>
30+
<div class="text-d-card-muted text-sm uppercase">[Draft]</div>
3831
) : (
3932
<div class="my-2 flex items-center text-sm italic opacity-80">
4033
<Calendar class="mr-1 size-4" />
41-
{modDatetime && t("page.updated")}
34+
{modDatetime && "Updated:"}
4235
&nbsp;
4336
<FormattedDate date={modDatetime || pubDatetime} />
4437
</div>

src/components/Footer.astro

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
---
2-
import { getLangFromUrl, useTranslations } from "@/i18n";
3-
import { getRelativeLocaleUrl } from "astro:i18n";
42
import Socials from "./Socials.astro";
53
64
const currentYear = new Date().getFullYear();
7-
8-
const lang = getLangFromUrl(Astro.url);
9-
const t = useTranslations(lang);
105
---
116

127
<footer
@@ -18,24 +13,23 @@ const t = useTranslations(lang);
1813
class="mt-2 flex flex-col items-center justify-center gap-y-2 text-sm sm:flex-row sm:gap-x-4"
1914
>
2015
<a
21-
href={getRelativeLocaleUrl(lang, "support")}
16+
href="/support"
2217
class="block underline decoration-dashed underline-offset-4 hover:decoration-wavy"
2318
>
24-
{t("footer.support")}
19+
Buy me a coffee
2520
</a>
2621
<span class="hidden sm:block">・</span>
2722
<a
28-
href="https://github.com/r0hitm/devavatar/issues"
29-
target="_blank"
23+
href="https://github.com/r0hitm/devavatar-kaisei/issues"
3024
class="block underline decoration-dashed underline-offset-4 hover:decoration-wavy"
3125
rel="noopener noreferrer"
3226
>
33-
{t("footer.report")}
27+
Report an issue
3428
</a>
3529
</div>
3630

3731
<p class="mt-4 text-center text-sm">
38-
{t("footer.cookie")}
32+
No cookies, no ads, no tracking ― just blog.
3933
</p>
4034

4135
<div

src/components/FormattedDate.astro

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
2-
import { getLangFromUrl } from "@/i18n";
2+
import { LOCALE } from "@/consts";
33
44
interface Props {
55
date: Date;
66
}
77
88
const { date } = Astro.props;
9-
const lang = getLangFromUrl(Astro.url);
109
---
1110

1211
<time datetime={date.toISOString()}>
1312
{
14-
date.toLocaleDateString(lang, {
13+
date.toLocaleDateString(LOCALE.langTag, {
1514
year: "numeric",
1615
month: "short",
1716
day: "numeric"

src/components/Header.astro

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ import { Menu, X } from "@lucide/astro";
55
import Search from "./Search";
66
import getPosts from "@/utils/getPosts";
77
import ThemeBtn from "./ThemeBtn.astro";
8-
import { getLangFromUrl, useTranslations } from "@/i18n";
9-
import { getRelativeLocaleUrl } from "astro:i18n";
10-
import LangSel from "./LangSel";
118
129
const posts = await getPosts();
1310
@@ -17,16 +14,13 @@ const searchList = posts.map(({ data, id }) => ({
1714
data,
1815
postId: id
1916
}));
20-
21-
const lang = getLangFromUrl(Astro.url);
22-
const t = useTranslations(lang);
2317
---
2418

2519
<header class="border-d-border mx-auto w-full max-w-4xl border-b py-2 sm:py-4">
2620
<div class="flex items-center justify-between">
2721
<!-- Header Logo -->
2822
<a
29-
href={getRelativeLocaleUrl(lang, "/")}
23+
href="/"
3024
class="group relative block text-xl font-semibold whitespace-nowrap sm:text-2xl"
3125
>
3226
<span class="relative font-mono tracking-wider">
@@ -48,50 +42,30 @@ const t = useTranslations(lang);
4842
<nav>
4943
<ul class="flex items-center justify-end gap-4">
5044
<li>
51-
<HeaderLink href={getRelativeLocaleUrl(lang, "posts")}>
52-
{t("header.posts")}</HeaderLink
53-
>
45+
<HeaderLink href="/posts">posts</HeaderLink>
5446
</li>
5547
<li>
56-
<HeaderLink
57-
href={getRelativeLocaleUrl(lang, "projects")}
58-
>{t("header.projects")}</HeaderLink
59-
>
48+
<HeaderLink href="/projects">projects</HeaderLink>
6049
</li>
6150
<li>
62-
<HeaderLink href={getRelativeLocaleUrl(lang, "tags")}
63-
>{t("header.tags")}</HeaderLink
64-
>
51+
<HeaderLink href="/tags">tags</HeaderLink>
6552
</li>
6653
<li>
67-
<HeaderLink href={getRelativeLocaleUrl(lang, "about")}
68-
>{t("header.about")}</HeaderLink
69-
>
54+
<HeaderLink href="/about">about</HeaderLink>
7055
</li>
7156
<li>
72-
<Search
73-
searchList={searchList}
74-
lang={lang}
75-
client:load
76-
/>
57+
<Search searchList={searchList} client:load />
7758
</li>
7859
<li>
7960
<ThemeBtn />
8061
</li>
81-
<li>
82-
<LangSel
83-
lang={lang}
84-
langList={["en", "ja"]}
85-
client:load
86-
/>
87-
</li>
8862
</ul>
8963
</nav>
9064
</div>
9165

9266
{/* Search Button & Mobile Menu */}
9367
<div class="flex items-center gap-2 sm:hidden">
94-
<Search searchList={searchList} lang={lang} client:load />
68+
<Search searchList={searchList} client:load />
9569

9670
<button id="hamburger-menu" class="p-2" aria-label="Menu Button">
9771
<Menu class="size-6" id="menu-icon" />
@@ -108,41 +82,33 @@ const t = useTranslations(lang);
10882
>
10983
<li>
11084
<HeaderLink
111-
href={getRelativeLocaleUrl(lang, "posts")}
85+
href="/posts"
11286
class="hover:bg-d-accent/10 block w-full rounded-md px-2 py-2"
113-
>{t("header.posts")}</HeaderLink
87+
>posts</HeaderLink
11488
>
11589
</li>
11690
<li>
11791
<HeaderLink
118-
href={getRelativeLocaleUrl(lang, "projects")}
92+
href="/projects"
11993
class="hover:bg-d-accent/10 block w-full rounded-md px-2 py-2"
120-
>{t("header.projects")}</HeaderLink
94+
>projects</HeaderLink
12195
>
12296
</li>
12397
<li>
12498
<HeaderLink
125-
href={getRelativeLocaleUrl(lang, "tags")}
99+
href="/tags"
126100
class="hover:bg-d-accent/10 block w-full rounded-md px-2 py-2"
127-
>{t("header.tags")}</HeaderLink
101+
>tags</HeaderLink
128102
>
129103
</li>
130104
<li>
131105
<HeaderLink
132-
href={getRelativeLocaleUrl(lang, "about")}
106+
href="/about"
133107
class="hover:bg-d-accent/10 block w-full rounded-md px-2 py-2"
134-
>{t("header.about")}</HeaderLink
108+
>about</HeaderLink
135109
>
136110
</li>
137111
<li>
138-
<LangSel
139-
lang={lang}
140-
langList={["en", "ja"]}
141-
showLabel
142-
client:load
143-
/>
144-
</li>
145-
<li class="">
146112
<ThemeBtn />
147113
</li>
148114
</ul>

src/components/HeaderLink.astro

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@ import type { HTMLAttributes } from "astro/types";
44
type Props = HTMLAttributes<"a">;
55
66
const { href, class: className, ...props } = Astro.props;
7-
8-
const pathname = Astro.url.pathname;
7+
const pathname = Astro.url.pathname.replace(import.meta.env.BASE_URL, "");
98
const subpath = pathname.match(/[^\/]+/g);
10-
const navpath = subpath && subpath[subpath.length - 1];
11-
const isActive =
12-
href === pathname ||
13-
href === "/" + (navpath || "") ||
14-
href === "/ja/" + (navpath || "") + "/"; // Fuck! localized urls are ending w/ `/` - fault or astro relativeurl I suppose
9+
const isActive = href === pathname || href === "/" + (subpath?.[0] || "");
1510
---
1611

1712
<a

src/components/LangSel.tsx

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

0 commit comments

Comments
 (0)