diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f15441a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e83535 --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# build output +dist/ +.astro/ + +# dependencies +node_modules/ + +# local env / secrets (never commit) +.dev.vars +.dev.vars.* +.env +.env.* + +# cloudflare / wrangler +.wrangler/ +worker-configuration.d.ts + +# generated search index +public/pagefind/ + +# logs & debug +*.log +npm-debug.log* + +# editor / OS +.idea/ +.DS_Store +Thumbs.db diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..1812199 --- /dev/null +++ b/.npmrc @@ -0,0 +1,4 @@ +# Supply-chain hardening (ignore-scripts) is applied in CI only — see docs 06 §1.6. +# Locally we leave install scripts enabled so `sharp` can set up its binaries +# for build-time image processing (astro imageService: 'compile'). +fund=false diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..a45fd52 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +24 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..445561d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,11 @@ +# Generated / build output +dist/ +.astro/ +.wrangler/ +node_modules/ +public/pagefind/ +worker-configuration.d.ts +package-lock.json + +# Spec documentation suite — authored content, not ours to reformat +poli0981.dev-docs/ diff --git a/astro.config.mjs b/astro.config.mjs new file mode 100644 index 0000000..021b779 --- /dev/null +++ b/astro.config.mjs @@ -0,0 +1,112 @@ +// @ts-check +import { defineConfig, fontProviders } from "astro/config"; +import cloudflare from "@astrojs/cloudflare"; +import svelte from "@astrojs/svelte"; +import mdx from "@astrojs/mdx"; +import sitemap from "@astrojs/sitemap"; +import tailwindcss from "@tailwindcss/vite"; + +// Error/system pages that must never appear in the sitemap. +const NON_INDEXED = /\/(404|500|403|429|offline)\/?$/; + +// https://astro.build/config +export default defineConfig({ + site: "https://poli0981.dev", + // Default output is "static": every page prerenders unless it opts out with + // `export const prerender = false` (only api routes + middleware run on-demand). + output: "static", + + // The @cloudflare/vite-plugin (used by this adapter) runs `astro dev` on workerd and + // auto-exposes the wrangler.jsonc bindings (KV/ASSETS) + .dev.vars — no platformProxy needed. + adapter: cloudflare({ + imageService: "compile", // sharp runs at build time (Workers has no runtime sharp) + }), + + // vi is the default locale and carries NO url prefix; en lives under /en/. + // Architecture must allow adding `ja` later without a refactor (see src/i18n/routing.ts). + i18n: { + defaultLocale: "vi", + locales: ["vi", "en"], + routing: { prefixDefaultLocale: false }, + }, + + integrations: [ + svelte(), + mdx(), + sitemap({ + i18n: { defaultLocale: "vi", locales: { vi: "vi", en: "en" } }, + filter: (page) => !NON_INDEXED.test(page), + }), + ], + + // Prism (class-based) instead of Shiki: Shiki emits per-token inline styles that + // violate our CSP. Prism colors code via CSS classes styled in the Prose component. + markdown: { + syntaxHighlight: "prism", + }, + + // Tailwind v4 is wired through the Vite plugin (NOT the legacy @astrojs/tailwind). + vite: { plugins: [tailwindcss()] }, + + // Self-hosted fonts via the built-in Fonts API. Subsets include `vietnamese`. + // Preload is chosen per- in BaseLayout — exactly the 2 first-paint files. + fonts: [ + { + provider: fontProviders.google(), + name: "Bricolage Grotesque", + cssVariable: "--ff-display", + weights: ["500 800"], + subsets: ["latin", "vietnamese"], + display: "swap", + }, + { + provider: fontProviders.google(), + name: "Be Vietnam Pro", + cssVariable: "--ff-body", + weights: [400, 500, 600], + subsets: ["latin", "vietnamese"], + display: "swap", + }, + { + provider: fontProviders.google(), + name: "Literata", + cssVariable: "--ff-reading", + weights: ["400 500"], + styles: ["normal", "italic"], + subsets: ["latin", "vietnamese"], + display: "swap", + }, + { + provider: fontProviders.google(), + name: "JetBrains Mono", + cssVariable: "--ff-mono", + weights: [400, 700], + subsets: ["latin", "vietnamese"], + display: "swap", + }, + ], + + // Built-in CSP. Astro auto-hashes the + +{#if visible} + +{/if} + + diff --git a/src/components/LinksList.astro b/src/components/LinksList.astro new file mode 100644 index 0000000..1c2bd50 --- /dev/null +++ b/src/components/LinksList.astro @@ -0,0 +1,84 @@ +--- +import { SOCIAL_LINKS } from "../lib/links"; +import type { Locale } from "../i18n/routing"; + +interface Props { + locale: Locale; +} +const { locale } = Astro.props; + +function relFor(href: string, me?: boolean): string | undefined { + const parts: string[] = []; + if (me) parts.push("me"); + if (href.startsWith("http")) parts.push("noopener", "noreferrer"); + return parts.length ? parts.join(" ") : undefined; +} +--- + + + + diff --git a/src/components/MenuSheet.svelte b/src/components/MenuSheet.svelte new file mode 100644 index 0000000..b356e9b --- /dev/null +++ b/src/components/MenuSheet.svelte @@ -0,0 +1,177 @@ + + + + + + + diff --git a/src/components/MobileTabBar.astro b/src/components/MobileTabBar.astro new file mode 100644 index 0000000..38da63b --- /dev/null +++ b/src/components/MobileTabBar.astro @@ -0,0 +1,125 @@ +--- +import { toLocale, useTranslations } from "../i18n"; +import { homePath, sectionPath, type Locale } from "../i18n/routing"; +import { isActivePath } from "../lib/nav"; + +const locale: Locale = toLocale(Astro.currentLocale); +const t = useTranslations(locale); +const pathname = Astro.url.pathname; + +const tabs = [ + { href: homePath(locale), label: t.nav.home, icon: "home" as const }, + { href: sectionPath("blog", locale), label: t.nav.blog, icon: "blog" as const }, + { href: sectionPath("stories", locale), label: t.nav.stories, icon: "book" as const }, +]; +--- + + + + diff --git a/src/components/Pagination.astro b/src/components/Pagination.astro new file mode 100644 index 0000000..445fd5f --- /dev/null +++ b/src/components/Pagination.astro @@ -0,0 +1,81 @@ +--- +interface NavLink { + href: string; + label: string; +} +interface Props { + prev?: NavLink | null; + next?: NavLink | null; + prevText?: string; + nextText?: string; + ariaLabel?: string; +} +const { + prev = null, + next = null, + prevText = "Trước", + nextText = "Sau", + ariaLabel = "Pagination", +} = Astro.props; +--- + + + + diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro new file mode 100644 index 0000000..343611a --- /dev/null +++ b/src/components/PostCard.astro @@ -0,0 +1,97 @@ +--- +import { Image } from "astro:assets"; +import { type BlogEntry, readingTime } from "../lib/collections"; +import { sectionPath, type Locale } from "../i18n/routing"; +import { useTranslations } from "../i18n"; +import { formatDate, isoDate } from "../lib/format"; + +interface Props { + entry: BlogEntry; + locale: Locale; +} +const { entry, locale } = Astro.props; +const t = useTranslations(locale); +const href = sectionPath("blog", locale, entry.id); +const mins = readingTime(entry.body); +--- + +
+ + { + entry.data.cover && ( +
+ +
+ ) + } +
+

{entry.data.title}

+

{entry.data.description}

+
+ + + {mins} {t.post.minRead} +
+
+
+
+ + diff --git a/src/components/PostGrid.astro b/src/components/PostGrid.astro new file mode 100644 index 0000000..1904777 --- /dev/null +++ b/src/components/PostGrid.astro @@ -0,0 +1,60 @@ +--- +import PostCard from "./PostCard.astro"; +import type { BlogEntry } from "../lib/collections"; +import type { Locale } from "../i18n/routing"; + +interface Props { + posts: BlogEntry[]; + locale: Locale; + emptyText?: string; + emptyHref?: string; + emptyLabel?: string; +} +const { posts, locale, emptyText, emptyHref, emptyLabel } = Astro.props; +--- + +{ + posts.length > 0 ? ( +
+ {posts.map((entry) => ( + + ))} +
+ ) : ( +
+

{emptyText}

+ {emptyHref && emptyLabel && {emptyLabel} →} +
+ ) +} + + diff --git a/src/components/ProjectCard.astro b/src/components/ProjectCard.astro new file mode 100644 index 0000000..ffa3b2f --- /dev/null +++ b/src/components/ProjectCard.astro @@ -0,0 +1,123 @@ +--- +import { type ProjectEntry } from "../lib/collections"; +import { sectionPath, type Locale } from "../i18n/routing"; + +interface Props { + entry: ProjectEntry; + locale: Locale; +} +const { entry, locale } = Astro.props; +const href = sectionPath("projects", locale, entry.id); +const { name, tagline, stack, repo, url, featured, year } = entry.data; +--- + +
+ +
+

{name}

+ {year} +
+

{tagline}

+ { + stack.length > 0 && ( +
    + {stack.slice(0, 6).map((s) => ( +
  • {s}
  • + ))} +
+ ) + } +
+ { + (repo || url) && ( + + ) + } +
+ + diff --git a/src/components/Prose.astro b/src/components/Prose.astro new file mode 100644 index 0000000..7afa29c --- /dev/null +++ b/src/components/Prose.astro @@ -0,0 +1,152 @@ +--- +interface Props { + class?: string; + /** Reader mode widens the measure and uses the reading font at a larger size. */ + reader?: boolean; +} +const { class: className = "", reader = false } = Astro.props; +--- + +
+ +
+ + diff --git a/src/components/ReadingControls.svelte b/src/components/ReadingControls.svelte new file mode 100644 index 0000000..4c4e108 --- /dev/null +++ b/src/components/ReadingControls.svelte @@ -0,0 +1,209 @@ + + + + +
+ + + {#if open} +
+
+ {labels.sizeTitle} +
+ + + +
+
+
+ {labels.themeTitle} +
+ + + +
+
+
+ {/if} +
+ + diff --git a/src/components/SkipLink.astro b/src/components/SkipLink.astro new file mode 100644 index 0000000..e5d31fb --- /dev/null +++ b/src/components/SkipLink.astro @@ -0,0 +1,28 @@ +--- +interface Props { + href?: string; + label?: string; +} +const { href = "#main", label = "Bỏ qua đến nội dung" } = Astro.props; +--- + + + + diff --git a/src/components/StoryCard.astro b/src/components/StoryCard.astro new file mode 100644 index 0000000..8953aa8 --- /dev/null +++ b/src/components/StoryCard.astro @@ -0,0 +1,125 @@ +--- +import { type StoryEntry } from "../lib/collections"; +import { sectionPath, type Locale } from "../i18n/routing"; +import { useTranslations } from "../i18n"; +import { formatDate, isoDate } from "../lib/format"; + +interface Props { + entry: StoryEntry; + locale: Locale; +} +const { entry, locale } = Astro.props; +const t = useTranslations(locale); +const href = sectionPath("stories", locale, ...entry.id.split("/")); + +const statusLabel = { + ongoing: t.story.statusOngoing, + complete: t.story.statusComplete, + dropped: t.story.statusDropped, +}[entry.data.status]; + +const hasCW = entry.data.contentWarning.length > 0; +--- + +
+ +
+
+ {statusLabel} + { + hasCW && ( + + ⚠ {entry.data.contentWarning[0]} + + ) + } +
+ {entry.data.series &&

{entry.data.series}

} +

{entry.data.title}

+

{entry.data.description}

+
+ +
+
+
+
+ + diff --git a/src/components/TagPill.astro b/src/components/TagPill.astro new file mode 100644 index 0000000..b0a3ed2 --- /dev/null +++ b/src/components/TagPill.astro @@ -0,0 +1,45 @@ +--- +import { sectionPath, type Locale } from "../i18n/routing"; + +interface Props { + tag: string; + locale: Locale; + count?: number; + /** When false, render a plain chip instead of a link to the tag page. */ + link?: boolean; +} +const { tag, locale, count, link = true } = Astro.props; +const href = sectionPath("blog", locale, "tag", tag); +const Tag = link ? "a" : "span"; +--- + + + #{tag}{count != null && {count}} + + + diff --git a/src/components/ThemeToggle.svelte b/src/components/ThemeToggle.svelte new file mode 100644 index 0000000..0923e89 --- /dev/null +++ b/src/components/ThemeToggle.svelte @@ -0,0 +1,82 @@ + + + + + diff --git a/src/components/Waveline.svelte b/src/components/Waveline.svelte new file mode 100644 index 0000000..5c23867 --- /dev/null +++ b/src/components/Waveline.svelte @@ -0,0 +1,130 @@ + + + + + + + diff --git a/src/content.config.ts b/src/content.config.ts new file mode 100644 index 0000000..c8ea68c --- /dev/null +++ b/src/content.config.ts @@ -0,0 +1,95 @@ +import { defineCollection, z, type SchemaContext } from "astro:content"; +import { glob } from "astro/loaders"; + +const LANG = z.enum(["vi", "en"]); + +/** Fields shared by long-form content (blog + stories). */ +const base = ({ image }: SchemaContext) => + z.object({ + title: z.string().max(120), + description: z.string().max(200), + lang: LANG, + // Links a vi post to its en translation (and vice-versa). + translationKey: z.string().optional(), + date: z.coerce.date(), + updated: z.coerce.date().optional(), + tags: z.array(z.string()).default([]), + cover: image().optional(), + draft: z.boolean().default(false), + }); + +// Markdown/MDX files, ignoring `_`-prefixed partials. +const contentGlob = (dir: string) => + glob({ pattern: "**/[^_]*.{md,mdx}", base: `./src/content/${dir}` }); + +const blog = defineCollection({ + loader: contentGlob("blog"), + // suggested tags: dev-log, diary, share, gaming + schema: (ctx) => base(ctx), +}); + +const stories = defineCollection({ + loader: contentGlob("stories"), + schema: (ctx) => + base(ctx).extend({ + series: z.string().optional(), + chapter: z.number().int().positive().optional(), + status: z.enum(["ongoing", "complete", "dropped"]).default("ongoing"), + contentWarning: z.array(z.string()).default([]), // e.g. ['horror', 'blood'] + }), +}); + +const projects = defineCollection({ + loader: contentGlob("projects"), + schema: ({ image }) => + z.object({ + name: z.string().max(120), + tagline: z.string().max(200), + lang: LANG, + translationKey: z.string().optional(), + stack: z.array(z.string()).default([]), + repo: z.url().optional(), + url: z.url().optional(), + status: z.enum(["active", "maintained", "archived"]).default("active"), + featured: z.boolean().default(false), + year: z.number(), + cover: image().optional(), + draft: z.boolean().default(false), + }), +}); + +const faq = defineCollection({ + loader: contentGlob("faq"), + schema: z.object({ + q: z.string(), + lang: LANG, + group: z.enum(["channel", "dev", "personal"]), + order: z.number().default(0), + }), +}); + +const gallery = defineCollection({ + loader: contentGlob("gallery"), + schema: z.object({ + title: z.string().max(120), + lang: LANG, + translationKey: z.string().optional(), + date: z.coerce.date(), + description: z.string().optional(), + album: z.string(), // = folder name under src/assets/gallery// + coverIndex: z.number().default(0), + }), +}); + +// Legal docs are bilingual within one file (EN + VI sections); both locale routes +// render the same document. See docs 12_LEGAL. +const legal = defineCollection({ + loader: contentGlob("legal"), + schema: z.object({ + title: z.string(), + order: z.number().default(0), + effectiveDate: z.string().optional(), + }), +}); + +export const collections = { blog, stories, projects, faq, gallery, legal }; diff --git a/src/content/blog/dem-render-dau-tien.md b/src/content/blog/dem-render-dau-tien.md new file mode 100644 index 0000000..4e74717 --- /dev/null +++ b/src/content/blog/dem-render-dau-tien.md @@ -0,0 +1,25 @@ +--- +title: "Đêm render đầu tiên của kênh" +description: "Ghi lại một đêm ngồi canh DaVinci Resolve xuất bản video đầu tiên của SkullMute." +lang: vi +translationKey: first-render-night +date: 2026-08-02 +tags: [diary, gaming] +--- + +Đêm đầu tiên ngồi canh render, cái quạt case kêu đều đều như một nhịp tim mượn tạm. Mình +không nghĩ một video ba phút lại ngốn nhiều thời gian đến vậy — nhưng đó là cái giá của việc +muốn mọi thứ **đúng ý**. + +## Vì sao lại là "im lặng" + +SkullMute không phải là không có âm thanh. Nó là âm thanh được **tắt có chủ đích** — chỉ giữ lại +thứ đáng giữ. Trang này cũng vậy: tối, ấm, và chỉ sáng ở đúng một chỗ. + +## Những gì học được + +- Xuất `AV1` mất gấp đôi thời gian nhưng nhẹ hơn hẳn. +- Ngủ sớm hơn, đừng canh thanh tiến trình. +- Một tách trà nóng đáng giá hơn mười lần F5. + +Hẹn gặp ở video sau. diff --git a/src/content/blog/first-render-night.md b/src/content/blog/first-render-night.md new file mode 100644 index 0000000..6d42a58 --- /dev/null +++ b/src/content/blog/first-render-night.md @@ -0,0 +1,25 @@ +--- +title: "The channel's first render night" +description: "Notes from a night spent watching DaVinci Resolve export SkullMute's first video." +lang: en +translationKey: first-render-night +date: 2026-08-02 +tags: [diary, gaming] +--- + +The first night watching a render, the case fan hummed steadily — a heartbeat on loan. I didn't +expect a three-minute video to eat this much time, but that's the price of wanting everything +**just right**. + +## Why "muted" + +SkullMute isn't the absence of sound. It's sound turned down **on purpose** — keeping only what's +worth keeping. This site is the same: dark, warm, and bright in exactly one place. + +## What I learned + +- Exporting `AV1` takes twice as long but is much lighter. +- Sleep earlier; don't babysit the progress bar. +- A hot cup of tea beats ten refreshes. + +See you in the next one. diff --git a/src/content/blog/lan-dau-viet-truyen.mdx b/src/content/blog/lan-dau-viet-truyen.mdx new file mode 100644 index 0000000..df2b384 --- /dev/null +++ b/src/content/blog/lan-dau-viet-truyen.mdx @@ -0,0 +1,21 @@ +--- +title: "Lần đầu viết truyện lúc 2 giờ sáng" +description: "Một ý tưởng đến sai giờ, và mình quyết định cứ để nó dẫn đường." +lang: vi +date: 2026-08-08 +tags: [diary, share] +--- + +import Callout from "@/components/Callout.astro"; + +Ý tưởng cho "Đêm không tiếng" đến lúc 2 giờ sáng — đúng cái giờ mà lẽ ra mình nên ngủ. Nhưng có +những đêm, sự im lặng của căn phòng lại ồn ào theo cách riêng của nó. + + + Đừng chờ ý tưởng "chín". Mở một file trống và gõ dòng đầu tiên — phần còn lại thường tự đến. + + +Mình mở một file markdown trống, gõ dòng đầu tiên, rồi để nó dẫn đường. Không outline, không kế +hoạch — chỉ có một căn nhà bỗng dưng tắt tiếng và một người ở lại. + +Viết trên trang này dễ chịu đúng như mình mong: tạo file, `git push`, xong. diff --git a/src/content/faq/channel-skullmute-la-gi.md b/src/content/faq/channel-skullmute-la-gi.md new file mode 100644 index 0000000..1ef5195 --- /dev/null +++ b/src/content/faq/channel-skullmute-la-gi.md @@ -0,0 +1,9 @@ +--- +q: "SkullMute là kênh gì?" +lang: vi +group: channel +order: 1 +--- + +Kênh của mình xoay quanh game — chủ yếu là visual novel, JRPG, và indie/psychological horror. +Không FPS, không competitive. Nếu bạn thích những trò chơi kể chuyện chậm rãi, đây là chỗ của bạn. diff --git a/src/content/faq/dev-cong-cu.md b/src/content/faq/dev-cong-cu.md new file mode 100644 index 0000000..12924de --- /dev/null +++ b/src/content/faq/dev-cong-cu.md @@ -0,0 +1,9 @@ +--- +q: "Bạn dùng công cụ gì để code?" +lang: vi +group: dev +order: 1 +--- + +Chủ yếu là VS Code, một terminal gọn nhẹ, và Obsidian trỏ thẳng vào thư mục nội dung của site. +Stack ưa thích: Astro, Svelte, Tailwind, TypeScript — ít phụ thuộc, dễ bảo trì. diff --git a/src/content/faq/personal-ten.md b/src/content/faq/personal-ten.md new file mode 100644 index 0000000..ccaa9f4 --- /dev/null +++ b/src/content/faq/personal-ten.md @@ -0,0 +1,9 @@ +--- +q: "Kokone và SkullMute — tên nào là chính?" +lang: vi +group: personal +order: 1 +--- + +Kokone là mình khi viết code và viết truyện; SkullMute là kênh. Hai tên, một người. Trang này +là chỗ cả hai gặp nhau. diff --git a/src/content/legal/disclaimer.md b/src/content/legal/disclaimer.md new file mode 100644 index 0000000..9039668 --- /dev/null +++ b/src/content/legal/disclaimer.md @@ -0,0 +1,37 @@ +--- +title: "Miễn trừ / Disclaimer" +order: 3 +effectiveDate: "2026-07-19" +--- + +## English + +**1. No affiliation.** This is an independent personal website. It is not affiliated with, endorsed by, or sponsored by any company, brand, game publisher, or software developer mentioned anywhere on the Site. + +**2. Third-party software and projects.** Any software, tools, games, or projects listed or referenced here belong to their respective developers and owners. Listings exist solely to gather information in one place for convenience. Names and logos are used only for identification (nominative use). All trademarks are the property of their respective holders. + +**3. Gaming content.** Game titles, screenshots, and video thumbnails shown on the Site or on the SkullMute channel belong to their respective publishers and are used to identify and discuss the works. + +**4. Opinions.** Everything on this Site reflects my personal views only, not those of any employer, partner, or community I take part in. + +**5. No professional advice.** Technical write-ups and guides are shared as-is from personal experience. Use them at your own risk; nothing here is professional, legal, or financial advice. + +**6. Fiction.** Stories published on this Site are works of fiction. Names, characters, and events are products of imagination; any resemblance to real persons or events is coincidental. Some stories carry content warnings — please heed them. + +**7. External links.** Linked sites and services are outside my control; I am not responsible for their content, availability, or policies. + +## Tiếng Việt + +**1. Không liên kết.** Đây là website cá nhân độc lập, không liên kết, không được bảo trợ hay tài trợ bởi bất kỳ công ty, thương hiệu, nhà phát hành game hay nhà phát triển phần mềm nào được nhắc đến trên Trang web. + +**2. Phần mềm & dự án bên thứ ba.** Mọi phần mềm, công cụ, game hay dự án được liệt kê hoặc nhắc đến tại đây đều thuộc về nhà phát triển và chủ sở hữu tương ứng. Việc liệt kê chỉ nhằm tập hợp thông tin về một chỗ cho tiện tra cứu. Tên và logo chỉ được dùng để nhận diện (nominative use). Mọi nhãn hiệu thuộc về chủ sở hữu tương ứng. + +**3. Nội dung game.** Tên game, ảnh chụp màn hình và thumbnail video xuất hiện trên Trang web hoặc kênh SkullMute thuộc về nhà phát hành tương ứng, được dùng để nhận diện và bàn luận về tác phẩm. + +**4. Quan điểm.** Mọi nội dung trên Trang web chỉ phản ánh quan điểm cá nhân của mình, không đại diện cho bất kỳ tổ chức, đối tác hay cộng đồng nào mình tham gia. + +**5. Không phải tư vấn chuyên môn.** Bài viết kỹ thuật và hướng dẫn được chia sẻ nguyên trạng từ trải nghiệm cá nhân. Bạn tự chịu trách nhiệm khi áp dụng; không nội dung nào là tư vấn chuyên môn, pháp lý hay tài chính. + +**6. Truyện hư cấu.** Truyện đăng trên Trang web là tác phẩm hư cấu. Tên nhân vật, sự kiện là sản phẩm của trí tưởng tượng; mọi sự trùng hợp với người thật, việc thật đều là ngẫu nhiên. Một số truyện có cảnh báo nội dung — vui lòng lưu ý trước khi đọc. + +**7. Liên kết ngoài.** Các trang và dịch vụ được dẫn link nằm ngoài tầm kiểm soát của mình; mình không chịu trách nhiệm về nội dung, tính khả dụng hay chính sách của họ. diff --git a/src/content/legal/licenses.md b/src/content/legal/licenses.md new file mode 100644 index 0000000..c952906 --- /dev/null +++ b/src/content/legal/licenses.md @@ -0,0 +1,20 @@ +--- +title: "Giấy phép / Licenses" +order: 5 +--- + +## English + +**Code.** The source code of this website is free software, licensed under the GNU General Public License v3.0. When the repository is public you can obtain it there; until then, code snippets published in blog posts are shared under the license stated in each post. + +**Content.** All written content, stories, photographs, and other original media on this Site are **© Kokone (SkullMute), all rights reserved**. You may not reproduce, republish, or redistribute them, and you may not use them to train machine-learning systems, without prior written permission. Short quotations with attribution and a link are permitted (see Terms §4). Individual pages may state a different license for that page's content, which then prevails. + +**Permissions & takedown.** Requests: contact@poli0981.dev. + +## Tiếng Việt + +**Mã nguồn.** Mã nguồn của website là phần mềm tự do, cấp phép theo GNU General Public License v3.0. Khi repo được mở public, bạn có thể lấy mã tại đó; trước lúc đó, các đoạn code đăng trong bài blog được chia sẻ theo giấy phép ghi trong từng bài. + +**Nội dung.** Toàn bộ bài viết, truyện, ảnh và media gốc trên Trang web thuộc **bản quyền © Kokone (SkullMute), bảo lưu mọi quyền**. Không sao chép, đăng lại, phân phối lại, và không dùng để huấn luyện hệ thống máy học khi chưa có sự cho phép bằng văn bản. Được phép trích ngắn có ghi nguồn kèm link (xem Điều khoản §4). Trang cụ thể có thể ghi giấy phép khác cho nội dung của trang đó — khi ấy giấy phép ghi tại trang được ưu tiên. + +**Xin phép & yêu cầu gỡ:** contact@poli0981.dev. diff --git a/src/content/legal/privacy.md b/src/content/legal/privacy.md new file mode 100644 index 0000000..b663994 --- /dev/null +++ b/src/content/legal/privacy.md @@ -0,0 +1,53 @@ +--- +title: "Bảo mật / Privacy Policy" +order: 2 +effectiveDate: "2026-07-19" +--- + +## English + +This is a personal website designed to collect as little data as possible. + +**1. What I do NOT do.** No advertising, no ad trackers, no cross-site tracking, no sale of data, no user accounts, no analytics cookies. + +**2. Analytics.** The Site uses Cloudflare Web Analytics, a cookie-free, privacy-focused service that reports aggregate statistics (page views, country, browser type). It does not build visitor profiles. + +**3. Hosting & security logs.** The Site runs on Cloudflare. Like virtually all websites, requests pass through infrastructure that processes IP addresses and request metadata for security (DDoS mitigation, abuse prevention, rate limiting). I use IP addresses only transiently for rate limiting and blocking abuse; they are not stored in my own records. + +**4. Bug reports (the only form on the Site).** If you choose to send a bug report, the following is transmitted and stored as a private GitHub issue and a Discord notification: your description, the page route, browser user-agent, viewport size, theme/language setting, and — only if you leave the checkbox enabled — the last console error messages shown to you in a preview before sending. No IP address is stored with the report. Contact me to request deletion of a report you sent. + +**5. Embedded videos.** YouTube videos load only after you click them, via YouTube's privacy-enhanced domain (youtube-nocookie.com). Before you click, only a static thumbnail is loaded. Once you click, YouTube's own privacy policy applies. + +**6. Local storage.** The Site stores small preferences in your browser only: theme, reading settings, language hint, legal-notice acknowledgement, and (if you play the offline mini-game) a best score. These never leave your device. + +**7. Email.** If you email contact@poli0981.dev, your message is forwarded via Cloudflare Email Routing to my mailbox and kept as normal correspondence. + +**8. Your choices & rights.** You can browse with JavaScript disabled (core content still works), clear local storage at any time, and request deletion of bug reports or emails you sent. Requests: contact@poli0981.dev. + +**9. Children.** The Site is not directed at children under 13 and collects no data targeting them. + +**10. Changes.** Updates will be posted here with a new effective date. + +## Tiếng Việt + +Đây là website cá nhân, được thiết kế để thu thập càng ít dữ liệu càng tốt. + +**1. Những thứ mình KHÔNG làm.** Không quảng cáo, không tracker quảng cáo, không theo dõi chéo trang, không bán dữ liệu, không tài khoản người dùng, không cookie analytics. + +**2. Thống kê truy cập.** Trang web dùng Cloudflare Web Analytics — dịch vụ không cookie, tôn trọng quyền riêng tư, chỉ báo số liệu tổng hợp (lượt xem, quốc gia, loại trình duyệt), không dựng hồ sơ người xem. + +**3. Hạ tầng & log bảo mật.** Trang web chạy trên Cloudflare. Như hầu hết website, request đi qua hạ tầng có xử lý địa chỉ IP và metadata cho mục đích bảo mật (chống DDoS, chống lạm dụng, rate limiting). Mình chỉ dùng IP thoáng qua để giới hạn tần suất và chặn phá hoại; IP không được lưu trong hồ sơ riêng của mình. + +**4. Báo lỗi (biểu mẫu duy nhất trên trang).** Nếu bạn chủ động gửi báo lỗi, những thứ sau được truyền và lưu dưới dạng GitHub issue riêng tư + thông báo Discord: mô tả của bạn, đường dẫn trang, user-agent trình duyệt, kích thước màn hình, cài đặt theme/ngôn ngữ, và — chỉ khi bạn để nguyên ô tick — các lỗi console gần nhất (có bản xem trước trước khi gửi). Địa chỉ IP không được lưu kèm báo cáo. Muốn xoá báo cáo đã gửi: liên hệ mình. + +**5. Video nhúng.** Video YouTube chỉ tải sau khi bạn bấm, qua tên miền tăng cường riêng tư (youtube-nocookie.com). Trước khi bấm, chỉ có ảnh thumbnail tĩnh. Sau khi bấm, chính sách của YouTube áp dụng. + +**6. Lưu trữ cục bộ.** Trang web lưu vài tuỳ chọn nhỏ ngay trong trình duyệt của bạn: theme, cài đặt đọc, gợi ý ngôn ngữ, ghi nhận đã xem thông báo pháp lý, và (nếu bạn chơi mini-game offline) điểm cao nhất. Chúng không bao giờ rời thiết bị của bạn. + +**7. Email.** Mail gửi tới contact@poli0981.dev được chuyển tiếp qua Cloudflare Email Routing về hộp thư của mình và lưu như thư từ thông thường. + +**8. Lựa chọn & quyền của bạn.** Bạn có thể duyệt web khi tắt JavaScript (nội dung chính vẫn hoạt động), xoá local storage bất cứ lúc nào, và yêu cầu xoá báo lỗi/email đã gửi. Liên hệ: contact@poli0981.dev. + +**9. Trẻ em.** Trang web không hướng tới trẻ dưới 13 tuổi và không thu thập dữ liệu nhắm vào trẻ em. + +**10. Thay đổi.** Bản cập nhật sẽ đăng tại đây kèm ngày hiệu lực mới. diff --git a/src/content/legal/terms.md b/src/content/legal/terms.md new file mode 100644 index 0000000..a5d99a6 --- /dev/null +++ b/src/content/legal/terms.md @@ -0,0 +1,53 @@ +--- +title: "Điều khoản / Terms of Use" +order: 1 +effectiveDate: "2026-07-19" +--- + +## English + +Welcome to `poli0981.dev` (the "Site"), operated by Kokone ("I", "me"). By accessing the Site you agree to these Terms. If you do not agree, please stop using the Site. + +**1. What this Site is.** A personal website: portfolio, blog/diary, original fiction, photo gallery, and information about the SkullMute channel. Content is provided for personal, non-commercial viewing. + +**2. Intellectual property.** Written content, stories, photos, and other original media are © Kokone, all rights reserved, unless a page states otherwise. The Site's source code is licensed separately under GPL-3.0 (see /legal/licenses). Third-party names, software, logos, and game content referenced on the Site belong to their respective owners (see /legal/disclaimer). + +**3. Acceptable use.** You may not: scrape or bulk-download content; republish stories, photos, or articles without written permission; use Site content to train machine-learning models; attempt to disrupt, probe, or overload the Site; or submit unlawful or abusive material through any form. + +**4. Quoting.** Short quotations (up to ~100 words) with a link back to the source page are welcome. Full reposts are not. + +**5. User submissions.** Bug reports you send may be stored (see Privacy Policy) and used to improve the Site. Do not include personal data of others. + +**6. Third-party links.** The Site links to external services (YouTube, Discord, GitHub, etc.). I am not responsible for their content or practices. + +**7. No warranty; limitation of liability.** The Site is provided "as is", without warranties of any kind. To the maximum extent permitted by law, I am not liable for any damages arising from use of the Site. + +**8. Changes.** These Terms may change; the effective date above will be updated. Continued use means acceptance. + +**9. Governing law.** These Terms are governed by the laws of Vietnam. + +**Contact:** contact@poli0981.dev + +## Tiếng Việt + +Chào mừng đến `poli0981.dev` ("Trang web"), do Kokone ("mình") vận hành. Việc truy cập Trang web đồng nghĩa bạn đồng ý với Điều khoản này; nếu không đồng ý, vui lòng ngừng sử dụng. + +**1. Trang web là gì.** Website cá nhân: portfolio, blog/nhật ký, truyện sáng tác, ảnh kỷ niệm và thông tin về kênh SkullMute. Nội dung phục vụ mục đích xem cá nhân, phi thương mại. + +**2. Sở hữu trí tuệ.** Bài viết, truyện, ảnh và media gốc khác thuộc bản quyền © Kokone, bảo lưu mọi quyền, trừ khi trang cụ thể ghi khác. Mã nguồn của Trang web được cấp phép riêng theo GPL-3.0 (xem /legal/licenses). Tên, phần mềm, logo và nội dung game của bên thứ ba được nhắc đến trên Trang web thuộc về chủ sở hữu tương ứng (xem /legal/disclaimer). + +**3. Sử dụng hợp lệ.** Bạn không được: cào (scrape) hoặc tải hàng loạt nội dung; đăng lại truyện, ảnh, bài viết khi chưa có sự cho phép bằng văn bản; dùng nội dung Trang web để huấn luyện mô hình máy học; cố ý phá hoại, dò quét hoặc làm quá tải Trang web; gửi nội dung vi phạm pháp luật hoặc lăng mạ qua bất kỳ biểu mẫu nào. + +**4. Trích dẫn.** Trích ngắn (tối đa ~100 từ) kèm link về trang gốc: hoan nghênh. Đăng lại toàn bộ: không. + +**5. Nội dung bạn gửi.** Báo lỗi bạn gửi có thể được lưu (xem Chính sách quyền riêng tư) và dùng để cải thiện Trang web. Không đưa dữ liệu cá nhân của người khác vào. + +**6. Liên kết bên thứ ba.** Trang web dẫn tới dịch vụ bên ngoài (YouTube, Discord, GitHub…). Mình không chịu trách nhiệm về nội dung hay hoạt động của họ. + +**7. Miễn trừ bảo đảm; giới hạn trách nhiệm.** Trang web được cung cấp "nguyên trạng", không kèm bất kỳ bảo đảm nào. Trong phạm vi pháp luật cho phép, mình không chịu trách nhiệm cho thiệt hại phát sinh từ việc sử dụng Trang web. + +**8. Thay đổi.** Điều khoản có thể được cập nhật; ngày hiệu lực ở trên sẽ thay đổi tương ứng. Tiếp tục sử dụng nghĩa là chấp nhận. + +**9. Luật áp dụng.** Điều khoản này chịu sự điều chỉnh của pháp luật Việt Nam. + +**Liên hệ:** contact@poli0981.dev diff --git a/src/content/legal/third-party.md b/src/content/legal/third-party.md new file mode 100644 index 0000000..50d18df --- /dev/null +++ b/src/content/legal/third-party.md @@ -0,0 +1,28 @@ +--- +title: "Bên thứ ba / Third-Party Notices" +order: 4 +--- + +## English + +This site is built with open-source software. Each component below remains under its own license; full license texts ship with each package and in the repository's `THIRD-PARTY-NOTICES.md`. + +## Tiếng Việt + +Trang web này được xây dựng bằng phần mềm mã nguồn mở. Mỗi thành phần dưới đây giữ nguyên giấy phép gốc của nó; toàn văn giấy phép đi kèm từng package và trong file `THIRD-PARTY-NOTICES.md` của repo. + +## Components + +| Component | License | +| ------------------------------------------------------------- | ---------------- | +| Astro + @astrojs/\* | MIT | +| Svelte | MIT | +| Tailwind CSS | MIT | +| Pagefind | MIT | +| @vite-pwa/astro / Workbox | MIT | +| Zod | MIT | +| sharp | Apache-2.0 | +| Wrangler | MIT / Apache-2.0 | +| Bricolage Grotesque, Be Vietnam Pro, Literata, JetBrains Mono | SIL OFL 1.1 | + +**Infrastructure services** (not packages, listed for transparency): Cloudflare (hosting / CDN / analytics / Turnstile), GitHub (source, issues), YouTube / Steam / GitHub public-data APIs (widgets). diff --git a/src/content/projects/poli0981-dev.md b/src/content/projects/poli0981-dev.md new file mode 100644 index 0000000..a07de90 --- /dev/null +++ b/src/content/projects/poli0981-dev.md @@ -0,0 +1,16 @@ +--- +name: "poli0981.dev" +tagline: "Trang cá nhân — Astro + Cloudflare, tối giản, bền và gần như miễn phí." +lang: vi +stack: [Astro, Svelte, Tailwind, "Cloudflare Workers", TypeScript] +repo: https://github.com/poli0981/poli0981.dev +url: https://poli0981.dev +status: active +featured: true +year: 2026 +--- + +Website bạn đang đọc. Dựng bằng Astro với vài island Svelte, chạy trên Cloudflare Workers + +Static Assets. Nội dung viết bằng Markdown thuần, xuất bản qua `git push`. + +Mục tiêu: đẹp có chủ đích (không giống template), mobile-first, và chi phí mới gần như bằng không. diff --git a/src/content/projects/skullmute-overlay.md b/src/content/projects/skullmute-overlay.md new file mode 100644 index 0000000..643d507 --- /dev/null +++ b/src/content/projects/skullmute-overlay.md @@ -0,0 +1,14 @@ +--- +name: "SkullMute Overlay" +tagline: "Bộ overlay stream tối giản — không animation ồn ào, chỉ thông tin cần thiết." +lang: vi +stack: [Svelte, TypeScript, OBS, WebSocket] +status: maintained +featured: false +year: 2025 +--- + +Bộ overlay dùng cho stream của SkullMute: hiển thị "now playing", chapter truyện đang đọc, và một +waveline nhỏ phản ứng theo âm thanh mic — đúng tinh thần "âm thanh bị tắt có chủ đích". + +Dựng bằng Svelte, giao tiếp với OBS qua WebSocket. Nhẹ, không animation gây mất tập trung. diff --git a/src/content/stories/dem-khong-tieng/chuong-01.md b/src/content/stories/dem-khong-tieng/chuong-01.md new file mode 100644 index 0000000..34c85c0 --- /dev/null +++ b/src/content/stories/dem-khong-tieng/chuong-01.md @@ -0,0 +1,21 @@ +--- +title: "Đêm không tiếng — Chương 1" +description: "Một căn nhà không còn phát ra âm thanh, và người ở lại bắt đầu nghe thấy chính mình." +lang: vi +date: 2026-08-10 +series: "Đêm không tiếng" +chapter: 1 +status: ongoing +contentWarning: [horror] +tags: [horror, short-story] +--- + +Căn nhà tắt tiếng vào lúc 3 giờ 12 phút sáng. + +Không phải mất điện — đèn vẫn sáng, tủ lạnh vẫn thở. Chỉ là mọi âm thanh bỗng rút đi, như ai đó +kéo cái cần gạt vô hình xuống mức tận cùng. Tôi nghe thấy tiếng máu chạy trong tai mình, rõ đến +mức khó chịu. + +Tôi gọi tên em. Miệng mở ra, cổ họng rung lên — nhưng không có gì thoát ra cả. + +Chỉ có sự im lặng, dày và ấm, đang lắng nghe. diff --git a/src/content/stories/dem-khong-tieng/chuong-02.md b/src/content/stories/dem-khong-tieng/chuong-02.md new file mode 100644 index 0000000..0c11c7d --- /dev/null +++ b/src/content/stories/dem-khong-tieng/chuong-02.md @@ -0,0 +1,21 @@ +--- +title: "Đêm không tiếng — Chương 2" +description: "Khi âm thanh trở lại, nó mang theo một thứ không nên nghe thấy." +lang: vi +date: 2026-08-17 +series: "Đêm không tiếng" +chapter: 2 +status: ongoing +contentWarning: [horror] +tags: [horror, short-story] +--- + +Âm thanh trở lại vào lúc 4 giờ 03 phút — chậm rãi, từng lớp một, như ai đó đang vặn lại cái cần +gạt vô hình. + +Đầu tiên là tiếng tủ lạnh. Rồi tiếng quạt. Rồi một tiếng thở — không phải của tôi. + +Nó đến từ căn phòng em, nơi đã trống suốt ba tháng. + +Tôi đứng ở hành lang, tay đặt lên nắm cửa lạnh ngắt, và lần đầu tiên trong đêm ấy, tôi ước gì căn +nhà cứ tắt tiếng mãi. diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..584ef03 --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// Cloudflare bindings (KV, ASSETS, SESSION) are typed in worker-configuration.d.ts +// (generated by `wrangler types`) and accessed via `import { env } from "cloudflare:workers"`. diff --git a/src/i18n/en.ts b/src/i18n/en.ts new file mode 100644 index 0000000..5144781 --- /dev/null +++ b/src/i18n/en.ts @@ -0,0 +1,103 @@ +import type { UIStrings } from "./vi"; + +/** English UI strings — hand-written (not machine-translated), same shape as vi.ts. */ +const en: UIStrings = { + site: { + tagline: "dev & storyteller", + }, + nav: { + home: "Home", + blog: "Blog", + stories: "Stories", + projects: "Projects", + gallery: "Gallery", + gaming: "Gaming", + dev: "Dev", + about: "About", + qa: "Q&A", + links: "Links", + menu: "Menu", + close: "Close", + openMenu: "Open menu", + }, + theme: { + toggle: "Toggle light/dark theme", + dark: "Dark", + light: "Light", + }, + lang: { + switchTo: "Tiếng Việt", + label: "Language", + }, + actions: { + readMore: "Read more", + viewSeries: "View series", + reportBug: "Report a bug", + gotIt: "Got it", + skipToContent: "Skip to content", + }, + footer: { + reportBug: "Report a bug", + legal: "Legal", + rights: "All rights reserved.", + }, + post: { + minRead: "min read", + prev: "Prev", + next: "Next", + onlyVi: "Only available in Vietnamese.", + readOther: "Read translation", + updated: "Updated", + }, + story: { + seriesToc: "Contents", + statusOngoing: "Ongoing", + statusComplete: "Complete", + statusDropped: "Dropped", + cwTitle: "Content warning", + cwHint: "Tap to read", + }, + reader: { + aria: "Reading settings", + sizeTitle: "Text size", + themeTitle: "Background", + sizeS: "A-", + sizeM: "A", + sizeL: "A+", + paper: "Paper", + sepia: "Sepia", + dark: "Dark", + }, + home: { + recent: "Recently written", + shortcuts: "Shortcuts", + }, + qaGroups: { + channel: "Channel", + dev: "Dev", + personal: "Personal", + }, + contact: { + title: "Contact", + lead: "The fastest ways to reach me:", + fast: "Fastest — Discord", + business: "Business — contact@poli0981.dev", + all: "Everything — /links", + }, + gate: { + line1: "Content © Kokone (SkullMute), all rights reserved.", + line2: "Software/brands mentioned belong to their owners; this site is unaffiliated.", + line3: "This site uses cookieless analytics.", + ack: "Got it", + more: "Details", + }, + legal: { + terms: "Terms", + privacy: "Privacy", + disclaimer: "Disclaimer", + thirdParty: "Third-party", + licenses: "Licenses", + }, +}; + +export default en; diff --git a/src/i18n/index.ts b/src/i18n/index.ts new file mode 100644 index 0000000..616c135 --- /dev/null +++ b/src/i18n/index.ts @@ -0,0 +1,15 @@ +import vi from "./vi"; +import en from "./en"; +import { DEFAULT_LOCALE, LOCALES, type Locale } from "./routing"; + +const DICTS = { vi, en } as const; + +/** UI strings for a locale (falls back to the default locale's dictionary). */ +export function useTranslations(locale: Locale) { + return DICTS[locale] ?? DICTS[DEFAULT_LOCALE]; +} + +/** Narrow an arbitrary value (e.g. Astro.currentLocale) to a supported Locale. */ +export function toLocale(value: string | undefined): Locale { + return (LOCALES as readonly string[]).includes(value ?? "") ? (value as Locale) : DEFAULT_LOCALE; +} diff --git a/src/i18n/routing.ts b/src/i18n/routing.ts new file mode 100644 index 0000000..bd2b319 --- /dev/null +++ b/src/i18n/routing.ts @@ -0,0 +1,81 @@ +/** + * The i18n routing seam. `vi` is the default locale and carries NO url prefix; + * `en` lives under `/en/`. Path segments can differ per locale (e.g. truyen ↔ stories). + * + * Adding a new locale later (e.g. `ja`) = add its column to SEGMENTS + create the + * matching `src/pages/ja/*` tree. Nothing else needs to change: LangSwitch, hreflang, + * and every nav link resolve through the helpers below. + */ + +export const LOCALES = ["vi", "en"] as const; +export type Locale = (typeof LOCALES)[number]; +export const DEFAULT_LOCALE: Locale = "vi"; + +/** Logical sections → the url segment used for each locale. (The i18n seam: add a + * locale column here + a matching src/pages//* tree to support a new language.) */ +const SEGMENTS = { + blog: { vi: "blog", en: "blog" }, + stories: { vi: "truyen", en: "stories" }, + projects: { vi: "projects", en: "projects" }, + gallery: { vi: "gallery", en: "gallery" }, + gaming: { vi: "gaming", en: "gaming" }, + dev: { vi: "dev", en: "dev" }, + about: { vi: "about", en: "about" }, + qa: { vi: "qa", en: "qa" }, + links: { vi: "links", en: "links" }, + legal: { vi: "legal", en: "legal" }, +} as const; + +export type Section = keyof typeof SEGMENTS; + +/** Url prefix for a locale ("" for the default, "/en" otherwise). */ +function localePrefix(locale: Locale): string { + return locale === DEFAULT_LOCALE ? "" : `/${locale}`; +} + +/** Home path for a locale ("/" or "/en/"). */ +export function homePath(locale: Locale): string { + return locale === DEFAULT_LOCALE ? "/" : `/${locale}/`; +} + +/** Build a localized path for a section, plus optional trailing slug segments. */ +export function sectionPath(section: Section, locale: Locale, ...rest: string[]): string { + const seg = SEGMENTS[section][locale]; + const tail = rest.length ? `/${rest.join("/")}` : ""; + return `${localePrefix(locale)}/${seg}${tail}`; +} + +/** Which locale a pathname belongs to (only `/en/...` is prefixed). */ +export function localeFromPath(pathname: string): Locale { + const first = pathname.split("/").filter(Boolean)[0]; + return first === "en" ? "en" : "vi"; +} + +/** Reverse-lookup: a url segment → its section key, for a given locale. */ +function sectionFromSegment(segment: string, locale: Locale): Section | null { + for (const key of Object.keys(SEGMENTS) as Section[]) { + if (SEGMENTS[key][locale] === segment) return key; + } + return null; +} + +/** + * The counterpart of `pathname` in the target locale — handles the /en/ prefix and + * the per-locale segment swap (truyen ↔ stories). For content pages whose slugs differ + * across languages, pass the translationKey-resolved href explicitly instead. + */ +export function alternatePath(pathname: string, target: Locale): string { + const current = localeFromPath(pathname); + if (current === target) return pathname; + + let parts = pathname.split("/").filter(Boolean); + if (current !== DEFAULT_LOCALE) parts = parts.slice(1); // drop the locale prefix + + if (parts.length === 0) return homePath(target); + + const section = sectionFromSegment(parts[0], current); + if (section) parts[0] = SEGMENTS[section][target]; + + const prefix = localePrefix(target); + return `${prefix}/${parts.join("/")}`; +} diff --git a/src/i18n/vi.ts b/src/i18n/vi.ts new file mode 100644 index 0000000..81443c4 --- /dev/null +++ b/src/i18n/vi.ts @@ -0,0 +1,102 @@ +/** Vietnamese UI strings (default locale). en.ts must mirror this shape. */ +const vi = { + site: { + tagline: "dev & storyteller", + }, + nav: { + home: "Trang chủ", + blog: "Blog", + stories: "Truyện", + projects: "Dự án", + gallery: "Ảnh", + gaming: "Gaming", + dev: "Dev", + about: "Giới thiệu", + qa: "Hỏi đáp", + links: "Liên kết", + menu: "Menu", + close: "Đóng", + openMenu: "Mở menu", + }, + theme: { + toggle: "Đổi giao diện sáng/tối", + dark: "Tối", + light: "Sáng", + }, + lang: { + switchTo: "English", + label: "Ngôn ngữ", + }, + actions: { + readMore: "Đọc tiếp", + viewSeries: "Xem series", + reportBug: "Báo lỗi", + gotIt: "Đã hiểu", + skipToContent: "Bỏ qua đến nội dung", + }, + footer: { + reportBug: "Báo lỗi", + legal: "Pháp lý", + rights: "Bảo lưu mọi quyền.", + }, + post: { + minRead: "phút đọc", + prev: "Trước", + next: "Sau", + onlyVi: "Chỉ có bản tiếng Việt.", + readOther: "Đọc bản dịch", + updated: "Cập nhật", + }, + story: { + seriesToc: "Mục lục", + statusOngoing: "Đang ra", + statusComplete: "Hoàn thành", + statusDropped: "Tạm dừng", + cwTitle: "Cảnh báo nội dung", + cwHint: "Bấm để đọc", + }, + reader: { + aria: "Tùy chỉnh đọc", + sizeTitle: "Cỡ chữ", + themeTitle: "Nền", + sizeS: "A-", + sizeM: "A", + sizeL: "A+", + paper: "Giấy", + sepia: "Sepia", + dark: "Tối", + }, + home: { + recent: "Mới viết", + shortcuts: "Lối tắt", + }, + qaGroups: { + channel: "Kênh", + dev: "Lập trình", + personal: "Cá nhân", + }, + contact: { + title: "Liên hệ", + lead: "Cách nhanh nhất để nhắn mình:", + fast: "Nhanh nhất — Discord", + business: "Công việc — contact@poli0981.dev", + all: "Tất cả kênh — /links", + }, + gate: { + line1: "Nội dung © Kokone (SkullMute), bảo lưu mọi quyền.", + line2: "Phần mềm/thương hiệu được nhắc đến thuộc chủ sở hữu tương ứng; trang không liên kết.", + line3: "Trang dùng phân tích không cookie.", + ack: "Đã hiểu", + more: "Chi tiết", + }, + legal: { + terms: "Điều khoản", + privacy: "Bảo mật", + disclaimer: "Miễn trừ", + thirdParty: "Bên thứ ba", + licenses: "Giấy phép", + }, +}; + +export default vi; +export type UIStrings = typeof vi; diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro new file mode 100644 index 0000000..088919e --- /dev/null +++ b/src/layouts/BaseLayout.astro @@ -0,0 +1,123 @@ +--- +import "../styles/global.css"; +import { Font } from "astro:assets"; +import { ClientRouter } from "astro:transitions"; +import SkipLink from "../components/SkipLink.astro"; +import Header from "../components/Header.astro"; +import Footer from "../components/Footer.astro"; +import MobileTabBar from "../components/MobileTabBar.astro"; +import MenuSheet from "../components/MenuSheet.svelte"; +import LegalGateSheet from "../components/LegalGateSheet.svelte"; +import { resolveSeo, SITE, type SeoInput } from "../lib/seo"; +import { toLocale, useTranslations } from "../i18n"; +import { menuNav, legalNav } from "../lib/nav"; + +interface Props extends SeoInput { + /** Extra classes for the
wrapper. */ + mainClass?: string; + /** Reading pages (blog post, story chapter) load the Literata reading font. */ + reading?: boolean; +} + +const { mainClass, reading = false, ...seoInput } = Astro.props; +// Default the locale from the URL (Astro.currentLocale) so /en/* pages resolve to `en`. +const locale = seoInput.locale ?? toLocale(Astro.currentLocale); +const seo = resolveSeo({ ...seoInput, locale }, Astro.url.pathname); +const lang = seo.locale; +const t = useTranslations(lang); +const ogImage = seo.image ? new URL(seo.image, SITE.url).href : undefined; +const menuItems = menuNav(lang); +const legalItems = legalNav(lang); +// The legal-notice gate is a reminder layer — never shown on the legal pages themselves. +const onLegalPage = /\/legal(\/|$)/.test(Astro.url.pathname); +--- + + + + + + + + {/* Apply stored theme before first paint, and re-apply after View Transitions swaps. */} + + + {seo.title} + + + {seo.noindex && } + + + + + {/* Open Graph / Twitter */} + + + + + + + {ogImage && } + + + + + { + /* Self-hosted fonts. Preload only the display family (hero + headings, the most + prominent first-paint text). Body/mono swap in with size-adjusted fallbacks + (optimizedFallbacks → CLS-safe), keeping the preload set within the perf budget. */ + } + + + + {/* Literata loads only on long-form reading pages (keeps the base bundle lean). */} + {reading && } + + + + + + +
+
+ +
+