Initialize blog scaffold

Add the CLI, site, and sample content so the project can run locally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yarnom 2026-05-28 16:58:30 +08:00
parent 9d2628b318
commit b78f4b39c9
40 changed files with 9140 additions and 0 deletions

View file

@ -0,0 +1,38 @@
package cli
import "testing"
func TestSanitizeSlug(t *testing.T) {
tests := map[string]string{
"Hello Astro": "hello-astro",
" Go / Astro_Blog! ": "go-astro-blog",
"Already--Clean": "already-clean",
"喜欢你": "",
"abc123": "abc123",
}
for input, want := range tests {
if got := sanitizeSlug(input); got != want {
t.Fatalf("sanitizeSlug(%q) = %q, want %q", input, got, want)
}
}
}
func TestFallbackSlug(t *testing.T) {
if got := fallbackSlug("Hello Astro"); got != "hello-astro" {
t.Fatalf("fallbackSlug english = %q", got)
}
got := fallbackSlug("喜欢你")
if len(got) <= len("post-") || got[:5] != "post-" {
t.Fatalf("fallbackSlug non-ascii = %q, want post-*", got)
}
}
func TestFormatYAMLStringList(t *testing.T) {
got := formatYAMLStringList([]string{"go", `astro "site"`})
want := `["go", "astro \"site\""]`
if got != want {
t.Fatalf("formatYAMLStringList = %q, want %q", got, want)
}
}