feat: Foundation → P1 — bilingual Astro + Cloudflare site (local-first)
Implements the Foundation → P1 scope: a bilingual (vi default, en under /en/) personal site for Kokone / SkullMute, fully runnable locally. Scaffold & tooling - Astro 7 + @astrojs/cloudflare v14 + Svelte 5 islands + Tailwind v4 (@theme) + self-hosted Fonts API + built-in CSP (Prism highlighting). - eslint (flat) + prettier (+astro/svelte/tailwind) + lefthook + knip; strict TypeScript. Design system & chrome - Runtime-var theming (dark "midnight ink" / light "old paper") via [data-theme]; 4 VN-subset fonts, exactly 2 first-paint preloads. - Waveline signature (requestAnimationFrame — no GSAP), grain overlay. - i18n seam (src/i18n/routing.ts), Header/Footer/MobileTabBar, ThemeToggle, LangSwitch, accessible MenuSheet. Content & pages - Content Collections (Zod): blog, stories, projects, faq, gallery, legal. - Blog (index/post/tag), Stories + reader (content-warning gate, ReadingControls: size + independent reader theme + progress), Home, About, Projects, Q&A, Links, 5 bilingual Legal pages — all with /en/ twins + translationKey pairing. Platform - LegalGateSheet first-visit notice; error pages 404/500/403/429/offline; middleware: security headers, www->apex, denylist->403 & /api rate-limit ->429 served from prerendered assets via the ASSETS binding. Verified locally: build/check/lint/format/knip all pass; 39 pages; CSP console-clean; error matrix under `astro preview`. Perf: HTML ~9KB gz, island JS 25KB gz, 2 font preloads (48KB). Deferred to a later plan: live deploy + domain + secrets, widgets worker (YouTube/Steam/GitHub + KV cron), gallery + exif scripts, Pagefind search, RSS/sitemap/OG images, bug-report pipeline, offline service worker, CI/CD reusable workflows. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbd5e31b82
commit
f802bc4203
102 files changed
+17797
No files matched your search
@@ -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
|
||||
+28
@@ -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
|
||||
@@ -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
|
||||
@@ -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/
|
||||
@@ -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-<Font> 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 <script>/<style> it emits; we add fetch
|
||||
// directives here. NOTE: this is delivered as a <meta http-equiv> tag, so
|
||||
// `frame-ancestors` is ignored by browsers in meta form — framing protection is
|
||||
// enforced with an X-Frame-Options header in middleware instead (see docs 06).
|
||||
security: {
|
||||
csp: {
|
||||
algorithm: "SHA-256",
|
||||
directives: [
|
||||
"default-src 'self'",
|
||||
"img-src 'self' data: https://i.ytimg.com",
|
||||
"frame-src https://www.youtube-nocookie.com",
|
||||
"connect-src 'self'",
|
||||
"font-src 'self'",
|
||||
"base-uri 'none'",
|
||||
"form-action 'self'",
|
||||
"object-src 'none'",
|
||||
],
|
||||
// 'self' keeps dynamically-imported island chunks (e.g. GSAP) loadable;
|
||||
// 'wasm-unsafe-eval' is pre-baked for Pagefind's WebAssembly (added later).
|
||||
scriptDirective: { resources: ["'self'", "'wasm-unsafe-eval'"] },
|
||||
styleDirective: { resources: ["'self'"] },
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
import tseslint from "typescript-eslint";
|
||||
import astro from "eslint-plugin-astro";
|
||||
import svelte from "eslint-plugin-svelte";
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: [
|
||||
"dist/",
|
||||
".astro/",
|
||||
".wrangler/",
|
||||
"node_modules/",
|
||||
"public/pagefind/",
|
||||
"poli0981.dev-docs/",
|
||||
"worker-configuration.d.ts",
|
||||
],
|
||||
},
|
||||
...tseslint.configs.recommended,
|
||||
...tseslint.configs.strict,
|
||||
...astro.configs.recommended,
|
||||
...svelte.configs.recommended,
|
||||
{
|
||||
rules: {
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{ argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
// Ambient declaration files idiomatically use triple-slash refs, import() types,
|
||||
// and marker interfaces (e.g. App.Locals extends Runtime).
|
||||
files: ["**/*.d.ts"],
|
||||
rules: {
|
||||
"@typescript-eslint/triple-slash-reference": "off",
|
||||
"@typescript-eslint/consistent-type-imports": "off",
|
||||
"@typescript-eslint/no-empty-object-type": "off",
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "https://unpkg.com/knip@6/schema.json",
|
||||
"ignoreDependencies": ["cloudflare"]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
format:
|
||||
glob: "*.{astro,svelte,ts,js,mjs,md,css,json,jsonc,yml,yaml}"
|
||||
run: npx prettier --write {staged_files}
|
||||
stage_fixed: true
|
||||
lint:
|
||||
glob: "*.{astro,svelte,ts,js,mjs}"
|
||||
run: npx eslint {staged_files}
|
||||
|
||||
pre-push:
|
||||
commands:
|
||||
typecheck:
|
||||
run: npm run check
|
||||
Generated
+11367
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "poli0981-dev",
|
||||
"type": "module",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "SEE LICENSE IN LICENSE",
|
||||
"engines": {
|
||||
"node": ">=24"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro",
|
||||
"check": "astro check",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"knip": "knip"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/cloudflare": "^14.1.3",
|
||||
"@astrojs/mdx": "^7.0.3",
|
||||
"@astrojs/sitemap": "^3.7.3",
|
||||
"@astrojs/svelte": "^9.0.1",
|
||||
"@tailwindcss/vite": "^4.3.3",
|
||||
"astro": "^7.1.1",
|
||||
"sharp": "^0.35.3",
|
||||
"svelte": "^5.56.6",
|
||||
"tailwindcss": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@astrojs/check": "^0.9.9",
|
||||
"@types/node": "^26.1.1",
|
||||
"eslint": "^10.7.0",
|
||||
"eslint-plugin-astro": "^3.0.1",
|
||||
"eslint-plugin-svelte": "^3.21.0",
|
||||
"knip": "^6.27.0",
|
||||
"lefthook": "^2.1.10",
|
||||
"prettier": "^3.9.5",
|
||||
"prettier-plugin-astro": "^0.14.1",
|
||||
"prettier-plugin-svelte": "^4.1.1",
|
||||
"prettier-plugin-tailwindcss": "^0.8.1",
|
||||
"typescript": "~6.0.3",
|
||||
"typescript-eslint": "^8.64.0",
|
||||
"wrangler": "^4.112.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/** @type {import("prettier").Config} */
|
||||
export default {
|
||||
printWidth: 100,
|
||||
singleQuote: false,
|
||||
semi: true,
|
||||
trailingComma: "all",
|
||||
// tailwindcss plugin MUST be last so it can reorder classes after the others parse.
|
||||
plugins: ["prettier-plugin-astro", "prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
|
||||
tailwindStylesheet: "./src/styles/global.css",
|
||||
overrides: [{ files: "*.astro", options: { parser: "astro" } }],
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
|
||||
<rect width="32" height="32" rx="7" fill="#0d1117" />
|
||||
<path
|
||||
d="M3 16 H9 L11 9 L14 23 L17 11 L20 20 L23 16 H29"
|
||||
fill="none"
|
||||
stroke="#e8a33d"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 305 B |
@@ -0,0 +1,66 @@
|
||||
---
|
||||
interface Props {
|
||||
type?: "info" | "tip" | "warn";
|
||||
title?: string;
|
||||
}
|
||||
const { type = "info", title } = Astro.props;
|
||||
const icon = { info: "i", tip: "★", warn: "!" }[type];
|
||||
---
|
||||
|
||||
<aside class:list={["callout", type]} role="note">
|
||||
<span class="callout-icon" aria-hidden="true">{icon}</span>
|
||||
<div class="callout-body">
|
||||
{title && <p class="callout-title">{title}</p>}
|
||||
<slot />
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<style>
|
||||
.callout {
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border-radius: var(--radius-card);
|
||||
border: 1px solid var(--line);
|
||||
background: var(--surface);
|
||||
font-family: var(--ff-body);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
.callout-icon {
|
||||
flex: none;
|
||||
inline-size: 1.5rem;
|
||||
block-size: 1.5rem;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 999px;
|
||||
font-family: var(--ff-mono);
|
||||
font-weight: 700;
|
||||
font-size: 0.85rem;
|
||||
color: var(--bg);
|
||||
}
|
||||
.callout-title {
|
||||
font-weight: 600;
|
||||
margin-block-end: 0.25rem;
|
||||
}
|
||||
.callout-body > :global(* + *) {
|
||||
margin-block-start: 0.5em;
|
||||
}
|
||||
.callout.info {
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
||||
}
|
||||
.callout.info .callout-icon {
|
||||
background: var(--accent);
|
||||
}
|
||||
.callout.tip {
|
||||
border-color: color-mix(in srgb, var(--ok) 40%, var(--line));
|
||||
}
|
||||
.callout.tip .callout-icon {
|
||||
background: var(--ok);
|
||||
}
|
||||
.callout.warn {
|
||||
border-color: color-mix(in srgb, var(--warn) 45%, var(--line));
|
||||
}
|
||||
.callout.warn .callout-icon {
|
||||
background: var(--warn);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,81 @@
|
||||
---
|
||||
interface Props {
|
||||
warnings: string[];
|
||||
title?: string;
|
||||
hint?: string;
|
||||
}
|
||||
// JS-free reveal via native <details> — keyboard-accessible and CSP-clean.
|
||||
const { warnings, title = "Cảnh báo nội dung", hint = "Bấm để đọc" } = Astro.props;
|
||||
---
|
||||
|
||||
<details class="cw">
|
||||
<summary class="cw-summary">
|
||||
<span class="cw-icon" aria-hidden="true">⚠</span>
|
||||
<span class="cw-title">{title}</span>
|
||||
{
|
||||
warnings.length > 0 && (
|
||||
<span class="cw-tags">
|
||||
{warnings.map((w) => (
|
||||
<span class="cw-tag">{w}</span>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
<span class="cw-hint">{hint}</span>
|
||||
</summary>
|
||||
<div class="cw-body">
|
||||
<slot />
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<style>
|
||||
.cw {
|
||||
border: 1px solid color-mix(in srgb, var(--horror) 55%, var(--line));
|
||||
border-radius: var(--radius-card);
|
||||
background: color-mix(in srgb, var(--horror) 10%, var(--surface));
|
||||
}
|
||||
.cw-summary {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 0.75rem;
|
||||
padding: 0.9rem 1.1rem;
|
||||
cursor: pointer;
|
||||
list-style: none;
|
||||
color: var(--text);
|
||||
}
|
||||
.cw-summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
.cw-icon {
|
||||
color: var(--horror);
|
||||
font-size: 1.1em;
|
||||
}
|
||||
.cw-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
.cw-tags {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
.cw-tag {
|
||||
padding: 0.1em 0.5em;
|
||||
border-radius: 999px;
|
||||
background: color-mix(in srgb, var(--horror) 30%, transparent);
|
||||
color: color-mix(in srgb, var(--horror) 30%, var(--text));
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.cw-hint {
|
||||
margin-inline-start: auto;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.cw[open] .cw-hint {
|
||||
display: none;
|
||||
}
|
||||
.cw-body {
|
||||
padding: 0 1.1rem 1.1rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
import { toLocale, useTranslations } from "../i18n";
|
||||
import { type Locale } from "../i18n/routing";
|
||||
import { menuNav, legalNav } from "../lib/nav";
|
||||
import Waveline from "./Waveline.svelte";
|
||||
|
||||
const locale: Locale = toLocale(Astro.currentLocale);
|
||||
const t = useTranslations(locale);
|
||||
const nav = menuNav(locale);
|
||||
const legal = legalNav(locale);
|
||||
const year = new Date().getFullYear();
|
||||
---
|
||||
|
||||
<footer class="site-footer">
|
||||
<div class="page">
|
||||
<Waveline client:visible height={34} />
|
||||
</div>
|
||||
<div class="page footer-inner">
|
||||
<nav class="footer-nav" aria-label="Footer">
|
||||
{nav.map((item) => <a href={item.href}>{item.label}</a>)}
|
||||
</nav>
|
||||
<nav class="footer-legal" aria-label={t.footer.legal}>
|
||||
{legal.map((item) => <a href={item.href}>{item.label}</a>)}
|
||||
</nav>
|
||||
<p class="copyright">© {year} Kokone (SkullMute). {t.footer.rights}</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<style>
|
||||
.site-footer {
|
||||
margin-block-start: var(--spacing-section);
|
||||
border-block-start: 1px solid transparent;
|
||||
}
|
||||
.footer-inner {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
padding-block: 2rem 3rem;
|
||||
}
|
||||
.footer-nav,
|
||||
.footer-legal {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 1rem;
|
||||
}
|
||||
.footer-nav a {
|
||||
color: var(--text);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
.footer-legal a {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.footer-nav a:hover,
|
||||
.footer-legal a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.copyright {
|
||||
margin: 0;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.footer-inner {
|
||||
padding-block-end: 2rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,148 @@
|
||||
---
|
||||
import { toLocale, useTranslations } from "../i18n";
|
||||
import { homePath, type Locale } from "../i18n/routing";
|
||||
import { primaryNav, isActivePath } from "../lib/nav";
|
||||
import ThemeToggle from "./ThemeToggle.svelte";
|
||||
import LangSwitch from "./LangSwitch.astro";
|
||||
|
||||
const locale: Locale = toLocale(Astro.currentLocale);
|
||||
const t = useTranslations(locale);
|
||||
const nav = primaryNav(locale);
|
||||
const pathname = Astro.url.pathname;
|
||||
---
|
||||
|
||||
<header class="site-header">
|
||||
<div class="page header-inner">
|
||||
<a class="brand" href={homePath(locale)} aria-label="poli0981.dev — home">
|
||||
<svg class="brand-mark" viewBox="0 0 32 12" aria-hidden="true">
|
||||
<path
|
||||
d="M1 6 H8 L10 2 L13 10 L16 3 L19 9 L22 6 H31"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"></path>
|
||||
</svg>
|
||||
<span class="brand-text">SkullMute</span>
|
||||
</a>
|
||||
|
||||
<nav class="primary-nav" aria-label="Primary">
|
||||
{
|
||||
nav.map((item) => (
|
||||
<a href={item.href} aria-current={isActivePath(pathname, item.href) ? "page" : undefined}>
|
||||
{item.label}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</nav>
|
||||
|
||||
<div class="actions">
|
||||
<ThemeToggle client:load label={t.theme.toggle} />
|
||||
<LangSwitch />
|
||||
<button
|
||||
type="button"
|
||||
class="menu-trigger"
|
||||
data-menu-trigger
|
||||
aria-label={t.nav.openMenu}
|
||||
aria-controls="menu-sheet"
|
||||
aria-expanded="false"
|
||||
>
|
||||
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" aria-hidden="true">
|
||||
<path
|
||||
d="M3 6h18M3 12h18M3 18h18"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.7"
|
||||
stroke-linecap="round"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<style>
|
||||
.site-header {
|
||||
position: sticky;
|
||||
inset-block-start: 0;
|
||||
z-index: 40;
|
||||
background: color-mix(in srgb, var(--bg) 85%, transparent);
|
||||
backdrop-filter: blur(8px);
|
||||
border-block-end: 1px solid var(--line);
|
||||
}
|
||||
.header-inner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
block-size: 3.75rem;
|
||||
}
|
||||
.brand {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--text);
|
||||
font-family: var(--ff-display);
|
||||
font-weight: 700;
|
||||
font-size: 1.05rem;
|
||||
}
|
||||
.brand-mark {
|
||||
inline-size: 2rem;
|
||||
block-size: 0.75rem;
|
||||
color: var(--accent);
|
||||
}
|
||||
.primary-nav {
|
||||
display: none;
|
||||
gap: 0.35rem;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.primary-nav a {
|
||||
padding: 0.4rem 0.7rem;
|
||||
border-radius: var(--radius-control);
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
font-weight: 500;
|
||||
transition:
|
||||
color var(--duration-fast) var(--ease-site),
|
||||
background var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.primary-nav a:hover {
|
||||
color: var(--text);
|
||||
background: var(--surface);
|
||||
}
|
||||
.primary-nav a[aria-current="page"] {
|
||||
color: var(--accent);
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
margin-inline-start: auto;
|
||||
}
|
||||
.menu-trigger {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
inline-size: 2.5rem;
|
||||
block-size: 2.5rem;
|
||||
border-radius: var(--radius-control);
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
}
|
||||
.menu-trigger:hover {
|
||||
background: var(--surface);
|
||||
border-color: var(--line);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.primary-nav {
|
||||
display: flex;
|
||||
}
|
||||
/* On desktop the primary nav takes the middle; actions sit at the end. */
|
||||
.actions {
|
||||
margin-inline-start: 0;
|
||||
}
|
||||
.menu-trigger {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,44 @@
|
||||
---
|
||||
import { alternatePath, localeFromPath, type Locale } from "../i18n/routing";
|
||||
import { useTranslations } from "../i18n";
|
||||
|
||||
interface Props {
|
||||
/** Override the target url (content pages resolve this from translationKey). */
|
||||
href?: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const current: Locale = localeFromPath(Astro.url.pathname);
|
||||
const target: Locale = current === "vi" ? "en" : "vi";
|
||||
const t = useTranslations(current);
|
||||
|
||||
const { href = alternatePath(Astro.url.pathname, target), label = t.lang.switchTo } = Astro.props;
|
||||
---
|
||||
|
||||
<a class="lang-switch" {href} hreflang={target} lang={target} aria-label={t.lang.label}>
|
||||
{label}
|
||||
</a>
|
||||
|
||||
<style>
|
||||
.lang-switch {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
block-size: 2.5rem;
|
||||
padding-inline: 0.75rem;
|
||||
border-radius: var(--radius-control);
|
||||
border: 1px solid transparent;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
transition:
|
||||
color var(--duration-fast) var(--ease-site),
|
||||
background var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.lang-switch:hover {
|
||||
color: var(--text);
|
||||
background: var(--surface);
|
||||
border-color: var(--line);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,134 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
/**
|
||||
* @type {{
|
||||
* strings: { line1: string, line2: string, line3: string, ack: string },
|
||||
* links: { href: string, label: string }[]
|
||||
* }}
|
||||
*/
|
||||
let { strings, links = [] } = $props();
|
||||
|
||||
// Bump when the legal texts change materially → the sheet reappears for everyone.
|
||||
const VERSION = 1;
|
||||
let visible = $state(false);
|
||||
|
||||
function dismiss() {
|
||||
visible = false;
|
||||
try {
|
||||
localStorage.setItem("legalAck", JSON.stringify({ v: VERSION, ts: Date.now() }));
|
||||
} catch {
|
||||
/* private mode */
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
try {
|
||||
const raw = localStorage.getItem("legalAck");
|
||||
if (raw) {
|
||||
const ack = JSON.parse(raw);
|
||||
if (ack && typeof ack.v === "number" && ack.v >= VERSION) return;
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
// 800ms after the page is interactive (docs 05 §5).
|
||||
const timer = setTimeout(() => {
|
||||
visible = true;
|
||||
}, 800);
|
||||
const onKey = (e) => {
|
||||
if (e.key === "Escape" && visible) dismiss();
|
||||
};
|
||||
document.addEventListener("keydown", onKey);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
document.removeEventListener("keydown", onKey);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
{#if visible}
|
||||
<aside class="gate" role="note" aria-label="Legal notice">
|
||||
<div class="gate-body">
|
||||
<p>{strings.line1}</p>
|
||||
<p>{strings.line2}</p>
|
||||
<p>{strings.line3}</p>
|
||||
<nav class="gate-links" aria-label="Legal links">
|
||||
{#each links as l (l.href)}
|
||||
<a href={l.href}>{l.label}</a>
|
||||
{/each}
|
||||
</nav>
|
||||
</div>
|
||||
<button type="button" class="gate-ack" onclick={dismiss}>{strings.ack}</button>
|
||||
</aside>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.gate {
|
||||
position: fixed;
|
||||
z-index: 55;
|
||||
inset-inline: 0;
|
||||
inset-block-end: 0;
|
||||
/* Does NOT block scroll — no backdrop; only the card is interactive. */
|
||||
max-block-size: 40vh;
|
||||
overflow-y: auto;
|
||||
padding: 1rem 1.15rem calc(1rem + env(safe-area-inset-bottom, 0));
|
||||
background: var(--elevated);
|
||||
border-block-start: 1px solid var(--line);
|
||||
box-shadow: var(--shadow-elevated);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
animation: gate-in 0.35s var(--ease-site) both;
|
||||
}
|
||||
@keyframes gate-in {
|
||||
from {
|
||||
transform: translateY(100%);
|
||||
}
|
||||
to {
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
.gate-body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.35rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
line-height: 1.5;
|
||||
}
|
||||
.gate-links {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 0.85rem;
|
||||
margin-block-start: 0.35rem;
|
||||
}
|
||||
.gate-links a {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.gate-ack {
|
||||
align-self: flex-start;
|
||||
padding: 0.5rem 1.1rem;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: var(--radius-control);
|
||||
background: transparent;
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.gate-ack:hover {
|
||||
background: color-mix(in srgb, var(--accent) 14%, transparent);
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.gate {
|
||||
inset-inline-start: auto;
|
||||
inset-inline-end: 1.5rem;
|
||||
inset-block-end: 1.5rem;
|
||||
inline-size: min(24rem, 90vw);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-modal);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
}
|
||||
---
|
||||
|
||||
<ul class="links-list">
|
||||
{
|
||||
SOCIAL_LINKS.map((link) => (
|
||||
<li>
|
||||
<a
|
||||
class="link-row"
|
||||
href={link.href}
|
||||
rel={relFor(link.href, link.me)}
|
||||
target={link.href.startsWith("http") ? "_blank" : undefined}
|
||||
>
|
||||
<span class="link-text">
|
||||
<span class="link-name">{link.name}</span>
|
||||
<span class="link-desc">{link.desc[locale]}</span>
|
||||
</span>
|
||||
<span class="link-arrow" aria-hidden="true">
|
||||
→
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
|
||||
<style>
|
||||
.links-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.link-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.15rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
transition:
|
||||
border-color var(--duration-fast) var(--ease-site),
|
||||
transform var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.link-row:hover {
|
||||
border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.link-text {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15rem;
|
||||
flex: 1;
|
||||
}
|
||||
.link-name {
|
||||
font-weight: 600;
|
||||
}
|
||||
.link-desc {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.link-arrow {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,177 @@
|
||||
<script>
|
||||
import { onMount, tick } from "svelte";
|
||||
|
||||
/** @type {{ items: {href: string, label: string}[], legal: {href: string, label: string}[], title: string, closeLabel: string, legalTitle: string }} */
|
||||
let {
|
||||
items = [],
|
||||
legal = [],
|
||||
title = "Menu",
|
||||
closeLabel = "Close",
|
||||
legalTitle = "Legal",
|
||||
} = $props();
|
||||
|
||||
let open = $state(false);
|
||||
let sheetEl = $state(null);
|
||||
|
||||
function reflectTriggers(v) {
|
||||
for (const b of document.querySelectorAll("[data-menu-trigger]")) {
|
||||
b.setAttribute("aria-expanded", String(v));
|
||||
}
|
||||
}
|
||||
|
||||
async function openMenu() {
|
||||
open = true;
|
||||
reflectTriggers(true);
|
||||
await tick();
|
||||
sheetEl?.querySelector("a, button")?.focus();
|
||||
}
|
||||
function closeMenu() {
|
||||
open = false;
|
||||
reflectTriggers(false);
|
||||
}
|
||||
function toggle() {
|
||||
if (open) closeMenu();
|
||||
else openMenu();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const onToggle = () => toggle();
|
||||
const onKey = (e) => {
|
||||
if (e.key === "Escape" && open) closeMenu();
|
||||
};
|
||||
const onSwap = () => closeMenu();
|
||||
document.addEventListener("toggle-menu", onToggle);
|
||||
document.addEventListener("keydown", onKey);
|
||||
document.addEventListener("astro:after-swap", onSwap);
|
||||
return () => {
|
||||
document.removeEventListener("toggle-menu", onToggle);
|
||||
document.removeEventListener("keydown", onKey);
|
||||
document.removeEventListener("astro:after-swap", onSwap);
|
||||
document.body.style.overflow = "";
|
||||
};
|
||||
});
|
||||
|
||||
// Scroll-lock the page while the sheet is open.
|
||||
$effect(() => {
|
||||
document.body.style.overflow = open ? "hidden" : "";
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="backdrop" class:open onclick={closeMenu} aria-hidden="true" role="presentation"></div>
|
||||
|
||||
<nav bind:this={sheetEl} id="menu-sheet" class="sheet" class:open aria-label={title} inert={!open}>
|
||||
<div class="sheet-head">
|
||||
<span class="sheet-title">{title}</span>
|
||||
<button type="button" class="close" onclick={closeMenu}>{closeLabel}</button>
|
||||
</div>
|
||||
|
||||
<ul class="links">
|
||||
{#each items as item (item.href)}
|
||||
<li><a href={item.href} onclick={closeMenu}>{item.label}</a></li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
{#if legal.length}
|
||||
<p class="group-title">{legalTitle}</p>
|
||||
<ul class="links legal">
|
||||
{#each legal as item (item.href)}
|
||||
<li><a href={item.href} onclick={closeMenu}>{item.label}</a></li>
|
||||
{/each}
|
||||
</ul>
|
||||
{/if}
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
.backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 50;
|
||||
background: rgb(0 0 0 / 0.5);
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transition:
|
||||
opacity var(--duration-base) var(--ease-site),
|
||||
visibility var(--duration-base) var(--ease-site);
|
||||
}
|
||||
.backdrop.open {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.sheet {
|
||||
position: fixed;
|
||||
inset-block: 0;
|
||||
inset-inline-end: 0;
|
||||
z-index: 51;
|
||||
inline-size: min(20rem, 82vw);
|
||||
padding: 1.25rem;
|
||||
padding-block-end: calc(1.25rem + env(safe-area-inset-bottom, 0));
|
||||
background: var(--elevated);
|
||||
border-inline-start: 1px solid var(--line);
|
||||
box-shadow: var(--shadow-elevated);
|
||||
transform: translateX(100%);
|
||||
transition: transform var(--duration-base) var(--ease-site);
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
.sheet.open {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.sheet-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.sheet-title {
|
||||
font-family: var(--ff-display);
|
||||
font-weight: 700;
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
.close {
|
||||
background: transparent;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-control);
|
||||
color: var(--muted);
|
||||
padding: 0.4rem 0.75rem;
|
||||
font-size: var(--text-meta);
|
||||
cursor: pointer;
|
||||
}
|
||||
.close:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.links {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.links a {
|
||||
display: block;
|
||||
padding: 0.7rem 0.5rem;
|
||||
color: var(--text);
|
||||
font-size: var(--text-lead);
|
||||
border-radius: var(--radius-control);
|
||||
}
|
||||
.links a:hover {
|
||||
background: var(--surface);
|
||||
color: var(--accent);
|
||||
}
|
||||
.group-title {
|
||||
margin: 1.25rem 0 0.25rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
}
|
||||
.links.legal a {
|
||||
font-size: var(--text-body);
|
||||
color: var(--muted);
|
||||
}
|
||||
.links.legal a:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
</style>
|
||||
@@ -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 },
|
||||
];
|
||||
---
|
||||
|
||||
<nav class="tabbar" aria-label="Primary (mobile)">
|
||||
{
|
||||
tabs.map((tab) => (
|
||||
<a
|
||||
class="tab"
|
||||
href={tab.href}
|
||||
aria-current={isActivePath(pathname, tab.href) ? "page" : undefined}
|
||||
>
|
||||
<svg
|
||||
class="tab-icon"
|
||||
viewBox="0 0 24 24"
|
||||
width="22"
|
||||
height="22"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
{tab.icon === "home" && (
|
||||
<path
|
||||
d="M4 11.5 12 4l8 7.5M6 10v9h12v-9"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
)}
|
||||
{tab.icon === "blog" && (
|
||||
<path
|
||||
d="M5 4h11l3 3v13H5zM8 9h8M8 13h8M8 17h5"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
)}
|
||||
{tab.icon === "book" && (
|
||||
<path
|
||||
d="M4 5.5A2.5 2.5 0 0 1 6.5 3H19v15H6.5A2.5 2.5 0 0 0 4 20.5zM19 18v3H6.5"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
)}
|
||||
</svg>
|
||||
<span>{tab.label}</span>
|
||||
</a>
|
||||
))
|
||||
}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="tab"
|
||||
data-menu-trigger
|
||||
aria-controls="menu-sheet"
|
||||
aria-expanded="false"
|
||||
>
|
||||
<svg class="tab-icon" viewBox="0 0 24 24" width="22" height="22" fill="none" aria-hidden="true">
|
||||
<path
|
||||
d="M4 7h16M4 12h16M4 17h16"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"></path>
|
||||
</svg>
|
||||
<span>{t.nav.menu}</span>
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
.tabbar {
|
||||
position: fixed;
|
||||
inset-inline: 0;
|
||||
inset-block-end: 0;
|
||||
z-index: 40;
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
background: color-mix(in srgb, var(--surface) 92%, transparent);
|
||||
backdrop-filter: blur(10px);
|
||||
border-block-start: 1px solid var(--line);
|
||||
padding-block-end: env(safe-area-inset-bottom, 0);
|
||||
}
|
||||
.tab {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.15rem;
|
||||
min-block-size: 3.5rem;
|
||||
padding: 0.4rem 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--muted);
|
||||
font-size: 0.6875rem;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
}
|
||||
.tab[aria-current="page"] {
|
||||
color: var(--accent);
|
||||
}
|
||||
.tab-icon {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.tabbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
---
|
||||
|
||||
<nav class="pager" aria-label={ariaLabel}>
|
||||
{
|
||||
prev ? (
|
||||
<a class="pager-link prev" href={prev.href} rel="prev">
|
||||
<span class="dir">← {prevText}</span>
|
||||
<span class="lbl">{prev.label}</span>
|
||||
</a>
|
||||
) : (
|
||||
<span class="pager-empty" />
|
||||
)
|
||||
}
|
||||
{
|
||||
next ? (
|
||||
<a class="pager-link next" href={next.href} rel="next">
|
||||
<span class="dir">{nextText} →</span>
|
||||
<span class="lbl">{next.label}</span>
|
||||
</a>
|
||||
) : (
|
||||
<span class="pager-empty" />
|
||||
)
|
||||
}
|
||||
</nav>
|
||||
|
||||
<style>
|
||||
.pager {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
.pager-link {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
padding: 0.9rem 1rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
transition:
|
||||
border-color var(--duration-fast) var(--ease-site),
|
||||
transform var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.pager-link:hover {
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.pager-link.next {
|
||||
text-align: end;
|
||||
}
|
||||
.dir {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.lbl {
|
||||
font-weight: 600;
|
||||
font-size: var(--text-body);
|
||||
line-height: 1.3;
|
||||
}
|
||||
</style>
|
||||
@@ -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);
|
||||
---
|
||||
|
||||
<article class="card">
|
||||
<a class="card-link" href={href}>
|
||||
{
|
||||
entry.data.cover && (
|
||||
<div class="card-cover">
|
||||
<Image
|
||||
src={entry.data.cover}
|
||||
alt=""
|
||||
widths={[400, 800]}
|
||||
sizes="(max-width: 768px) 100vw, 380px"
|
||||
loading="lazy"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div class="card-body">
|
||||
<h3 class="card-title">{entry.data.title}</h3>
|
||||
<p class="card-desc">{entry.data.description}</p>
|
||||
<div class="card-meta">
|
||||
<time datetime={isoDate(entry.data.date)}>{formatDate(entry.data.date, locale)}</time>
|
||||
<span class="dot" aria-hidden="true">·</span>
|
||||
<span>{mins} {t.post.minRead}</span>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
overflow: clip;
|
||||
transition:
|
||||
transform var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
||||
}
|
||||
.card-link {
|
||||
display: block;
|
||||
block-size: 100%;
|
||||
color: inherit;
|
||||
}
|
||||
.card-cover :global(img) {
|
||||
display: block;
|
||||
inline-size: 100%;
|
||||
aspect-ratio: 16 / 9;
|
||||
object-fit: cover;
|
||||
}
|
||||
.card-body {
|
||||
padding: 1rem 1.1rem 1.15rem;
|
||||
}
|
||||
.card-title {
|
||||
font-size: var(--text-lead);
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
.card-desc {
|
||||
margin-block-start: 0.4rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-body);
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.card-meta {
|
||||
margin-block-start: 0.75rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
</style>
|
||||
@@ -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 ? (
|
||||
<div class="post-grid">
|
||||
{posts.map((entry) => (
|
||||
<PostCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div class="empty">
|
||||
<p>{emptyText}</p>
|
||||
{emptyHref && emptyLabel && <a href={emptyHref}>{emptyLabel} →</a>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
<style>
|
||||
.post-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.post-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (min-width: 960px) {
|
||||
.post-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
.empty {
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
padding: 2.5rem 1.5rem;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.empty a {
|
||||
display: inline-block;
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
---
|
||||
|
||||
<article class:list={["card project", { featured }]}>
|
||||
<a class="card-link" href={href}>
|
||||
<div class="head">
|
||||
<h3 class="card-title">{name}</h3>
|
||||
<span class="year">{year}</span>
|
||||
</div>
|
||||
<p class="tagline">{tagline}</p>
|
||||
{
|
||||
stack.length > 0 && (
|
||||
<ul class="stack">
|
||||
{stack.slice(0, 6).map((s) => (
|
||||
<li>{s}</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
</a>
|
||||
{
|
||||
(repo || url) && (
|
||||
<div class="links">
|
||||
{repo && (
|
||||
<a href={repo} target="_blank" rel="noopener noreferrer">
|
||||
repo ↗
|
||||
</a>
|
||||
)}
|
||||
{url && (
|
||||
<a href={url} target="_blank" rel="noopener noreferrer">
|
||||
site ↗
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</article>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
padding: 1.1rem;
|
||||
transition:
|
||||
transform var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
||||
}
|
||||
.card.featured {
|
||||
border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
|
||||
}
|
||||
.card-link {
|
||||
color: inherit;
|
||||
flex: 1;
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.card-title {
|
||||
font-size: var(--text-lead);
|
||||
font-weight: 700;
|
||||
}
|
||||
.year {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.tagline {
|
||||
margin-block-start: 0.35rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
.stack {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin-block-start: 0.75rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.35rem;
|
||||
}
|
||||
.stack li {
|
||||
padding: 0.1em 0.5em;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.links {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
margin-block-start: 0.9rem;
|
||||
padding-block-start: 0.75rem;
|
||||
border-block-start: 1px solid var(--line);
|
||||
}
|
||||
.links a {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.links a:hover {
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
---
|
||||
|
||||
<div class:list={["prose", { "prose--reader": reader }, className]}>
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
<style is:global>
|
||||
.prose {
|
||||
--measure: 65ch;
|
||||
max-inline-size: var(--measure);
|
||||
font-family: var(--ff-reading);
|
||||
font-size: var(--text-body);
|
||||
line-height: 1.7;
|
||||
color: var(--text);
|
||||
}
|
||||
.prose--reader {
|
||||
--measure: 68ch;
|
||||
/* --reader-fs is set by ReadingControls on the reader container and inherits here. */
|
||||
font-size: var(--reader-fs, clamp(1.125rem, 1.05rem + 0.32vw, 1.25rem));
|
||||
}
|
||||
|
||||
.prose > * + * {
|
||||
margin-block-start: 1em;
|
||||
}
|
||||
.prose h2,
|
||||
.prose h3,
|
||||
.prose h4 {
|
||||
font-family: var(--ff-display);
|
||||
line-height: 1.2;
|
||||
margin-block-start: 1.8em;
|
||||
text-wrap: balance;
|
||||
}
|
||||
.prose h2 {
|
||||
font-size: var(--text-h3);
|
||||
}
|
||||
.prose h3 {
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
.prose a {
|
||||
color: var(--accent);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 0.15em;
|
||||
text-decoration-thickness: 1px;
|
||||
text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
|
||||
}
|
||||
.prose a:hover {
|
||||
text-decoration-color: var(--accent);
|
||||
}
|
||||
.prose strong {
|
||||
color: var(--text);
|
||||
font-weight: 600;
|
||||
}
|
||||
.prose blockquote {
|
||||
margin-inline: 0;
|
||||
padding-inline-start: 1.1em;
|
||||
border-inline-start: 2px solid var(--accent);
|
||||
color: var(--muted);
|
||||
font-style: italic;
|
||||
}
|
||||
.prose ul,
|
||||
.prose ol {
|
||||
padding-inline-start: 1.4em;
|
||||
}
|
||||
.prose li::marker {
|
||||
color: var(--muted);
|
||||
}
|
||||
.prose img {
|
||||
max-inline-size: 100%;
|
||||
block-size: auto;
|
||||
border-radius: var(--radius-card);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.prose hr {
|
||||
border: none;
|
||||
border-block-start: 1px solid var(--line);
|
||||
margin-block: 2em;
|
||||
}
|
||||
.prose :not(pre) > code {
|
||||
font-family: var(--ff-mono);
|
||||
font-size: 0.9em;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 4px;
|
||||
padding: 0.1em 0.35em;
|
||||
}
|
||||
.prose pre {
|
||||
font-family: var(--ff-mono);
|
||||
font-size: 0.9em;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
padding: 1em 1.1em;
|
||||
overflow-x: auto;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.prose pre code {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Prism token theme (class-based → CSP-clean). */
|
||||
.prose .token.comment,
|
||||
.prose .token.prolog,
|
||||
.prose .token.doctype,
|
||||
.prose .token.cdata {
|
||||
color: var(--muted);
|
||||
font-style: italic;
|
||||
}
|
||||
.prose .token.punctuation {
|
||||
color: var(--muted);
|
||||
}
|
||||
.prose .token.keyword,
|
||||
.prose .token.selector,
|
||||
.prose .token.important,
|
||||
.prose .token.atrule {
|
||||
color: var(--accent);
|
||||
}
|
||||
.prose .token.string,
|
||||
.prose .token.attr-value,
|
||||
.prose .token.char,
|
||||
.prose .token.regex {
|
||||
color: var(--ok);
|
||||
}
|
||||
.prose .token.function,
|
||||
.prose .token.class-name {
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
.prose .token.number,
|
||||
.prose .token.boolean,
|
||||
.prose .token.constant {
|
||||
color: var(--warn);
|
||||
}
|
||||
.prose .token.tag,
|
||||
.prose .token.property,
|
||||
.prose .token.attr-name,
|
||||
.prose .token.symbol {
|
||||
color: var(--text);
|
||||
}
|
||||
.prose .token.operator,
|
||||
.prose .token.entity,
|
||||
.prose .token.url {
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,209 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
/**
|
||||
* @type {{
|
||||
* labels: {
|
||||
* aria: string, sizeTitle: string, themeTitle: string,
|
||||
* sizeS: string, sizeM: string, sizeL: string,
|
||||
* paper: string, sepia: string, dark: string
|
||||
* }
|
||||
* }}
|
||||
*/
|
||||
let { labels } = $props();
|
||||
|
||||
let open = $state(false);
|
||||
let size = $state("m"); // s | m | l
|
||||
let theme = $state(""); // "" follows the site theme; else paper | sepia | dark
|
||||
let progress = $state(0);
|
||||
|
||||
let barEl = $state(null);
|
||||
let panelEl = $state(null);
|
||||
|
||||
function target() {
|
||||
return document.getElementById("reader-root");
|
||||
}
|
||||
function apply() {
|
||||
const root = target();
|
||||
if (!root) return;
|
||||
root.dataset.readerSize = size;
|
||||
if (theme) root.dataset.readerTheme = theme;
|
||||
else delete root.dataset.readerTheme;
|
||||
}
|
||||
function persist() {
|
||||
try {
|
||||
localStorage.setItem("reader", JSON.stringify({ size, theme }));
|
||||
} catch {
|
||||
/* private mode */
|
||||
}
|
||||
}
|
||||
function setSize(s) {
|
||||
size = s;
|
||||
apply();
|
||||
persist();
|
||||
}
|
||||
function setTheme(t) {
|
||||
theme = theme === t ? "" : t; // click active → back to following the site theme
|
||||
apply();
|
||||
persist();
|
||||
}
|
||||
|
||||
function onScroll() {
|
||||
const el = document.documentElement;
|
||||
const max = el.scrollHeight - el.clientHeight;
|
||||
progress = max > 0 ? Math.min(1, Math.max(0, el.scrollTop / max)) : 0;
|
||||
}
|
||||
|
||||
// Drive the progress bar through a CSS var via CSSOM (never an inline style attr → CSP-safe).
|
||||
$effect(() => {
|
||||
if (barEl) barEl.style.setProperty("--p", String(progress));
|
||||
});
|
||||
|
||||
onMount(() => {
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem("reader") || "{}");
|
||||
if (saved.size === "s" || saved.size === "m" || saved.size === "l") size = saved.size;
|
||||
if (saved.theme === "paper" || saved.theme === "sepia" || saved.theme === "dark")
|
||||
theme = saved.theme;
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
apply();
|
||||
onScroll();
|
||||
|
||||
const onKey = (e) => {
|
||||
if (e.key === "Escape" && open) open = false;
|
||||
};
|
||||
const onDown = (e) => {
|
||||
if (open && panelEl && !panelEl.contains(e.target)) open = false;
|
||||
};
|
||||
window.addEventListener("scroll", onScroll, { passive: true });
|
||||
window.addEventListener("resize", onScroll, { passive: true });
|
||||
document.addEventListener("keydown", onKey);
|
||||
document.addEventListener("pointerdown", onDown);
|
||||
document.addEventListener("astro:after-swap", apply);
|
||||
return () => {
|
||||
window.removeEventListener("scroll", onScroll);
|
||||
window.removeEventListener("resize", onScroll);
|
||||
document.removeEventListener("keydown", onKey);
|
||||
document.removeEventListener("pointerdown", onDown);
|
||||
document.removeEventListener("astro:after-swap", apply);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="progress" bind:this={barEl} aria-hidden="true"></div>
|
||||
|
||||
<div class="rc" bind:this={panelEl}>
|
||||
<button
|
||||
type="button"
|
||||
class="aa"
|
||||
onclick={() => (open = !open)}
|
||||
aria-expanded={open}
|
||||
aria-label={labels.aria}
|
||||
>
|
||||
Aa
|
||||
</button>
|
||||
|
||||
{#if open}
|
||||
<div class="panel" role="group" aria-label={labels.aria}>
|
||||
<div class="row">
|
||||
<span class="row-title">{labels.sizeTitle}</span>
|
||||
<div class="opts">
|
||||
<button class:active={size === "s"} onclick={() => setSize("s")}>{labels.sizeS}</button>
|
||||
<button class:active={size === "m"} onclick={() => setSize("m")}>{labels.sizeM}</button>
|
||||
<button class:active={size === "l"} onclick={() => setSize("l")}>{labels.sizeL}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<span class="row-title">{labels.themeTitle}</span>
|
||||
<div class="opts">
|
||||
<button class:active={theme === "paper"} onclick={() => setTheme("paper")}>
|
||||
{labels.paper}
|
||||
</button>
|
||||
<button class:active={theme === "sepia"} onclick={() => setTheme("sepia")}>
|
||||
{labels.sepia}
|
||||
</button>
|
||||
<button class:active={theme === "dark"} onclick={() => setTheme("dark")}>
|
||||
{labels.dark}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.progress {
|
||||
position: fixed;
|
||||
inset-block-start: 0;
|
||||
inset-inline: 0;
|
||||
block-size: 2px;
|
||||
z-index: 45;
|
||||
background: var(--accent);
|
||||
transform: scaleX(var(--p, 0));
|
||||
transform-origin: left;
|
||||
transition: transform 80ms linear;
|
||||
}
|
||||
|
||||
.rc {
|
||||
position: relative;
|
||||
}
|
||||
.aa {
|
||||
inline-size: 2.5rem;
|
||||
block-size: 2.5rem;
|
||||
border-radius: var(--radius-control);
|
||||
border: 1px solid var(--line);
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
font-family: var(--ff-display);
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
.aa:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.panel {
|
||||
position: absolute;
|
||||
inset-block-start: calc(100% + 0.5rem);
|
||||
inset-inline-end: 0;
|
||||
z-index: 60;
|
||||
inline-size: 15rem;
|
||||
padding: 0.9rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
background: var(--elevated);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
box-shadow: var(--shadow-elevated);
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.row-title {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.opts {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 0.35rem;
|
||||
}
|
||||
.opts button {
|
||||
padding: 0.45rem 0;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-control);
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.opts button.active {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,28 @@
|
||||
---
|
||||
interface Props {
|
||||
href?: string;
|
||||
label?: string;
|
||||
}
|
||||
const { href = "#main", label = "Bỏ qua đến nội dung" } = Astro.props;
|
||||
---
|
||||
|
||||
<a class="skip-link" {href}>{label}</a>
|
||||
|
||||
<style>
|
||||
.skip-link {
|
||||
position: fixed;
|
||||
inset-block-start: 0.5rem;
|
||||
inset-inline-start: 0.5rem;
|
||||
z-index: 10000;
|
||||
padding: 0.5rem 0.875rem;
|
||||
background: var(--elevated);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-control);
|
||||
transform: translateY(-160%);
|
||||
transition: transform var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.skip-link:focus-visible {
|
||||
transform: translateY(0);
|
||||
}
|
||||
</style>
|
||||
@@ -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;
|
||||
---
|
||||
|
||||
<article class="card story">
|
||||
<a class="card-link" href={href}>
|
||||
<div class="card-body">
|
||||
<div class="badges">
|
||||
<span class:list={["status", entry.data.status]}>{statusLabel}</span>
|
||||
{
|
||||
hasCW && (
|
||||
<span class="cw-badge" title={entry.data.contentWarning.join(", ")}>
|
||||
⚠ {entry.data.contentWarning[0]}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
{entry.data.series && <p class="series">{entry.data.series}</p>}
|
||||
<h3 class="card-title">{entry.data.title}</h3>
|
||||
<p class="card-desc">{entry.data.description}</p>
|
||||
<div class="card-meta">
|
||||
<time datetime={isoDate(entry.data.date)}>{formatDate(entry.data.date, locale)}</time>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
|
||||
<style>
|
||||
.card {
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
transition:
|
||||
transform var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.card:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
|
||||
}
|
||||
.card-link {
|
||||
display: block;
|
||||
color: inherit;
|
||||
}
|
||||
.card-body {
|
||||
padding: 1.1rem;
|
||||
}
|
||||
.badges {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
margin-block-end: 0.6rem;
|
||||
}
|
||||
.status {
|
||||
padding: 0.1em 0.55em;
|
||||
border-radius: 999px;
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
}
|
||||
.status.ongoing {
|
||||
color: var(--accent);
|
||||
border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
|
||||
}
|
||||
.status.complete {
|
||||
color: var(--ok);
|
||||
border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
|
||||
}
|
||||
.cw-badge {
|
||||
padding: 0.1em 0.55em;
|
||||
border-radius: 999px;
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
color: color-mix(in srgb, var(--horror) 35%, var(--text));
|
||||
background: color-mix(in srgb, var(--horror) 18%, transparent);
|
||||
border: 1px solid color-mix(in srgb, var(--horror) 45%, var(--line));
|
||||
}
|
||||
.series {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.card-title {
|
||||
margin-block-start: 0.15rem;
|
||||
font-size: var(--text-lead);
|
||||
font-weight: 700;
|
||||
line-height: 1.25;
|
||||
}
|
||||
.card-desc {
|
||||
margin-block-start: 0.4rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-body);
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
overflow: hidden;
|
||||
}
|
||||
.card-meta {
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
</style>
|
||||
@@ -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 class="tag-pill" href={link ? href : undefined}>
|
||||
#{tag}{count != null && <span class="tag-count">{count}</span>}
|
||||
</Tag>
|
||||
|
||||
<style>
|
||||
.tag-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35em;
|
||||
padding: 0.2em 0.6em;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--surface);
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
line-height: 1.4;
|
||||
transition:
|
||||
color var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
a.tag-pill:hover {
|
||||
color: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.tag-count {
|
||||
color: var(--text);
|
||||
opacity: 0.7;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,82 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
|
||||
/** @type {{ label: string }} */
|
||||
let { label = "Toggle theme" } = $props();
|
||||
|
||||
let theme = $state("dark");
|
||||
|
||||
onMount(() => {
|
||||
theme = document.documentElement.dataset.theme === "light" ? "light" : "dark";
|
||||
// Reflect theme if a View Transitions swap re-runs the persisted <html> attribute.
|
||||
const sync = () => {
|
||||
theme = document.documentElement.dataset.theme === "light" ? "light" : "dark";
|
||||
};
|
||||
document.addEventListener("astro:after-swap", sync);
|
||||
return () => document.removeEventListener("astro:after-swap", sync);
|
||||
});
|
||||
|
||||
function toggle() {
|
||||
theme = theme === "dark" ? "light" : "dark";
|
||||
document.documentElement.dataset.theme = theme;
|
||||
try {
|
||||
localStorage.setItem("theme", theme);
|
||||
} catch {
|
||||
/* private mode — non-fatal */
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="theme-toggle"
|
||||
onclick={toggle}
|
||||
aria-label={label}
|
||||
title={label}
|
||||
aria-pressed={theme === "light"}
|
||||
>
|
||||
{#if theme === "dark"}
|
||||
<!-- moon -->
|
||||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true">
|
||||
<path
|
||||
d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<!-- sun -->
|
||||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" aria-hidden="true">
|
||||
<circle cx="12" cy="12" r="4.2" stroke="currentColor" stroke-width="1.6" />
|
||||
<path
|
||||
d="M12 2v2.5M12 19.5V22M2 12h2.5M19.5 12H22M4.9 4.9l1.8 1.8M17.3 17.3l1.8 1.8M19.1 4.9l-1.8 1.8M6.7 17.3l-1.8 1.8"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.6"
|
||||
stroke-linecap="round"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<style>
|
||||
.theme-toggle {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
inline-size: 2.5rem;
|
||||
block-size: 2.5rem;
|
||||
border-radius: var(--radius-control);
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition:
|
||||
background var(--duration-fast) var(--ease-site),
|
||||
border-color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.theme-toggle:hover {
|
||||
background: var(--surface);
|
||||
border-color: var(--line);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,130 @@
|
||||
<script module>
|
||||
// Unique gradient id per instance (same increment order on SSR + hydrate).
|
||||
let uidCounter = 0;
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
import { DURATION, prefersReducedMotion } from "../lib/motion";
|
||||
|
||||
// Easing to match the site ease (~cubic-bezier(0.22,1,0.36,1)) without a library.
|
||||
const easeOut = (t) => 1 - Math.pow(1 - t, 4);
|
||||
const easeInOut = (t) => (t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2);
|
||||
|
||||
/**
|
||||
* The site signature: a muted sound-wave. Idle = flatline; on hover or first
|
||||
* scroll-into-view it "comes alive" into a waveform for ~1.2s, then settles flat.
|
||||
* One beat, never a loop. Static flatline under prefers-reduced-motion.
|
||||
*/
|
||||
let { height = 40, beats = 6, coordWidth = 320, class: className = "" } = $props();
|
||||
|
||||
const mid = height / 2;
|
||||
const peak = height * 0.34;
|
||||
const N = 96;
|
||||
const uid = `wl-grad-${uidCounter++}`;
|
||||
|
||||
let svgEl;
|
||||
let pathEl;
|
||||
|
||||
const flat = `M0 ${mid} L${coordWidth} ${mid}`;
|
||||
|
||||
function buildPath(amp) {
|
||||
let d = `M0 ${mid}`;
|
||||
for (let i = 1; i <= N; i++) {
|
||||
const x = (i / N) * coordWidth;
|
||||
const envelope = Math.sin((i / N) * Math.PI); // 0 at the ends → flat edges
|
||||
const y = mid + Math.sin((i / N) * beats * Math.PI * 2) * amp * envelope;
|
||||
d += ` L${x.toFixed(2)} ${y.toFixed(2)}`;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (prefersReducedMotion()) return; // stays a flat line
|
||||
|
||||
let playing = false;
|
||||
// One 1.2s beat: amplitude rises (easeOut), then settles back to flat (easeInOut).
|
||||
const total = DURATION.slow * 1000 * 3; // ~1200ms
|
||||
const play = () => {
|
||||
if (playing) return;
|
||||
playing = true;
|
||||
let startTs = 0;
|
||||
const step = (now) => {
|
||||
if (!startTs) startTs = now;
|
||||
const t = Math.min(1, (now - startTs) / total);
|
||||
const amp = t < 0.5 ? peak * easeOut(t / 0.5) : peak * (1 - easeInOut((t - 0.5) / 0.5));
|
||||
pathEl.setAttribute("d", buildPath(amp));
|
||||
if (t < 1) {
|
||||
requestAnimationFrame(step);
|
||||
} else {
|
||||
pathEl.setAttribute("d", flat);
|
||||
playing = false;
|
||||
}
|
||||
};
|
||||
requestAnimationFrame(step);
|
||||
};
|
||||
|
||||
svgEl.addEventListener("pointerenter", play);
|
||||
const io = new IntersectionObserver(
|
||||
(entries) => {
|
||||
for (const e of entries) {
|
||||
if (e.isIntersecting) {
|
||||
play();
|
||||
io.disconnect();
|
||||
}
|
||||
}
|
||||
},
|
||||
{ threshold: 0.6 },
|
||||
);
|
||||
io.observe(svgEl);
|
||||
|
||||
return () => {
|
||||
io.disconnect();
|
||||
svgEl.removeEventListener("pointerenter", play);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<svg
|
||||
bind:this={svgEl}
|
||||
class={className}
|
||||
viewBox={`0 0 ${coordWidth} ${height}`}
|
||||
preserveAspectRatio="none"
|
||||
role="presentation"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<defs>
|
||||
<linearGradient id={uid} x1="0" y1="0" x2="1" y2="0">
|
||||
<stop class="s-line" offset="0%" />
|
||||
<stop class="s-line" offset="36%" />
|
||||
<stop class="s-accent" offset="50%" />
|
||||
<stop class="s-line" offset="64%" />
|
||||
<stop class="s-line" offset="100%" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path
|
||||
bind:this={pathEl}
|
||||
d={flat}
|
||||
fill="none"
|
||||
stroke={`url(#${uid})`}
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
vector-effect="non-scaling-stroke"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
svg {
|
||||
display: block;
|
||||
inline-size: 100%;
|
||||
block-size: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
/* stop-color via CSS so the theme vars resolve (presentation attrs don't parse var()). */
|
||||
.s-line {
|
||||
stop-color: var(--line);
|
||||
}
|
||||
.s-accent {
|
||||
stop-color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -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/<album>/
|
||||
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 };
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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ó.
|
||||
|
||||
<Callout type="tip" title="Mẹo nhỏ">
|
||||
Đừ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.
|
||||
</Callout>
|
||||
|
||||
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.
|
||||
@@ -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.
|
||||
@@ -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ì.
|
||||
@@ -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.
|
||||
@@ -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ọ.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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
|
||||
@@ -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).
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="astro/client" />
|
||||
/// <reference path="../worker-configuration.d.ts" />
|
||||
|
||||
// Cloudflare bindings (KV, ASSETS, SESSION) are typed in worker-configuration.d.ts
|
||||
// (generated by `wrangler types`) and accessed via `import { env } from "cloudflare:workers"`.
|
||||
+103
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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/<locale>/* 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("/")}`;
|
||||
}
|
||||
+102
@@ -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;
|
||||
@@ -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 <main> 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);
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang={lang} data-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
{/* Apply stored theme before first paint, and re-apply after View Transitions swaps. */}
|
||||
<script is:inline>
|
||||
(() => {
|
||||
const apply = () => {
|
||||
try {
|
||||
const t = localStorage.getItem("theme");
|
||||
if (t === "light" || t === "dark") document.documentElement.dataset.theme = t;
|
||||
} catch {}
|
||||
};
|
||||
apply();
|
||||
document.addEventListener("astro:after-swap", apply);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<title>{seo.title}</title>
|
||||
<meta name="description" content={seo.description} />
|
||||
<link rel="canonical" href={seo.canonical} />
|
||||
{seo.noindex && <meta name="robots" content="noindex, nofollow" />}
|
||||
|
||||
<meta name="theme-color" content={SITE.themeColor.dark} media="(prefers-color-scheme: dark)" />
|
||||
<meta
|
||||
name="theme-color"
|
||||
content={SITE.themeColor.light}
|
||||
media="(prefers-color-scheme: light)"
|
||||
/>
|
||||
|
||||
{/* Open Graph / Twitter */}
|
||||
<meta property="og:type" content={seo.type} />
|
||||
<meta property="og:site_name" content={SITE.name} />
|
||||
<meta property="og:title" content={seo.title} />
|
||||
<meta property="og:description" content={seo.description} />
|
||||
<meta property="og:url" content={seo.canonical} />
|
||||
<meta property="og:locale" content={lang === "vi" ? "vi_VN" : "en_US"} />
|
||||
{ogImage && <meta property="og:image" content={ogImage} />}
|
||||
<meta name="twitter:card" content={ogImage ? "summary_large_image" : "summary"} />
|
||||
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
|
||||
{
|
||||
/* 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. */
|
||||
}
|
||||
<Font cssVariable="--ff-display" preload />
|
||||
<Font cssVariable="--ff-body" />
|
||||
<Font cssVariable="--ff-mono" />
|
||||
{/* Literata loads only on long-form reading pages (keeps the base bundle lean). */}
|
||||
{reading && <Font cssVariable="--ff-reading" />}
|
||||
|
||||
<ClientRouter />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<SkipLink label={t.actions.skipToContent} />
|
||||
<Header />
|
||||
<main id="main" class={mainClass}>
|
||||
<slot />
|
||||
</main>
|
||||
<Footer />
|
||||
<MobileTabBar />
|
||||
<MenuSheet
|
||||
client:idle
|
||||
items={menuItems}
|
||||
legal={legalItems}
|
||||
title={t.nav.menu}
|
||||
closeLabel={t.nav.close}
|
||||
legalTitle={t.footer.legal}
|
||||
/>
|
||||
|
||||
{!onLegalPage && <LegalGateSheet client:idle strings={t.gate} links={legalItems} />}
|
||||
|
||||
<script>
|
||||
// Route every menu trigger (header hamburger + mobile tab "Menu") to the sheet.
|
||||
// One document-level listener; it survives View Transitions navigations.
|
||||
document.addEventListener("click", (e) => {
|
||||
const target = e.target;
|
||||
if (target instanceof Element && target.closest("[data-menu-trigger]")) {
|
||||
document.dispatchEvent(new CustomEvent("toggle-menu"));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,128 @@
|
||||
---
|
||||
import "../styles/global.css";
|
||||
import { Font } from "astro:assets";
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
/** Show the Home / Blog / Truyện links (hidden for 429 + offline). */
|
||||
showLinks?: boolean;
|
||||
}
|
||||
const { title, showLinks = true } = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang="vi" data-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<script is:inline>
|
||||
(() => {
|
||||
try {
|
||||
const t = localStorage.getItem("theme");
|
||||
if (t === "light" || t === "dark") document.documentElement.dataset.theme = t;
|
||||
} catch {}
|
||||
})();
|
||||
</script>
|
||||
<title>{title}</title>
|
||||
{/* Only the body font — no display/reading font, no islands (docs 09 §3.1). */}
|
||||
<Font cssVariable="--ff-body" preload />
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="err">
|
||||
<svg class="flatline" viewBox="0 0 320 24" preserveAspectRatio="none" aria-hidden="true">
|
||||
<defs>
|
||||
<linearGradient id="err-flat" x1="0" y1="0" x2="1" y2="0">
|
||||
<stop offset="0%" class="l"></stop>
|
||||
<stop offset="42%" class="l"></stop>
|
||||
<stop offset="50%" class="a"></stop>
|
||||
<stop offset="58%" class="l"></stop>
|
||||
<stop offset="100%" class="l"></stop>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<line
|
||||
x1="0"
|
||||
y1="12"
|
||||
x2="320"
|
||||
y2="12"
|
||||
stroke="url(#err-flat)"
|
||||
stroke-width="1.5"
|
||||
vector-effect="non-scaling-stroke"></line>
|
||||
</svg>
|
||||
|
||||
<slot />
|
||||
|
||||
{
|
||||
showLinks && (
|
||||
<nav class="err-nav" aria-label="Điều hướng lỗi">
|
||||
<a href="/">Trang chủ</a>
|
||||
<a href="/blog">Blog</a>
|
||||
<a href="/truyen">Truyện</a>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<style>
|
||||
.err {
|
||||
min-block-size: 100dvh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 1.25rem;
|
||||
text-align: center;
|
||||
padding: 2rem 1.25rem;
|
||||
max-inline-size: 40rem;
|
||||
margin-inline: auto;
|
||||
}
|
||||
.flatline {
|
||||
inline-size: min(20rem, 80vw);
|
||||
block-size: 24px;
|
||||
}
|
||||
.flatline .l {
|
||||
stop-color: var(--line);
|
||||
}
|
||||
.flatline .a {
|
||||
stop-color: var(--accent);
|
||||
}
|
||||
.err-nav {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
gap: 0.5rem 1.25rem;
|
||||
margin-block-start: 0.5rem;
|
||||
}
|
||||
.err-nav a {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.err-nav a:hover {
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
|
||||
/* Shared error-content styles (used by the slotted page content). */
|
||||
:global(.err h1) {
|
||||
font-family: var(--ff-body);
|
||||
font-weight: 600;
|
||||
font-size: var(--text-h2);
|
||||
line-height: 1.15;
|
||||
}
|
||||
:global(.err .en) {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
:global(.err .code) {
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
color: var(--muted);
|
||||
}
|
||||
:global(.err .ref) {
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,112 @@
|
||||
---
|
||||
import BaseLayout from "./BaseLayout.astro";
|
||||
import Prose from "../components/Prose.astro";
|
||||
import { useTranslations } from "../i18n";
|
||||
import { legalNav, isActivePath } from "../lib/nav";
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
description?: string;
|
||||
locale: Locale;
|
||||
effectiveDate?: string;
|
||||
}
|
||||
const { title, description, locale, effectiveDate } = Astro.props;
|
||||
const t = useTranslations(locale);
|
||||
const links = legalNav(locale);
|
||||
const pathname = Astro.url.pathname;
|
||||
const effectiveLabel = locale === "vi" ? "Hiệu lực" : "Effective";
|
||||
---
|
||||
|
||||
<BaseLayout {title} {description} {locale}>
|
||||
<div class="legal-wrap page">
|
||||
<aside class="legal-side">
|
||||
<p class="side-title">{t.footer.legal}</p>
|
||||
<ul>
|
||||
{
|
||||
links.map((l) => (
|
||||
<li>
|
||||
<a href={l.href} aria-current={isActivePath(pathname, l.href) ? "page" : undefined}>
|
||||
{l.label}
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<article class="legal-doc">
|
||||
<h1>{title}</h1>
|
||||
{
|
||||
effectiveDate && (
|
||||
<p class="effective">
|
||||
{effectiveLabel}: {effectiveDate}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
<Prose class="legal-body">
|
||||
<slot />
|
||||
</Prose>
|
||||
</article>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.legal-wrap {
|
||||
display: grid;
|
||||
gap: 2rem;
|
||||
padding-block: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
.legal-side {
|
||||
align-self: start;
|
||||
}
|
||||
.side-title {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-meta);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.08em;
|
||||
margin-block-end: 0.5rem;
|
||||
}
|
||||
.legal-side ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.25rem 1rem;
|
||||
}
|
||||
.legal-side a {
|
||||
color: var(--muted);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
.legal-side a:hover,
|
||||
.legal-side a[aria-current="page"] {
|
||||
color: var(--accent);
|
||||
}
|
||||
.legal-doc h1 {
|
||||
font-size: var(--text-h1);
|
||||
}
|
||||
.effective {
|
||||
margin-block-start: 0.5rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.legal-body {
|
||||
margin-block-start: 1.75rem;
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
.legal-wrap {
|
||||
grid-template-columns: 14rem 1fr;
|
||||
gap: 3rem;
|
||||
}
|
||||
.legal-side {
|
||||
position: sticky;
|
||||
inset-block-start: 5rem;
|
||||
}
|
||||
.legal-side ul {
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,183 @@
|
||||
---
|
||||
import { Image } from "astro:assets";
|
||||
import BaseLayout from "./BaseLayout.astro";
|
||||
import Prose from "../components/Prose.astro";
|
||||
import Waveline from "../components/Waveline.svelte";
|
||||
import TagPill from "../components/TagPill.astro";
|
||||
import Pagination from "../components/Pagination.astro";
|
||||
import type { BlogEntry } from "../lib/collections";
|
||||
import { useTranslations } from "../i18n";
|
||||
import { sectionPath, type Locale } from "../i18n/routing";
|
||||
import { formatDate, isoDate } from "../lib/format";
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: BlogEntry;
|
||||
locale: Locale;
|
||||
readingMins: number;
|
||||
translationHref?: string | null;
|
||||
prev?: NavLink | null;
|
||||
next?: NavLink | null;
|
||||
}
|
||||
const {
|
||||
entry,
|
||||
locale,
|
||||
readingMins,
|
||||
translationHref = null,
|
||||
prev = null,
|
||||
next = null,
|
||||
} = Astro.props;
|
||||
const t = useTranslations(locale);
|
||||
const { title, description, date, updated, tags, cover } = entry.data;
|
||||
const blogHref = sectionPath("blog", locale);
|
||||
---
|
||||
|
||||
<BaseLayout {title} {description} {locale} type="article" reading>
|
||||
<article class="reading-column post">
|
||||
<nav class="breadcrumb" aria-label="Breadcrumb">
|
||||
<a href={blogHref}>{t.nav.blog}</a>
|
||||
<span aria-hidden="true">/</span>
|
||||
<span class="current">{title}</span>
|
||||
</nav>
|
||||
|
||||
<header class="post-header">
|
||||
<h1>{title}</h1>
|
||||
<div class="post-meta">
|
||||
<time datetime={isoDate(date)}>{formatDate(date, locale)}</time>
|
||||
<span aria-hidden="true">·</span>
|
||||
<span>{readingMins} {t.post.minRead}</span>
|
||||
{
|
||||
updated && (
|
||||
<Fragment>
|
||||
<span aria-hidden="true">·</span>
|
||||
<span>
|
||||
{t.post.updated} {formatDate(updated, locale)}
|
||||
</span>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
{
|
||||
tags.length > 0 && (
|
||||
<div class="post-tags">
|
||||
{tags.map((tag) => (
|
||||
<TagPill {tag} {locale} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
translationHref && (
|
||||
<a class="translation" href={translationHref}>
|
||||
{t.post.readOther} →
|
||||
</a>
|
||||
)
|
||||
}
|
||||
</header>
|
||||
|
||||
{
|
||||
cover && (
|
||||
<div class="post-cover">
|
||||
<Image
|
||||
src={cover}
|
||||
alt=""
|
||||
widths={[720, 1080, 1440]}
|
||||
sizes="(max-width: 768px) 100vw, 720px"
|
||||
fetchpriority="high"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
<Prose class="post-body">
|
||||
<slot />
|
||||
</Prose>
|
||||
|
||||
<footer class="post-foot">
|
||||
<Waveline client:visible height={36} />
|
||||
<Pagination
|
||||
{prev}
|
||||
{next}
|
||||
prevText={t.post.prev}
|
||||
nextText={t.post.next}
|
||||
ariaLabel="Post navigation"
|
||||
/>
|
||||
</footer>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.reading-column {
|
||||
max-inline-size: 46rem;
|
||||
margin-inline: auto;
|
||||
padding-inline: clamp(1rem, 4vw, 2rem);
|
||||
padding-block: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
.breadcrumb {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.breadcrumb a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.breadcrumb .current {
|
||||
color: var(--text);
|
||||
opacity: 0.7;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-inline-size: 20ch;
|
||||
}
|
||||
.post-header {
|
||||
margin-block: 1.25rem 1.5rem;
|
||||
}
|
||||
.post-header h1 {
|
||||
font-size: var(--text-h1);
|
||||
line-height: 1.1;
|
||||
}
|
||||
.post-meta {
|
||||
margin-block-start: 0.75rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.post-tags {
|
||||
margin-block-start: 0.9rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.translation {
|
||||
display: inline-block;
|
||||
margin-block-start: 0.9rem;
|
||||
color: var(--accent);
|
||||
font-size: var(--text-meta);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.post-cover {
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
.post-cover :global(img) {
|
||||
inline-size: 100%;
|
||||
block-size: auto;
|
||||
border-radius: var(--radius-card);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.post-foot {
|
||||
margin-block-start: 3rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,128 @@
|
||||
---
|
||||
import BaseLayout from "./BaseLayout.astro";
|
||||
import Prose from "../components/Prose.astro";
|
||||
import Waveline from "../components/Waveline.svelte";
|
||||
import type { ProjectEntry } from "../lib/collections";
|
||||
import { sectionPath, type Locale } from "../i18n/routing";
|
||||
import { useTranslations } from "../i18n";
|
||||
|
||||
interface Props {
|
||||
entry: ProjectEntry;
|
||||
locale: Locale;
|
||||
}
|
||||
const { entry, locale } = Astro.props;
|
||||
const t = useTranslations(locale);
|
||||
const { name, tagline, stack, repo, url, status, year } = entry.data;
|
||||
|
||||
const statusLabel = {
|
||||
active: locale === "vi" ? "Đang phát triển" : "Active",
|
||||
maintained: locale === "vi" ? "Bảo trì" : "Maintained",
|
||||
archived: locale === "vi" ? "Lưu trữ" : "Archived",
|
||||
}[status];
|
||||
---
|
||||
|
||||
<BaseLayout title={name} description={tagline} {locale}>
|
||||
<article class="proj">
|
||||
<p class="crumb">
|
||||
<a href={sectionPath("projects", locale)}>{t.nav.projects}</a> / {name}
|
||||
</p>
|
||||
<h1>{name}</h1>
|
||||
<p class="tagline">{tagline}</p>
|
||||
<div class="facts">
|
||||
<span class="year">{year}</span>
|
||||
<span class="status">{statusLabel}</span>
|
||||
</div>
|
||||
{
|
||||
stack.length > 0 && (
|
||||
<ul class="stack">
|
||||
{stack.map((s) => (
|
||||
<li>{s}</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
{
|
||||
(repo || url) && (
|
||||
<div class="links">
|
||||
{repo && (
|
||||
<a href={repo} target="_blank" rel="noopener noreferrer">
|
||||
repo ↗
|
||||
</a>
|
||||
)}
|
||||
{url && (
|
||||
<a href={url} target="_blank" rel="noopener noreferrer">
|
||||
site ↗
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<div class="wave"><Waveline client:visible height={30} /></div>
|
||||
<Prose>
|
||||
<slot />
|
||||
</Prose>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.proj {
|
||||
max-inline-size: 46rem;
|
||||
margin-inline: auto;
|
||||
padding-inline: clamp(1rem, 4vw, 2rem);
|
||||
padding-block: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
.crumb {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.crumb a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
h1 {
|
||||
margin-block-start: 0.75rem;
|
||||
font-size: var(--text-h1);
|
||||
}
|
||||
.tagline {
|
||||
margin-block-start: 0.5rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
.facts {
|
||||
margin-block-start: 1rem;
|
||||
display: flex;
|
||||
gap: 0.75rem;
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.stack {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin-block-start: 1rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
.stack li {
|
||||
padding: 0.15em 0.6em;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--line);
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.links {
|
||||
margin-block-start: 1rem;
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
}
|
||||
.links a {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.wave {
|
||||
margin-block: 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,203 @@
|
||||
---
|
||||
import BaseLayout from "./BaseLayout.astro";
|
||||
import Prose from "../components/Prose.astro";
|
||||
import Waveline from "../components/Waveline.svelte";
|
||||
import ContentWarning from "../components/ContentWarning.astro";
|
||||
import ReadingControls from "../components/ReadingControls.svelte";
|
||||
import Pagination from "../components/Pagination.astro";
|
||||
import type { StoryEntry } from "../lib/collections";
|
||||
import { useTranslations } from "../i18n";
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: StoryEntry;
|
||||
locale: Locale;
|
||||
seriesHref?: string | null;
|
||||
seriesTocHref?: string | null;
|
||||
prev?: NavLink | null;
|
||||
next?: NavLink | null;
|
||||
translationHref?: string | null;
|
||||
}
|
||||
const {
|
||||
entry,
|
||||
locale,
|
||||
seriesHref = null,
|
||||
seriesTocHref = null,
|
||||
prev = null,
|
||||
next = null,
|
||||
} = Astro.props;
|
||||
const t = useTranslations(locale);
|
||||
const { title, description, series, contentWarning } = entry.data;
|
||||
const hasCW = contentWarning.length > 0;
|
||||
---
|
||||
|
||||
<BaseLayout {title} {description} {locale} type="article" reading>
|
||||
{/* Sticky reader bar. The "Aa" reading controls trigger is added in M5. */}
|
||||
<div class="reader-bar">
|
||||
<a class="back" href={seriesHref ?? seriesTocHref ?? "#"}>
|
||||
← <span>{series ?? t.nav.stories}</span>
|
||||
</a>
|
||||
<span class="chapter-title">{title}</span>
|
||||
<ReadingControls client:idle labels={t.reader} />
|
||||
</div>
|
||||
|
||||
<article id="reader-root" class="reading-column reader">
|
||||
<header class="reader-head">
|
||||
{series && <p class="series">{series}</p>}
|
||||
<h1>{title}</h1>
|
||||
</header>
|
||||
|
||||
{
|
||||
hasCW ? (
|
||||
<ContentWarning warnings={contentWarning} title={t.story.cwTitle} hint={t.story.cwHint}>
|
||||
<Prose reader>
|
||||
<slot />
|
||||
</Prose>
|
||||
</ContentWarning>
|
||||
) : (
|
||||
<Prose reader>
|
||||
<slot />
|
||||
</Prose>
|
||||
)
|
||||
}
|
||||
|
||||
<footer class="reader-foot">
|
||||
<Waveline client:visible height={36} />
|
||||
<Pagination
|
||||
{prev}
|
||||
{next}
|
||||
prevText={t.post.prev}
|
||||
nextText={t.post.next}
|
||||
ariaLabel="Chapter navigation"
|
||||
/>
|
||||
{
|
||||
seriesTocHref && (
|
||||
<a class="toc-link" href={seriesTocHref}>
|
||||
{t.story.seriesToc}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
</footer>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.reader-bar {
|
||||
position: sticky;
|
||||
inset-block-start: 0;
|
||||
z-index: 30;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 0.6rem clamp(1rem, 4vw, 2rem);
|
||||
background: color-mix(in srgb, var(--bg) 88%, transparent);
|
||||
backdrop-filter: blur(8px);
|
||||
border-block-end: 1px solid var(--line);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.reader-bar .back {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
color: var(--muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
.reader-bar .back:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.chapter-title {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
color: var(--text);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.reader-controls-slot {
|
||||
inline-size: 2.5rem;
|
||||
}
|
||||
|
||||
.reading-column {
|
||||
max-inline-size: 46rem;
|
||||
margin-inline: auto;
|
||||
padding-inline: clamp(1rem, 4vw, 2rem);
|
||||
padding-block: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
|
||||
/* Text size — drives --reader-fs, inherited by the reader Prose. */
|
||||
.reader {
|
||||
--reader-fs: clamp(1.125rem, 1.05rem + 0.32vw, 1.25rem);
|
||||
}
|
||||
.reader[data-reader-size="s"] {
|
||||
--reader-fs: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
|
||||
}
|
||||
.reader[data-reader-size="l"] {
|
||||
--reader-fs: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
|
||||
}
|
||||
|
||||
/* Reader background — independent of the site theme (redefines the local palette). */
|
||||
.reader[data-reader-theme] {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
margin-block: 1rem 2rem;
|
||||
}
|
||||
.reader[data-reader-theme="paper"] {
|
||||
--bg: #f5efe2;
|
||||
--surface: #fffdf7;
|
||||
--elevated: #ffffff;
|
||||
--line: #e2d9c5;
|
||||
--text: #26221a;
|
||||
--muted: #6e6757;
|
||||
--accent: #9a6414;
|
||||
}
|
||||
.reader[data-reader-theme="sepia"] {
|
||||
--bg: #f2e6cf;
|
||||
--surface: #f8efdb;
|
||||
--elevated: #fbf3e0;
|
||||
--line: #dcc9a0;
|
||||
--text: #3a2f1d;
|
||||
--muted: #6b5a3d;
|
||||
--accent: #8a5a12;
|
||||
}
|
||||
.reader[data-reader-theme="dark"] {
|
||||
--bg: #0d1117;
|
||||
--surface: #12161f;
|
||||
--elevated: #1a2030;
|
||||
--line: #242b38;
|
||||
--text: #e9e4d8;
|
||||
--muted: #98a0ae;
|
||||
--accent: #e8a33d;
|
||||
}
|
||||
.reader-head {
|
||||
margin-block-end: 1.75rem;
|
||||
text-align: center;
|
||||
}
|
||||
.series {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.reader-head h1 {
|
||||
margin-block-start: 0.35rem;
|
||||
font-size: var(--text-h1);
|
||||
line-height: 1.12;
|
||||
}
|
||||
.reader-foot {
|
||||
margin-block-start: 3rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
.toc-link {
|
||||
align-self: center;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,104 @@
|
||||
import { getCollection, type CollectionEntry } from "astro:content";
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
export type BlogEntry = CollectionEntry<"blog">;
|
||||
export type StoryEntry = CollectionEntry<"stories">;
|
||||
export type ProjectEntry = CollectionEntry<"projects">;
|
||||
export type FaqEntry = CollectionEntry<"faq">;
|
||||
|
||||
/** Drafts are visible in `astro dev` but excluded from production builds. */
|
||||
const INCLUDE_DRAFTS = import.meta.env.DEV;
|
||||
|
||||
function byDateDesc(a: { data: { date: Date } }, b: { data: { date: Date } }): number {
|
||||
return b.data.date.getTime() - a.data.date.getTime();
|
||||
}
|
||||
|
||||
export async function getBlogPosts(locale: Locale): Promise<BlogEntry[]> {
|
||||
const posts = await getCollection(
|
||||
"blog",
|
||||
({ data }) => (INCLUDE_DRAFTS || !data.draft) && data.lang === locale,
|
||||
);
|
||||
return posts.sort(byDateDesc);
|
||||
}
|
||||
|
||||
export async function getStoryChapters(locale: Locale): Promise<StoryEntry[]> {
|
||||
const chapters = await getCollection(
|
||||
"stories",
|
||||
({ data }) => (INCLUDE_DRAFTS || !data.draft) && data.lang === locale,
|
||||
);
|
||||
return chapters.sort(byDateDesc);
|
||||
}
|
||||
|
||||
export async function getProjects(locale: Locale): Promise<ProjectEntry[]> {
|
||||
const projects = await getCollection(
|
||||
"projects",
|
||||
({ data }) => (INCLUDE_DRAFTS || !data.draft) && data.lang === locale,
|
||||
);
|
||||
// Featured first, then newest year.
|
||||
return projects.sort(
|
||||
(a, b) => Number(b.data.featured) - Number(a.data.featured) || b.data.year - a.data.year,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getFaqs(locale: Locale): Promise<FaqEntry[]> {
|
||||
const faqs = await getCollection("faq", ({ data }) => data.lang === locale);
|
||||
return faqs.sort((a, b) => a.data.order - b.data.order);
|
||||
}
|
||||
|
||||
export type MixedItem = { kind: "blog"; entry: BlogEntry } | { kind: "story"; entry: StoryEntry };
|
||||
|
||||
/** Newest blog + story items merged, for the homepage "recently written" strip. */
|
||||
export async function getLatestMixed(locale: Locale, limit = 3): Promise<MixedItem[]> {
|
||||
const [blog, stories] = await Promise.all([getBlogPosts(locale), getStoryChapters(locale)]);
|
||||
const merged: MixedItem[] = [
|
||||
...blog.map((entry) => ({ kind: "blog" as const, entry })),
|
||||
...stories.map((entry) => ({ kind: "story" as const, entry })),
|
||||
];
|
||||
merged.sort((a, b) => b.entry.data.date.getTime() - a.entry.data.date.getTime());
|
||||
return merged.slice(0, limit);
|
||||
}
|
||||
|
||||
/** Estimated reading time in minutes (~200 wpm; fine for both vi and en). */
|
||||
export function readingTime(body: string | undefined): number {
|
||||
if (!body) return 1;
|
||||
const words = body.trim().split(/\s+/).filter(Boolean).length;
|
||||
return Math.max(1, Math.round(words / 200));
|
||||
}
|
||||
|
||||
/** Unique tags with counts, most frequent first. */
|
||||
export function collectTags(entries: { data: { tags: string[] } }[]): {
|
||||
tag: string;
|
||||
count: number;
|
||||
}[] {
|
||||
const counts = new Map<string, number>();
|
||||
for (const entry of entries) {
|
||||
for (const tag of entry.data.tags) counts.set(tag, (counts.get(tag) ?? 0) + 1);
|
||||
}
|
||||
return [...counts.entries()]
|
||||
.map(([tag, count]) => ({ tag, count }))
|
||||
.sort((a, b) => b.count - a.count || a.tag.localeCompare(b.tag));
|
||||
}
|
||||
|
||||
type Translatable = "blog" | "stories" | "projects";
|
||||
|
||||
/** The counterpart entry in the other locale, matched by translationKey (or null). */
|
||||
export async function findTranslation<C extends Translatable>(
|
||||
collection: C,
|
||||
entry: CollectionEntry<C>,
|
||||
): Promise<CollectionEntry<C> | null> {
|
||||
const data = entry.data as { translationKey?: string; lang: Locale };
|
||||
if (!data.translationKey) return null;
|
||||
const otherLang: Locale = data.lang === "vi" ? "en" : "vi";
|
||||
const matches = await getCollection(collection, ({ data: d }) => {
|
||||
const dd = d as { translationKey?: string; lang: Locale };
|
||||
return dd.translationKey === data.translationKey && dd.lang === otherLang;
|
||||
});
|
||||
return (matches[0] as CollectionEntry<C>) ?? null;
|
||||
}
|
||||
|
||||
/** Split a stories entry id ("series-slug/chapter-slug" or "one-shot") into parts. */
|
||||
export function parseStoryId(id: string): { series: string | null; slug: string } {
|
||||
const parts = id.split("/");
|
||||
if (parts.length >= 2) return { series: parts[0], slug: parts.slice(1).join("/") };
|
||||
return { series: null, slug: id };
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
const MONTHS_EN = [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec",
|
||||
];
|
||||
|
||||
/** Deterministic, locale-aware date label (UTC-based — no Intl locale-data dependency). */
|
||||
export function formatDate(date: Date, locale: Locale): string {
|
||||
const d = date.getUTCDate();
|
||||
const m = date.getUTCMonth();
|
||||
const y = date.getUTCFullYear();
|
||||
return locale === "vi" ? `${d} thg ${m + 1}, ${y}` : `${MONTHS_EN[m]} ${d}, ${y}`;
|
||||
}
|
||||
|
||||
/** YYYY-MM-DD for <time datetime>. */
|
||||
export function isoDate(date: Date): string {
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
export interface SocialLink {
|
||||
name: string;
|
||||
href: string;
|
||||
desc: Record<Locale, string>;
|
||||
/** rel="me" for identity verification (Mastodon). */
|
||||
me?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Social + community links. Only GitHub + contact email are confirmed; the rest are
|
||||
* placeholders (`#`) to be filled with real URLs at launch (docs 15 P4).
|
||||
*/
|
||||
export const SOCIAL_LINKS: SocialLink[] = [
|
||||
{
|
||||
name: "YouTube — SkullMute",
|
||||
href: "#",
|
||||
desc: {
|
||||
vi: "Kênh chính: game, visual novel, indie/psychological horror.",
|
||||
en: "Main channel: games, visual novels, indie/psychological horror.",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "GitHub — poli0981",
|
||||
href: "https://github.com/poli0981",
|
||||
desc: { vi: "Mã nguồn & dự án mở.", en: "Source code & open projects." },
|
||||
},
|
||||
{
|
||||
name: "Discord — Gaming",
|
||||
href: "#",
|
||||
desc: {
|
||||
vi: "Cộng đồng xem stream & chơi cùng.",
|
||||
en: "Community for streams & co-op.",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Discord — Repo",
|
||||
href: "#",
|
||||
desc: { vi: "Báo lỗi site & thảo luận dev.", en: "Site bug reports & dev talk." },
|
||||
},
|
||||
{
|
||||
name: "Telegram",
|
||||
href: "#",
|
||||
desc: { vi: "Cập nhật ngắn.", en: "Short updates." },
|
||||
},
|
||||
{
|
||||
name: "Bluesky",
|
||||
href: "#",
|
||||
desc: { vi: "Bài viết ngắn.", en: "Short posts." },
|
||||
},
|
||||
{
|
||||
name: "Mastodon",
|
||||
href: "#",
|
||||
me: true,
|
||||
desc: { vi: "Fediverse (đã xác minh).", en: "Fediverse (verified)." },
|
||||
},
|
||||
{
|
||||
name: "X",
|
||||
href: "#",
|
||||
desc: { vi: "Cập nhật ngắn.", en: "Short updates." },
|
||||
},
|
||||
{
|
||||
name: "Facebook Page",
|
||||
href: "#",
|
||||
desc: { vi: "Trang chính thức.", en: "Official page." },
|
||||
},
|
||||
{
|
||||
name: "contact@poli0981.dev",
|
||||
href: "mailto:contact@poli0981.dev",
|
||||
desc: { vi: "Liên hệ công việc.", en: "Business enquiries." },
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Motion tokens (docs 03 §6) shared by GSAP islands and CSS.
|
||||
* GSAP itself is always dynamically imported inside the island that needs it —
|
||||
* never import it from here, so it stays out of shared bundles.
|
||||
*/
|
||||
|
||||
/** Durations in seconds; CSS mirrors these as ms tokens (--duration-*). */
|
||||
export const DURATION = {
|
||||
fast: 0.15,
|
||||
base: 0.25,
|
||||
slow: 0.4,
|
||||
} as const;
|
||||
|
||||
/** True when the visitor asked for reduced motion — every island must branch on this. */
|
||||
export function prefersReducedMotion(): boolean {
|
||||
return (
|
||||
typeof window !== "undefined" &&
|
||||
typeof window.matchMedia === "function" &&
|
||||
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
import { sectionPath, type Locale } from "../i18n/routing";
|
||||
import { useTranslations } from "../i18n";
|
||||
|
||||
export interface NavItem {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Nav definitions live here so Header, MobileTabBar, MenuSheet, and Footer stay in sync.
|
||||
* P1 scope: only pages that exist. Gaming / Gallery / Dev join when their pages ship.
|
||||
*/
|
||||
|
||||
export function primaryNav(locale: Locale): NavItem[] {
|
||||
const t = useTranslations(locale);
|
||||
return [
|
||||
{ href: sectionPath("blog", locale), label: t.nav.blog },
|
||||
{ href: sectionPath("stories", locale), label: t.nav.stories },
|
||||
{ href: sectionPath("projects", locale), label: t.nav.projects },
|
||||
{ href: sectionPath("about", locale), label: t.nav.about },
|
||||
];
|
||||
}
|
||||
|
||||
/** Everything the mobile menu sheet lists (primary + secondary pages). */
|
||||
export function menuNav(locale: Locale): NavItem[] {
|
||||
const t = useTranslations(locale);
|
||||
return [
|
||||
...primaryNav(locale),
|
||||
{ href: sectionPath("qa", locale), label: t.nav.qa },
|
||||
{ href: sectionPath("links", locale), label: t.nav.links },
|
||||
];
|
||||
}
|
||||
|
||||
export function legalNav(locale: Locale): NavItem[] {
|
||||
const t = useTranslations(locale);
|
||||
return [
|
||||
{ href: sectionPath("legal", locale, "terms"), label: t.legal.terms },
|
||||
{ href: sectionPath("legal", locale, "privacy"), label: t.legal.privacy },
|
||||
{ href: sectionPath("legal", locale, "disclaimer"), label: t.legal.disclaimer },
|
||||
{ href: sectionPath("legal", locale, "third-party"), label: t.legal.thirdParty },
|
||||
{ href: sectionPath("legal", locale, "licenses"), label: t.legal.licenses },
|
||||
];
|
||||
}
|
||||
|
||||
/** Marks a nav item active for the current path (exact or as a section prefix). */
|
||||
export function isActivePath(pathname: string, href: string): boolean {
|
||||
if (href === "/" || href === "/en/") return pathname === href;
|
||||
return pathname === href || pathname.startsWith(href + "/");
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import {
|
||||
getBlogPosts,
|
||||
getStoryChapters,
|
||||
getProjects,
|
||||
parseStoryId,
|
||||
type BlogEntry,
|
||||
type StoryEntry,
|
||||
} from "./collections";
|
||||
import { sectionPath, type Locale } from "../i18n/routing";
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const storyHref = (locale: Locale, entry: StoryEntry) =>
|
||||
sectionPath("stories", locale, ...entry.id.split("/"));
|
||||
|
||||
interface StoryChapterPath {
|
||||
params: { series: string; slug: string };
|
||||
props: {
|
||||
entry: StoryEntry;
|
||||
prev: NavLink | null;
|
||||
next: NavLink | null;
|
||||
seriesTocHref: string;
|
||||
};
|
||||
}
|
||||
|
||||
/** getStaticPaths for blog post detail pages, with prev/next (older/newer) links. */
|
||||
export async function blogPostPaths(locale: Locale) {
|
||||
const posts = await getBlogPosts(locale);
|
||||
return posts.map((entry, i) => {
|
||||
const newer = posts[i - 1]; // list is newest-first
|
||||
const older = posts[i + 1];
|
||||
const linkTo = (p: BlogEntry): NavLink => ({
|
||||
href: sectionPath("blog", locale, p.id),
|
||||
label: p.data.title,
|
||||
});
|
||||
return {
|
||||
params: { slug: entry.id },
|
||||
props: {
|
||||
entry,
|
||||
prev: older ? linkTo(older) : null, // "prev" = older post
|
||||
next: newer ? linkTo(newer) : null, // "next" = newer post
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** getStaticPaths for blog tag pages. */
|
||||
export async function blogTagPaths(locale: Locale) {
|
||||
const posts = await getBlogPosts(locale);
|
||||
const tags = [...new Set(posts.flatMap((p) => p.data.tags))];
|
||||
return tags.map((tag) => ({
|
||||
params: { tag },
|
||||
props: { tag, posts: posts.filter((p) => p.data.tags.includes(tag)) },
|
||||
}));
|
||||
}
|
||||
|
||||
/** getStaticPaths for project detail pages. */
|
||||
export async function projectPaths(locale: Locale) {
|
||||
const projects = await getProjects(locale);
|
||||
return projects.map((entry) => ({ params: { slug: entry.id }, props: { entry } }));
|
||||
}
|
||||
|
||||
/**
|
||||
* getStaticPaths for story chapter reader pages (/truyen/[series]/[slug]).
|
||||
* Only chapters that live in a series folder produce routes; prev/next walk the
|
||||
* chapter order within the same series.
|
||||
*/
|
||||
export async function storyChapterPaths(locale: Locale) {
|
||||
const all = await getStoryChapters(locale);
|
||||
const bySeries = new Map<string, StoryEntry[]>();
|
||||
for (const chapter of all) {
|
||||
const { series } = parseStoryId(chapter.id);
|
||||
if (!series) continue; // one-shots without a series folder are skipped for this route
|
||||
const existing = bySeries.get(series);
|
||||
if (existing) existing.push(chapter);
|
||||
else bySeries.set(series, [chapter]);
|
||||
}
|
||||
|
||||
const paths: StoryChapterPath[] = [];
|
||||
for (const [series, list] of bySeries) {
|
||||
list.sort(
|
||||
(a, b) =>
|
||||
(a.data.chapter ?? 0) - (b.data.chapter ?? 0) ||
|
||||
a.data.date.getTime() - b.data.date.getTime(),
|
||||
);
|
||||
list.forEach((entry, i) => {
|
||||
const { slug } = parseStoryId(entry.id);
|
||||
const earlier = list[i - 1];
|
||||
const later = list[i + 1];
|
||||
paths.push({
|
||||
params: { series, slug },
|
||||
props: {
|
||||
entry,
|
||||
prev: earlier ? { href: storyHref(locale, earlier), label: earlier.data.title } : null,
|
||||
next: later ? { href: storyHref(locale, later), label: later.data.title } : null,
|
||||
seriesTocHref: sectionPath("stories", locale),
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/** Site-wide identity + SEO helpers (docs 13). */
|
||||
import type { Locale } from "../i18n/routing";
|
||||
|
||||
export const SITE = {
|
||||
url: "https://poli0981.dev",
|
||||
name: "poli0981.dev",
|
||||
author: "Kokone (SkullMute)",
|
||||
defaultDescription: {
|
||||
vi: "Trang cá nhân của Kokone — dev, người viết, và kênh SkullMute.",
|
||||
en: "Kokone's personal site — dev, storyteller, and the SkullMute channel.",
|
||||
},
|
||||
themeColor: {
|
||||
dark: "#0d1117",
|
||||
light: "#f5efe2",
|
||||
},
|
||||
} as const;
|
||||
|
||||
/** `<title>` text. Homepage gets the signature line; other pages are "Name — poli0981.dev". */
|
||||
function pageTitle(title?: string): string {
|
||||
return title ? `${title} — ${SITE.name}` : "Kokone (SkullMute) — dev & storyteller";
|
||||
}
|
||||
|
||||
/** Absolute canonical URL for a pathname (leading slash expected). */
|
||||
function canonical(pathname: string): string {
|
||||
return new URL(pathname, SITE.url).href;
|
||||
}
|
||||
|
||||
export interface SeoInput {
|
||||
title?: string;
|
||||
description?: string;
|
||||
locale?: Locale;
|
||||
/** Absolute or root-relative OG image URL (defaults handled at render time). */
|
||||
image?: string;
|
||||
type?: "website" | "article";
|
||||
noindex?: boolean;
|
||||
}
|
||||
|
||||
export interface ResolvedSeo {
|
||||
title: string;
|
||||
description: string;
|
||||
canonical: string;
|
||||
locale: Locale;
|
||||
type: "website" | "article";
|
||||
noindex: boolean;
|
||||
image?: string;
|
||||
}
|
||||
|
||||
/** Resolve raw page inputs + the current URL into the values BaseLayout renders. */
|
||||
export function resolveSeo(input: SeoInput, pathname: string): ResolvedSeo {
|
||||
const locale: Locale = input.locale ?? "vi";
|
||||
return {
|
||||
title: pageTitle(input.title),
|
||||
description: input.description ?? SITE.defaultDescription[locale],
|
||||
canonical: canonical(pathname),
|
||||
locale,
|
||||
type: input.type ?? "website",
|
||||
noindex: input.noindex ?? false,
|
||||
image: input.image,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
import { defineMiddleware } from "astro:middleware";
|
||||
import { env } from "cloudflare:workers";
|
||||
|
||||
const RATE_LIMIT = 5; // requests per window per IP on /api/*
|
||||
const WINDOW_SECONDS = 60;
|
||||
|
||||
export const onRequest = defineMiddleware(async (context, next) => {
|
||||
const { request, url } = context;
|
||||
|
||||
// www → apex (301).
|
||||
if (url.hostname.startsWith("www.")) {
|
||||
const apex = new URL(url);
|
||||
apex.hostname = url.hostname.slice(4);
|
||||
return context.redirect(apex.toString(), 301);
|
||||
}
|
||||
|
||||
const ip = request.headers.get("cf-connecting-ip") ?? "0.0.0.0";
|
||||
// Bindings may be absent under plain `astro dev`; guard so the build/prerender is safe.
|
||||
const kv = env.KV as KVNamespace | undefined;
|
||||
const assets = env.ASSETS as Fetcher | undefined;
|
||||
|
||||
// Serve a prerendered error page via ASSETS, preserving the HTTP status.
|
||||
const serveError = async (path: string, status: number): Promise<Response> => {
|
||||
if (assets) {
|
||||
const res = await assets.fetch(new URL(path, url));
|
||||
return new Response(res.body, { status, headers: res.headers });
|
||||
}
|
||||
return context.rewrite(path);
|
||||
};
|
||||
|
||||
// Denylist → custom 403.
|
||||
if (kv) {
|
||||
const denied = await kv.get(`denylist:${ip}`);
|
||||
if (denied !== null) return serveError("/403", 403);
|
||||
}
|
||||
|
||||
// Soft rate-limit on /api/* → custom 429 + Retry-After. (The hard limit is a
|
||||
// Cloudflare zone rule; KV is eventually-consistent, so this is best-effort.)
|
||||
if (url.pathname.startsWith("/api/") && kv) {
|
||||
const key = `rl:${ip}`;
|
||||
const current = Number((await kv.get(key)) ?? "0");
|
||||
if (current >= RATE_LIMIT) {
|
||||
const res = await serveError("/429", 429);
|
||||
res.headers.set("Retry-After", String(WINDOW_SECONDS));
|
||||
return res;
|
||||
}
|
||||
await kv.put(key, String(current + 1), { expirationTtl: WINDOW_SECONDS });
|
||||
}
|
||||
|
||||
const response = await next();
|
||||
|
||||
// Non-CSP security headers (docs 06 §1.1). The CSP itself is delivered per-page as a
|
||||
// <meta> tag by Astro — do NOT set a Content-Security-Policy header here or it would
|
||||
// clobber the per-page script/style hashes. frame-ancestors isn't enforceable in meta,
|
||||
// so framing is blocked with X-Frame-Options instead.
|
||||
const h = response.headers;
|
||||
h.set("X-Content-Type-Options", "nosniff");
|
||||
h.set("Referrer-Policy", "strict-origin-when-cross-origin");
|
||||
h.set("Permissions-Policy", "camera=(), microphone=(), geolocation=(), payment=(), usb=()");
|
||||
h.set("Cross-Origin-Opener-Policy", "same-origin");
|
||||
h.set("X-Frame-Options", "DENY");
|
||||
h.set("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
|
||||
|
||||
return response;
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
import ErrorLayout from "@/layouts/ErrorLayout.astro";
|
||||
---
|
||||
|
||||
<ErrorLayout title="403 — poli0981.dev">
|
||||
<p class="code">403</p>
|
||||
<h1>Cửa này đang khoá.</h1>
|
||||
<p class="en">This door is locked.</p>
|
||||
<p class="code">Nếu bạn nghĩ đây là nhầm lẫn — contact@poli0981.dev</p>
|
||||
</ErrorLayout>
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
import ErrorLayout from "@/layouts/ErrorLayout.astro";
|
||||
import { getLatestMixed } from "@/lib/collections";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const latest = await getLatestMixed("vi", 3);
|
||||
const linkFor = (item: (typeof latest)[number]) =>
|
||||
item.kind === "blog"
|
||||
? sectionPath("blog", "vi", item.entry.id)
|
||||
: sectionPath("stories", "vi", ...item.entry.id.split("/"));
|
||||
---
|
||||
|
||||
<ErrorLayout title="404 — poli0981.dev">
|
||||
<p class="code">404</p>
|
||||
<h1>Trang này không phát ra tín hiệu.</h1>
|
||||
<p class="en">This page makes no sound.</p>
|
||||
|
||||
{
|
||||
latest.length > 0 && (
|
||||
<ul class="recent">
|
||||
{latest.map((item) => (
|
||||
<li>
|
||||
<a href={linkFor(item)}>{item.entry.data.title}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
</ErrorLayout>
|
||||
|
||||
<style>
|
||||
.recent {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0.5rem 0 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.recent a {
|
||||
color: var(--text);
|
||||
}
|
||||
.recent a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,21 @@
|
||||
---
|
||||
import ErrorLayout from "@/layouts/ErrorLayout.astro";
|
||||
---
|
||||
|
||||
<ErrorLayout title="429 — poli0981.dev" showLinks={false}>
|
||||
<p class="code">429</p>
|
||||
<h1>Chậm lại một nhịp.</h1>
|
||||
<p class="en">Take a breath.</p>
|
||||
<p class="code">Thử lại sau / Retry in <span id="cd">60</span>s</p>
|
||||
<script is:inline>
|
||||
(() => {
|
||||
let n = 60;
|
||||
const el = document.getElementById("cd");
|
||||
const t = setInterval(() => {
|
||||
n -= 1;
|
||||
if (el) el.textContent = String(n);
|
||||
if (n <= 0) clearInterval(t);
|
||||
}, 1000);
|
||||
})();
|
||||
</script>
|
||||
</ErrorLayout>
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
import ErrorLayout from "@/layouts/ErrorLayout.astro";
|
||||
---
|
||||
|
||||
<ErrorLayout title="500 — poli0981.dev">
|
||||
<p class="code">500</p>
|
||||
<h1>Có gì đó vỡ trong im lặng.</h1>
|
||||
<p class="en">Something broke, quietly.</p>
|
||||
<p class="code">
|
||||
Mã tham chiếu / Reference: <span class="ref" id="ref">…</span>
|
||||
</p>
|
||||
<script is:inline>
|
||||
{
|
||||
const el = document.getElementById("ref");
|
||||
if (el) el.textContent = crypto.randomUUID().slice(0, 8);
|
||||
}
|
||||
</script>
|
||||
</ErrorLayout>
|
||||
@@ -0,0 +1,116 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.about} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">Giới thiệu</h1>
|
||||
<p class="lede">
|
||||
Mình là <strong>Kokone</strong> — lập trình viên ban ngày, người kể chuyện lúc nửa đêm. Trang này
|
||||
là một địa chỉ duy nhất cho cả hai khuôn mặt đó.
|
||||
</p>
|
||||
<div class="wave"><Waveline client:visible height={30} /></div>
|
||||
|
||||
<div class="faces">
|
||||
<article class="face">
|
||||
<h2>Kokone — dev</h2>
|
||||
<p>
|
||||
Mình viết code, thích công cụ tối giản và bền. Dự án mở nằm trên GitHub (<code
|
||||
>poli0981</code
|
||||
>). Ưu tiên: ít phụ thuộc, dễ bảo trì, chi phí gần bằng không.
|
||||
</p>
|
||||
</article>
|
||||
<article class="face">
|
||||
<h2>SkullMute — creator</h2>
|
||||
<p>
|
||||
Kênh của mình về những trò chơi kể chuyện chậm rãi — visual novel, JRPG, và
|
||||
indie/psychological horror. Không FPS, không competitive. Đôi khi mình viết truyện ngắn.
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="timeline">
|
||||
<h2 class="timeline-title">Dòng thời gian</h2>
|
||||
<ul>
|
||||
<li><span class="year">2026</span> Dựng poli0981.dev — nhà chung cho dev & kênh.</li>
|
||||
<li><span class="year">2026</span> Bắt đầu series truyện đầu tiên.</li>
|
||||
<li><span class="year">—</span> Và vẫn đang viết tiếp.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 46rem;
|
||||
}
|
||||
.lede {
|
||||
margin-block-start: 1rem;
|
||||
font-size: var(--text-lead);
|
||||
color: var(--muted);
|
||||
}
|
||||
.lede strong {
|
||||
color: var(--text);
|
||||
}
|
||||
.lede code {
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1.5rem 2.5rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.faces {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 700px) {
|
||||
.faces {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
.face {
|
||||
padding: 1.25rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
}
|
||||
.face h2 {
|
||||
font-size: var(--text-lead);
|
||||
margin-block-end: 0.5rem;
|
||||
}
|
||||
.face p {
|
||||
color: var(--muted);
|
||||
}
|
||||
.face code {
|
||||
font-family: var(--ff-mono);
|
||||
color: var(--accent);
|
||||
}
|
||||
.timeline {
|
||||
margin-block-start: 2.5rem;
|
||||
}
|
||||
.timeline-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.timeline ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.timeline .year {
|
||||
display: inline-block;
|
||||
inline-size: 3.5rem;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,9 @@
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
// Deliberate 500 trigger for the docs-09 error matrix (verifies 500.astro renders).
|
||||
// Remove or gate before public launch.
|
||||
export const prerender = false;
|
||||
|
||||
export const GET: APIRoute = () => {
|
||||
throw new Error("Boom — deliberate 500 for error-page testing.");
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
// On-demand route so middleware (rate-limit, headers) runs for it.
|
||||
export const prerender = false;
|
||||
|
||||
export const GET: APIRoute = () =>
|
||||
new Response(JSON.stringify({ ok: true }), {
|
||||
status: 200,
|
||||
headers: { "content-type": "application/json", "cache-control": "no-store" },
|
||||
});
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
import PostLayout from "@/layouts/PostLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { blogPostPaths } from "@/lib/pages";
|
||||
import { readingTime, findTranslation, type BlogEntry } from "@/lib/collections";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
export const getStaticPaths = () => blogPostPaths("vi");
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: BlogEntry;
|
||||
prev: NavLink | null;
|
||||
next: NavLink | null;
|
||||
}
|
||||
const { entry, prev, next } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const mins = readingTime(entry.body);
|
||||
const translation = await findTranslation("blog", entry);
|
||||
const translationHref = translation
|
||||
? sectionPath("blog", translation.data.lang, translation.id)
|
||||
: null;
|
||||
---
|
||||
|
||||
<PostLayout {entry} locale="vi" readingMins={mins} {translationHref} {prev} {next}>
|
||||
<Content />
|
||||
</PostLayout>
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import PostGrid from "@/components/PostGrid.astro";
|
||||
import TagPill from "@/components/TagPill.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getBlogPosts, collectTags } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
const posts = await getBlogPosts(locale);
|
||||
const tags = collectTags(posts);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.blog} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.blog}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
{
|
||||
tags.length > 0 && (
|
||||
<div class="tag-cloud">
|
||||
{tags.map(({ tag, count }) => (
|
||||
<TagPill {tag} {locale} {count} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<PostGrid {posts} {locale} emptyText="Chưa có bài viết nào." />
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 1.5rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.tag-cloud {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import PostGrid from "@/components/PostGrid.astro";
|
||||
import { blogTagPaths } from "@/lib/pages";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
import type { BlogEntry } from "@/lib/collections";
|
||||
|
||||
export const getStaticPaths = () => blogTagPaths("vi");
|
||||
|
||||
interface Props {
|
||||
tag: string;
|
||||
posts: BlogEntry[];
|
||||
}
|
||||
const { tag, posts } = Astro.props as Props;
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={`#${tag}`} {locale}>
|
||||
<section class="page py-section">
|
||||
<p class="crumb"><a href={sectionPath("blog", locale)}>{t.nav.blog}</a> / #{tag}</p>
|
||||
<h1 class="text-h1">#{tag}</h1>
|
||||
<div class="grid-wrap"><PostGrid {posts} {locale} /></div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.crumb {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.crumb a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.grid-wrap {
|
||||
margin-block-start: 2rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,118 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.about} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">About</h1>
|
||||
<p class="lede">
|
||||
I'm <strong>Kokone</strong> — a developer by day, a storyteller at midnight. This site is one address
|
||||
for both of those faces.
|
||||
</p>
|
||||
<div class="wave"><Waveline client:visible height={30} /></div>
|
||||
|
||||
<div class="faces">
|
||||
<article class="face">
|
||||
<h2>Kokone — dev</h2>
|
||||
<p>
|
||||
I write code and like tools that are minimal and durable. Open projects live on GitHub (<code
|
||||
>poli0981</code
|
||||
>). Priorities: few dependencies, easy to maintain, near-zero cost.
|
||||
</p>
|
||||
</article>
|
||||
<article class="face">
|
||||
<h2>SkullMute — creator</h2>
|
||||
<p>
|
||||
My channel is about slow, story-driven games — visual novels, JRPGs, and
|
||||
indie/psychological horror. No FPS, no competitive. Sometimes I write short fiction.
|
||||
</p>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="timeline">
|
||||
<h2 class="timeline-title">Timeline</h2>
|
||||
<ul>
|
||||
<li>
|
||||
<span class="year">2026</span> Built poli0981.dev — a home for the dev & the channel.
|
||||
</li>
|
||||
<li><span class="year">2026</span> Started the first fiction series.</li>
|
||||
<li><span class="year">—</span> And still writing.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 46rem;
|
||||
}
|
||||
.lede {
|
||||
margin-block-start: 1rem;
|
||||
font-size: var(--text-lead);
|
||||
color: var(--muted);
|
||||
}
|
||||
.lede strong {
|
||||
color: var(--text);
|
||||
}
|
||||
.lede code {
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1.5rem 2.5rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.faces {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 700px) {
|
||||
.faces {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
.face {
|
||||
padding: 1.25rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
}
|
||||
.face h2 {
|
||||
font-size: var(--text-lead);
|
||||
margin-block-end: 0.5rem;
|
||||
}
|
||||
.face p {
|
||||
color: var(--muted);
|
||||
}
|
||||
.face code {
|
||||
font-family: var(--ff-mono);
|
||||
color: var(--accent);
|
||||
}
|
||||
.timeline {
|
||||
margin-block-start: 2.5rem;
|
||||
}
|
||||
.timeline-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.timeline ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.timeline .year {
|
||||
display: inline-block;
|
||||
inline-size: 3.5rem;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,30 @@
|
||||
---
|
||||
import PostLayout from "@/layouts/PostLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { blogPostPaths } from "@/lib/pages";
|
||||
import { readingTime, findTranslation, type BlogEntry } from "@/lib/collections";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
export const getStaticPaths = () => blogPostPaths("en");
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: BlogEntry;
|
||||
prev: NavLink | null;
|
||||
next: NavLink | null;
|
||||
}
|
||||
const { entry, prev, next } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const mins = readingTime(entry.body);
|
||||
const translation = await findTranslation("blog", entry);
|
||||
const translationHref = translation
|
||||
? sectionPath("blog", translation.data.lang, translation.id)
|
||||
: null;
|
||||
---
|
||||
|
||||
<PostLayout {entry} locale="en" readingMins={mins} {translationHref} {prev} {next}>
|
||||
<Content />
|
||||
</PostLayout>
|
||||
@@ -0,0 +1,50 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import PostGrid from "@/components/PostGrid.astro";
|
||||
import TagPill from "@/components/TagPill.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getBlogPosts, collectTags } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
const posts = await getBlogPosts(locale);
|
||||
const tags = collectTags(posts);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.blog} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.blog}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
{
|
||||
tags.length > 0 && (
|
||||
<div class="tag-cloud">
|
||||
{tags.map(({ tag, count }) => (
|
||||
<TagPill {tag} {locale} {count} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
<PostGrid
|
||||
{posts}
|
||||
{locale}
|
||||
emptyText={t.post.onlyVi}
|
||||
emptyHref={sectionPath("blog", "vi")}
|
||||
emptyLabel="Blog (tiếng Việt)"
|
||||
/>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 1.5rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.tag-cloud {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,40 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import PostGrid from "@/components/PostGrid.astro";
|
||||
import { blogTagPaths } from "@/lib/pages";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
import type { BlogEntry } from "@/lib/collections";
|
||||
|
||||
export const getStaticPaths = () => blogTagPaths("en");
|
||||
|
||||
interface Props {
|
||||
tag: string;
|
||||
posts: BlogEntry[];
|
||||
}
|
||||
const { tag, posts } = Astro.props as Props;
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={`#${tag}`} {locale}>
|
||||
<section class="page py-section">
|
||||
<p class="crumb"><a href={sectionPath("blog", locale)}>{t.nav.blog}</a> / #{tag}</p>
|
||||
<h1 class="text-h1">#{tag}</h1>
|
||||
<div class="grid-wrap"><PostGrid {posts} {locale} /></div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.crumb {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
}
|
||||
.crumb a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
.grid-wrap {
|
||||
margin-block-start: 2rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,130 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import PostCard from "@/components/PostCard.astro";
|
||||
import StoryCard from "@/components/StoryCard.astro";
|
||||
import { getLatestMixed } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
const latest = await getLatestMixed(locale, 3);
|
||||
|
||||
const shortcuts = [
|
||||
{ href: sectionPath("projects", locale), label: t.nav.projects },
|
||||
{ href: sectionPath("stories", locale), label: t.nav.stories },
|
||||
{ href: sectionPath("links", locale), label: t.nav.links },
|
||||
{ href: sectionPath("about", locale), label: t.nav.about },
|
||||
];
|
||||
---
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<section class="page hero reveal">
|
||||
<p class="eyebrow">poli0981.dev</p>
|
||||
<h1 class="hero-title">Kokone <span class="accent">/ SkullMute</span></h1>
|
||||
<p class="hero-tag">~ {t.site.tagline} ~</p>
|
||||
<div class="hero-wave"><Waveline client:visible height={48} /></div>
|
||||
</section>
|
||||
|
||||
{
|
||||
latest.length > 0 && (
|
||||
<section class="page block">
|
||||
<h2 class="block-title">{t.home.recent}</h2>
|
||||
<div class="latest-grid">
|
||||
{latest.map((item) =>
|
||||
item.kind === "blog" ? (
|
||||
<PostCard entry={item.entry} {locale} />
|
||||
) : (
|
||||
<StoryCard entry={item.entry} {locale} />
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
<section class="page block">
|
||||
<h2 class="block-title">{t.home.shortcuts}</h2>
|
||||
<div class="shortcuts">
|
||||
{
|
||||
shortcuts.map((s) => (
|
||||
<a class="shortcut" href={s.href}>
|
||||
{s.label}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.hero {
|
||||
padding-block: clamp(3rem, 10vw, 6rem) clamp(2rem, 6vw, 4rem);
|
||||
}
|
||||
.eyebrow {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.hero-title {
|
||||
margin-block-start: 0.5rem;
|
||||
font-size: var(--text-hero);
|
||||
line-height: 1.02;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
.hero-title .accent {
|
||||
color: var(--accent);
|
||||
}
|
||||
.hero-tag {
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
.hero-wave {
|
||||
margin-block-start: 1.75rem;
|
||||
max-inline-size: 30rem;
|
||||
}
|
||||
.block {
|
||||
padding-block-end: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
.block-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1.25rem;
|
||||
}
|
||||
.latest-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.latest-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (min-width: 960px) {
|
||||
.latest-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
.shortcuts {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.shortcut {
|
||||
padding: 0.7rem 1.1rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
transition:
|
||||
border-color var(--duration-fast) var(--ease-site),
|
||||
color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.shortcut:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
import LegalLayout from "@/layouts/LegalLayout.astro";
|
||||
import { getCollection, render, type CollectionEntry } from "astro:content";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const docs = await getCollection("legal");
|
||||
return docs.map((entry) => ({ params: { slug: entry.id }, props: { entry } }));
|
||||
}
|
||||
|
||||
interface Props {
|
||||
entry: CollectionEntry<"legal">;
|
||||
}
|
||||
const { entry } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
|
||||
const titleMap: Record<string, string> = {
|
||||
terms: t.legal.terms,
|
||||
privacy: t.legal.privacy,
|
||||
disclaimer: t.legal.disclaimer,
|
||||
"third-party": t.legal.thirdParty,
|
||||
licenses: t.legal.licenses,
|
||||
};
|
||||
const title = titleMap[entry.id] ?? entry.data.title;
|
||||
---
|
||||
|
||||
<LegalLayout {title} {locale} effectiveDate={entry.data.effectiveDate}>
|
||||
<Content />
|
||||
</LegalLayout>
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import LinksList from "@/components/LinksList.astro";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.links} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">{t.nav.links}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
<LinksList {locale} />
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 42rem;
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
import ProjectLayout from "@/layouts/ProjectLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { projectPaths } from "@/lib/pages";
|
||||
import type { ProjectEntry } from "@/lib/collections";
|
||||
|
||||
export const getStaticPaths = () => projectPaths("en");
|
||||
|
||||
interface Props {
|
||||
entry: ProjectEntry;
|
||||
}
|
||||
const { entry } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
---
|
||||
|
||||
<ProjectLayout {entry} locale="en">
|
||||
<Content />
|
||||
</ProjectLayout>
|
||||
@@ -0,0 +1,68 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import ProjectCard from "@/components/ProjectCard.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getProjects } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
const projects = await getProjects(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.projects} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.projects}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
{
|
||||
projects.length > 0 ? (
|
||||
<div class="project-grid">
|
||||
{projects.map((entry) => (
|
||||
<ProjectCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div class="empty">
|
||||
<p>{t.post.onlyVi}</p>
|
||||
<a href={sectionPath("projects", "vi")}>Dự án (tiếng Việt) →</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.project-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.project-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (min-width: 960px) {
|
||||
.project-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
.empty {
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
padding: 2.5rem 1.5rem;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.empty a {
|
||||
display: inline-block;
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,142 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { render } from "astro:content";
|
||||
import { getFaqs } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
const faqs = await getFaqs(locale);
|
||||
const items = await Promise.all(
|
||||
faqs.map(async (f) => {
|
||||
const { Content } = await render(f);
|
||||
return { id: f.id, group: f.data.group, q: f.data.q, Content };
|
||||
}),
|
||||
);
|
||||
const groups = [
|
||||
{ key: "channel", label: t.qaGroups.channel },
|
||||
{ key: "dev", label: t.qaGroups.dev },
|
||||
{ key: "personal", label: t.qaGroups.personal },
|
||||
] as const;
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.qa} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">{t.nav.qa}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
|
||||
{
|
||||
faqs.length === 0 && (
|
||||
<p class="only-vi">
|
||||
{t.post.onlyVi} <a href={sectionPath("qa", "vi")}>Hỏi đáp (tiếng Việt) →</a>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
{
|
||||
groups.map((g) => {
|
||||
const list = items.filter((i) => i.group === g.key);
|
||||
return (
|
||||
list.length > 0 && (
|
||||
<div class="qa-group">
|
||||
<h2 class="group-title">{g.label}</h2>
|
||||
{list.map(({ q, Content }) => (
|
||||
<details class="qa">
|
||||
<summary>{q}</summary>
|
||||
<div class="answer">
|
||||
<Content />
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
<div class="contact">
|
||||
<h2 class="group-title">{t.contact.title}</h2>
|
||||
<p class="lead">{t.contact.lead}</p>
|
||||
<ul class="contact-list">
|
||||
<li>{t.contact.fast}</li>
|
||||
<li>{t.contact.business}</li>
|
||||
<li>{t.contact.all}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 46rem;
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.only-vi {
|
||||
color: var(--muted);
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
.only-vi a {
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.qa-group {
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
.group-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.qa {
|
||||
border-block-end: 1px solid var(--line);
|
||||
}
|
||||
.qa summary {
|
||||
padding: 0.9rem 0;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
.qa summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
.qa summary::after {
|
||||
content: "+";
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.qa[open] summary::after {
|
||||
content: "−";
|
||||
}
|
||||
.answer {
|
||||
padding-block-end: 1rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
.contact {
|
||||
margin-block-start: 2.5rem;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
}
|
||||
.lead {
|
||||
color: var(--muted);
|
||||
margin-block: 0.5rem 1rem;
|
||||
}
|
||||
.contact-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
import StoryReaderLayout from "@/layouts/StoryReaderLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { storyChapterPaths } from "@/lib/pages";
|
||||
import { findTranslation, type StoryEntry } from "@/lib/collections";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
export const getStaticPaths = () => storyChapterPaths("en");
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: StoryEntry;
|
||||
prev: NavLink | null;
|
||||
next: NavLink | null;
|
||||
seriesTocHref: string;
|
||||
}
|
||||
const { entry, prev, next, seriesTocHref } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const translation = await findTranslation("stories", entry);
|
||||
const translationHref = translation
|
||||
? sectionPath("stories", translation.data.lang, ...translation.id.split("/"))
|
||||
: null;
|
||||
---
|
||||
|
||||
<StoryReaderLayout
|
||||
{entry}
|
||||
locale="en"
|
||||
{prev}
|
||||
{next}
|
||||
{seriesTocHref}
|
||||
seriesHref={seriesTocHref}
|
||||
{translationHref}
|
||||
>
|
||||
<Content />
|
||||
</StoryReaderLayout>
|
||||
@@ -0,0 +1,102 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import StoryCard from "@/components/StoryCard.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getStoryChapters, parseStoryId, type StoryEntry } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "en" as const;
|
||||
const t = useTranslations(locale);
|
||||
const chapters = await getStoryChapters(locale);
|
||||
|
||||
const groups = new Map<string, StoryEntry[]>();
|
||||
const standalone: StoryEntry[] = [];
|
||||
for (const c of chapters) {
|
||||
const key = c.data.series ?? parseStoryId(c.id).series;
|
||||
if (key) {
|
||||
const list = groups.get(key) ?? [];
|
||||
list.push(c);
|
||||
groups.set(key, list);
|
||||
} else {
|
||||
standalone.push(c);
|
||||
}
|
||||
}
|
||||
for (const list of groups.values()) {
|
||||
list.sort((a, b) => (a.data.chapter ?? 0) - (b.data.chapter ?? 0));
|
||||
}
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.stories} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.stories}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
|
||||
{
|
||||
[...groups].map(([series, list]) => (
|
||||
<div class="series">
|
||||
<h2 class="series-name">{series}</h2>
|
||||
<div class="story-grid">
|
||||
{list.map((entry) => (
|
||||
<StoryCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
{
|
||||
standalone.length > 0 && (
|
||||
<div class="story-grid">
|
||||
{standalone.map((entry) => (
|
||||
<StoryCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
{
|
||||
chapters.length === 0 && (
|
||||
<div class="empty">
|
||||
<p>{t.post.onlyVi}</p>
|
||||
<a href={sectionPath("stories", "vi")}>Truyện (tiếng Việt) →</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.series {
|
||||
margin-block-end: 2.5rem;
|
||||
}
|
||||
.series-name {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.story-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.story-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
.empty {
|
||||
border: 1px dashed var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
padding: 2.5rem 1.5rem;
|
||||
text-align: center;
|
||||
color: var(--muted);
|
||||
}
|
||||
.empty a {
|
||||
display: inline-block;
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,132 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import PostCard from "@/components/PostCard.astro";
|
||||
import StoryCard from "@/components/StoryCard.astro";
|
||||
import { getLatestMixed } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
const latest = await getLatestMixed(locale, 3);
|
||||
|
||||
const shortcuts = [
|
||||
{ href: sectionPath("projects", locale), label: t.nav.projects },
|
||||
{ href: sectionPath("stories", locale), label: t.nav.stories },
|
||||
{ href: sectionPath("links", locale), label: t.nav.links },
|
||||
{ href: sectionPath("about", locale), label: t.nav.about },
|
||||
];
|
||||
---
|
||||
|
||||
<BaseLayout {locale}>
|
||||
<section class="page hero reveal">
|
||||
<p class="eyebrow">poli0981.dev</p>
|
||||
<h1 class="hero-title">Kokone <span class="accent">/ SkullMute</span></h1>
|
||||
<p class="hero-tag">~ {t.site.tagline} ~</p>
|
||||
<div class="hero-wave"><Waveline client:visible height={48} /></div>
|
||||
</section>
|
||||
|
||||
{
|
||||
latest.length > 0 && (
|
||||
<section class="page block">
|
||||
<h2 class="block-title">{t.home.recent}</h2>
|
||||
<div class="latest-grid">
|
||||
{latest.map((item) =>
|
||||
item.kind === "blog" ? (
|
||||
<PostCard entry={item.entry} {locale} />
|
||||
) : (
|
||||
<StoryCard entry={item.entry} {locale} />
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
<section class="page block">
|
||||
<h2 class="block-title">{t.home.shortcuts}</h2>
|
||||
<div class="shortcuts">
|
||||
{
|
||||
shortcuts.map((s) => (
|
||||
<a class="shortcut" href={s.href}>
|
||||
{s.label}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.hero {
|
||||
padding-block: clamp(3rem, 10vw, 6rem) clamp(2rem, 6vw, 4rem);
|
||||
}
|
||||
.eyebrow {
|
||||
color: var(--muted);
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-meta);
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
.hero-title {
|
||||
margin-block-start: 0.5rem;
|
||||
font-size: var(--text-hero);
|
||||
line-height: 1.02;
|
||||
letter-spacing: -0.01em;
|
||||
}
|
||||
.hero-title .accent {
|
||||
color: var(--accent);
|
||||
}
|
||||
.hero-tag {
|
||||
margin-block-start: 0.75rem;
|
||||
color: var(--muted);
|
||||
font-size: var(--text-lead);
|
||||
}
|
||||
.hero-wave {
|
||||
margin-block-start: 1.75rem;
|
||||
max-inline-size: 30rem;
|
||||
}
|
||||
|
||||
.block {
|
||||
padding-block-end: clamp(2rem, 6vw, 3.5rem);
|
||||
}
|
||||
.block-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1.25rem;
|
||||
}
|
||||
.latest-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.latest-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (min-width: 960px) {
|
||||
.latest-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.shortcuts {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.shortcut {
|
||||
padding: 0.7rem 1.1rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 999px;
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
transition:
|
||||
border-color var(--duration-fast) var(--ease-site),
|
||||
color var(--duration-fast) var(--ease-site);
|
||||
}
|
||||
.shortcut:hover {
|
||||
border-color: var(--accent);
|
||||
color: var(--accent);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
import LegalLayout from "@/layouts/LegalLayout.astro";
|
||||
import { getCollection, render, type CollectionEntry } from "astro:content";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const docs = await getCollection("legal");
|
||||
return docs.map((entry) => ({ params: { slug: entry.id }, props: { entry } }));
|
||||
}
|
||||
|
||||
interface Props {
|
||||
entry: CollectionEntry<"legal">;
|
||||
}
|
||||
const { entry } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
|
||||
const titleMap: Record<string, string> = {
|
||||
terms: t.legal.terms,
|
||||
privacy: t.legal.privacy,
|
||||
disclaimer: t.legal.disclaimer,
|
||||
"third-party": t.legal.thirdParty,
|
||||
licenses: t.legal.licenses,
|
||||
};
|
||||
const title = titleMap[entry.id] ?? entry.data.title;
|
||||
---
|
||||
|
||||
<LegalLayout {title} {locale} effectiveDate={entry.data.effectiveDate}>
|
||||
<Content />
|
||||
</LegalLayout>
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import LinksList from "@/components/LinksList.astro";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.links} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">{t.nav.links}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
<LinksList {locale} />
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 42rem;
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
---
|
||||
import ErrorLayout from "@/layouts/ErrorLayout.astro";
|
||||
---
|
||||
|
||||
<ErrorLayout title="Offline — poli0981.dev" showLinks={false}>
|
||||
<p class="code">offline</p>
|
||||
<h1>Không có mạng — nhưng vẫn có thứ để làm.</h1>
|
||||
<p class="en">You're offline.</p>
|
||||
<p class="code">Kết nối lại rồi thử tải trang một lần nữa nhé.</p>
|
||||
</ErrorLayout>
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
import ProjectLayout from "@/layouts/ProjectLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { projectPaths } from "@/lib/pages";
|
||||
import type { ProjectEntry } from "@/lib/collections";
|
||||
|
||||
export const getStaticPaths = () => projectPaths("vi");
|
||||
|
||||
interface Props {
|
||||
entry: ProjectEntry;
|
||||
}
|
||||
const { entry } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
---
|
||||
|
||||
<ProjectLayout {entry} locale="vi">
|
||||
<Content />
|
||||
</ProjectLayout>
|
||||
@@ -0,0 +1,54 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import ProjectCard from "@/components/ProjectCard.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getProjects } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
const projects = await getProjects(locale);
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.projects} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.projects}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
{
|
||||
projects.length > 0 ? (
|
||||
<div class="project-grid">
|
||||
{projects.map((entry) => (
|
||||
<ProjectCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p class="empty">Chưa có dự án nào.</p>
|
||||
)
|
||||
}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.project-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.project-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
@media (min-width: 960px) {
|
||||
.project-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
}
|
||||
.empty {
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,125 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { render } from "astro:content";
|
||||
import { getFaqs } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
const faqs = await getFaqs(locale);
|
||||
const items = await Promise.all(
|
||||
faqs.map(async (f) => {
|
||||
const { Content } = await render(f);
|
||||
return { id: f.id, group: f.data.group, q: f.data.q, Content };
|
||||
}),
|
||||
);
|
||||
const groups = [
|
||||
{ key: "channel", label: t.qaGroups.channel },
|
||||
{ key: "dev", label: t.qaGroups.dev },
|
||||
{ key: "personal", label: t.qaGroups.personal },
|
||||
] as const;
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.qa} {locale}>
|
||||
<section class="page narrow py-section">
|
||||
<h1 class="text-h1">{t.nav.qa}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
|
||||
{
|
||||
groups.map((g) => {
|
||||
const list = items.filter((i) => i.group === g.key);
|
||||
return (
|
||||
list.length > 0 && (
|
||||
<div class="qa-group">
|
||||
<h2 class="group-title">{g.label}</h2>
|
||||
{list.map(({ q, Content }) => (
|
||||
<details class="qa">
|
||||
<summary>{q}</summary>
|
||||
<div class="answer">
|
||||
<Content />
|
||||
</div>
|
||||
</details>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
<div class="contact">
|
||||
<h2 class="group-title">{t.contact.title}</h2>
|
||||
<p class="lead">{t.contact.lead}</p>
|
||||
<ul class="contact-list">
|
||||
<li>{t.contact.fast}</li>
|
||||
<li>{t.contact.business}</li>
|
||||
<li>{t.contact.all}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.narrow {
|
||||
max-inline-size: 46rem;
|
||||
}
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.qa-group {
|
||||
margin-block-end: 2rem;
|
||||
}
|
||||
.group-title {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.qa {
|
||||
border-block-end: 1px solid var(--line);
|
||||
}
|
||||
.qa summary {
|
||||
padding: 0.9rem 0;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
.qa summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
.qa summary::after {
|
||||
content: "+";
|
||||
color: var(--accent);
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
.qa[open] summary::after {
|
||||
content: "−";
|
||||
}
|
||||
.answer {
|
||||
padding-block-end: 1rem;
|
||||
color: var(--muted);
|
||||
}
|
||||
.contact {
|
||||
margin-block-start: 2.5rem;
|
||||
padding: 1.5rem;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius-card);
|
||||
background: var(--surface);
|
||||
}
|
||||
.lead {
|
||||
color: var(--muted);
|
||||
margin-block: 0.5rem 1rem;
|
||||
}
|
||||
.contact-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--ff-mono);
|
||||
font-size: var(--text-body);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
import StoryReaderLayout from "@/layouts/StoryReaderLayout.astro";
|
||||
import { render } from "astro:content";
|
||||
import { storyChapterPaths } from "@/lib/pages";
|
||||
import { findTranslation, type StoryEntry } from "@/lib/collections";
|
||||
import { sectionPath } from "@/i18n/routing";
|
||||
|
||||
export const getStaticPaths = () => storyChapterPaths("vi");
|
||||
|
||||
interface NavLink {
|
||||
href: string;
|
||||
label: string;
|
||||
}
|
||||
interface Props {
|
||||
entry: StoryEntry;
|
||||
prev: NavLink | null;
|
||||
next: NavLink | null;
|
||||
seriesTocHref: string;
|
||||
}
|
||||
const { entry, prev, next, seriesTocHref } = Astro.props as Props;
|
||||
const { Content } = await render(entry);
|
||||
const translation = await findTranslation("stories", entry);
|
||||
const translationHref = translation
|
||||
? sectionPath("stories", translation.data.lang, ...translation.id.split("/"))
|
||||
: null;
|
||||
---
|
||||
|
||||
<StoryReaderLayout
|
||||
{entry}
|
||||
locale="vi"
|
||||
{prev}
|
||||
{next}
|
||||
{seriesTocHref}
|
||||
seriesHref={seriesTocHref}
|
||||
{translationHref}
|
||||
>
|
||||
<Content />
|
||||
</StoryReaderLayout>
|
||||
@@ -0,0 +1,86 @@
|
||||
---
|
||||
import BaseLayout from "@/layouts/BaseLayout.astro";
|
||||
import StoryCard from "@/components/StoryCard.astro";
|
||||
import Waveline from "@/components/Waveline.svelte";
|
||||
import { getStoryChapters, parseStoryId, type StoryEntry } from "@/lib/collections";
|
||||
import { useTranslations } from "@/i18n";
|
||||
|
||||
const locale = "vi" as const;
|
||||
const t = useTranslations(locale);
|
||||
const chapters = await getStoryChapters(locale);
|
||||
|
||||
const groups = new Map<string, StoryEntry[]>();
|
||||
const standalone: StoryEntry[] = [];
|
||||
for (const c of chapters) {
|
||||
const key = c.data.series ?? parseStoryId(c.id).series;
|
||||
if (key) {
|
||||
const list = groups.get(key) ?? [];
|
||||
list.push(c);
|
||||
groups.set(key, list);
|
||||
} else {
|
||||
standalone.push(c);
|
||||
}
|
||||
}
|
||||
for (const list of groups.values()) {
|
||||
list.sort((a, b) => (a.data.chapter ?? 0) - (b.data.chapter ?? 0));
|
||||
}
|
||||
---
|
||||
|
||||
<BaseLayout title={t.nav.stories} {locale}>
|
||||
<section class="page py-section">
|
||||
<h1 class="text-h1">{t.nav.stories}</h1>
|
||||
<div class="wave"><Waveline client:visible height={28} /></div>
|
||||
|
||||
{
|
||||
[...groups].map(([series, list]) => (
|
||||
<div class="series">
|
||||
<h2 class="series-name">{series}</h2>
|
||||
<div class="story-grid">
|
||||
{list.map((entry) => (
|
||||
<StoryCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
{
|
||||
standalone.length > 0 && (
|
||||
<div class="story-grid">
|
||||
{standalone.map((entry) => (
|
||||
<StoryCard {entry} {locale} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
{chapters.length === 0 && <p class="empty">Chưa có truyện nào.</p>}
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.wave {
|
||||
margin-block: 1rem 2rem;
|
||||
max-inline-size: 22rem;
|
||||
}
|
||||
.series {
|
||||
margin-block-end: 2.5rem;
|
||||
}
|
||||
.series-name {
|
||||
font-size: var(--text-h3);
|
||||
margin-block-end: 1rem;
|
||||
}
|
||||
.story-grid {
|
||||
display: grid;
|
||||
gap: 1.25rem;
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.story-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
.empty {
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,233 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
/* We toggle themes with a [data-theme] attribute (not the OS media query), so the
|
||||
dark/light variants must key off that attribute. */
|
||||
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
|
||||
@custom-variant light (&:where([data-theme="light"], [data-theme="light"] *));
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Runtime palettes — the single source that flips on [data-theme].
|
||||
* Components reference the semantic tokens below (var(--bg), var(--accent)…)
|
||||
* or the Tailwind utilities generated from the @theme block further down.
|
||||
* ------------------------------------------------------------------ */
|
||||
:root,
|
||||
[data-theme="dark"] {
|
||||
color-scheme: dark;
|
||||
/* Dark — "mực đêm" (midnight ink), the default */
|
||||
--bg: #0d1117;
|
||||
--surface: #12161f;
|
||||
--elevated: #1a2030;
|
||||
--line: #242b38;
|
||||
--text: #e9e4d8;
|
||||
--muted: #98a0ae;
|
||||
--accent: #e8a33d;
|
||||
--accent-strong: #f4b860;
|
||||
--horror: #8c2f39;
|
||||
--ok: #4c9a6a;
|
||||
--warn: #c9822b;
|
||||
--err: #c24a4a;
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
color-scheme: light;
|
||||
/* Light — "trang giấy cũ" (old paper). Accent is darker to hold AA on light. */
|
||||
--bg: #f5efe2;
|
||||
--surface: #fffdf7;
|
||||
--elevated: #ffffff;
|
||||
--line: #e2d9c5;
|
||||
--text: #26221a;
|
||||
--muted: #6e6757;
|
||||
--accent: #9a6414;
|
||||
--accent-strong: #7c4f10;
|
||||
--horror: #8c2f39;
|
||||
--ok: #3f7f57;
|
||||
--warn: #a86a1f;
|
||||
--err: #a83b3b;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Theme tokens → Tailwind utilities.
|
||||
* `inline` so utilities inline `var(--bg)` etc. and flip with [data-theme].
|
||||
* ------------------------------------------------------------------ */
|
||||
@theme inline {
|
||||
--color-bg: var(--bg);
|
||||
--color-surface: var(--surface);
|
||||
--color-elevated: var(--elevated);
|
||||
--color-line: var(--line);
|
||||
--color-text: var(--text);
|
||||
--color-muted: var(--muted);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-strong: var(--accent-strong);
|
||||
--color-horror: var(--horror);
|
||||
--color-ok: var(--ok);
|
||||
--color-warn: var(--warn);
|
||||
--color-err: var(--err);
|
||||
|
||||
/* Font families come from the Astro Fonts API (--ff-*), self-hosted. */
|
||||
--font-sans: var(--ff-body);
|
||||
--font-display: var(--ff-display);
|
||||
--font-reading: var(--ff-reading);
|
||||
--font-mono: var(--ff-mono);
|
||||
}
|
||||
|
||||
/* Static design tokens (emitted as :root vars AND Tailwind utilities). */
|
||||
@theme {
|
||||
/* Fluid type scale, 360px → 1280px (docs 03 §3). */
|
||||
--text-meta: clamp(0.875rem, 0.85rem + 0.11vw, 0.9375rem);
|
||||
--text-body: clamp(1rem, 0.95rem + 0.22vw, 1.125rem);
|
||||
--text-lead: clamp(1.25rem, 1.15rem + 0.43vw, 1.5rem);
|
||||
--text-h3: clamp(1.563rem, 1.39rem + 0.76vw, 2rem);
|
||||
--text-h2: clamp(1.953rem, 1.64rem + 1.39vw, 2.75rem);
|
||||
--text-h1: clamp(2.441rem, 1.93rem + 2.28vw, 3.75rem);
|
||||
--text-hero: clamp(3.05rem, 2.29rem + 3.39vw, 5rem);
|
||||
|
||||
/* Section rhythm + a spacing token usable as p-section / py-section / gap-section. */
|
||||
--spacing-section: clamp(3rem, 8vw, 6rem);
|
||||
|
||||
--radius-control: 6px;
|
||||
--radius-card: 10px;
|
||||
--radius-modal: 16px;
|
||||
|
||||
--shadow-elevated: 0 8px 30px rgb(0 0 0 / 0.35);
|
||||
|
||||
/* Motion (docs 03 §6). Primary ease ~ cubic-bezier(0.22, 1, 0.36, 1). */
|
||||
--ease-site: cubic-bezier(0.22, 1, 0.36, 1);
|
||||
--duration-fast: 150ms;
|
||||
--duration-base: 250ms;
|
||||
--duration-slow: 400ms;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Base element styles
|
||||
* ------------------------------------------------------------------ */
|
||||
html {
|
||||
-webkit-text-size-adjust: 100%;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-block-size: 100dvh;
|
||||
background-color: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: var(--ff-body);
|
||||
font-size: var(--text-body);
|
||||
line-height: 1.7;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
}
|
||||
|
||||
/* Leave room for the fixed mobile tab bar so the footer isn't hidden behind it. */
|
||||
@media (max-width: 767px) {
|
||||
body {
|
||||
padding-block-end: calc(3.5rem + env(safe-area-inset-bottom, 0px));
|
||||
}
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
font-family: var(--ff-display);
|
||||
line-height: 1.15;
|
||||
font-weight: 700;
|
||||
text-wrap: balance;
|
||||
}
|
||||
|
||||
code,
|
||||
kbd,
|
||||
samp,
|
||||
pre {
|
||||
font-family: var(--ff-mono);
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: var(--accent);
|
||||
color: #0d1117;
|
||||
}
|
||||
|
||||
/* Visible, consistent focus ring for keyboard users (docs 03 §8). */
|
||||
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
/* Page width container. */
|
||||
.page {
|
||||
max-inline-size: 72rem;
|
||||
margin-inline: auto;
|
||||
padding-inline: clamp(1rem, 4vw, 2rem);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Grain overlay — one element, whole page, ~3%, never intercepts input.
|
||||
* Inline SVG feTurbulence keeps it asset-free and CSP-safe (data: is in img-src).
|
||||
* ------------------------------------------------------------------ */
|
||||
body::after {
|
||||
content: "";
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
/* No mix-blend-mode: a full-viewport blended layer is a per-paint cost that
|
||||
hurts the perf budget. A plain low-opacity overlay composites once. */
|
||||
opacity: 0.045;
|
||||
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
|
||||
background-size: 160px 160px;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Staged reveal — one moment on load, ≤6 elements (docs 03 §6). CSS-only;
|
||||
* the reduced-motion reset above collapses it to an instant appearance.
|
||||
* ------------------------------------------------------------------ */
|
||||
@keyframes reveal-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(12px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
.reveal > * {
|
||||
animation: reveal-in 0.5s var(--ease-site) both;
|
||||
}
|
||||
.reveal > *:nth-child(1) {
|
||||
animation-delay: 0.04s;
|
||||
}
|
||||
.reveal > *:nth-child(2) {
|
||||
animation-delay: 0.1s;
|
||||
}
|
||||
.reveal > *:nth-child(3) {
|
||||
animation-delay: 0.16s;
|
||||
}
|
||||
.reveal > *:nth-child(4) {
|
||||
animation-delay: 0.22s;
|
||||
}
|
||||
.reveal > *:nth-child(5) {
|
||||
animation-delay: 0.28s;
|
||||
}
|
||||
.reveal > *:nth-child(6) {
|
||||
animation-delay: 0.34s;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ *
|
||||
* Reduced motion — every animation/transition has a still branch.
|
||||
* ------------------------------------------------------------------ */
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
animation-duration: 0.001ms !important;
|
||||
animation-iteration-count: 1 !important;
|
||||
transition-duration: 0.001ms !important;
|
||||
scroll-behavior: auto !important;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user