feat: add FrontMatter CMS, biome, translation, etc.

* add Frontmatter CMS

* add biome

* update

* update

* fixed & add docs

* fix translation.ts

* fix translation
This commit is contained in:
L4Ph
2024-01-21 13:54:41 +09:00
committed by GitHub
parent f9a78b3e3b
commit 197d524b53
42 changed files with 2714 additions and 12795 deletions

View File

@@ -1,32 +1,32 @@
enum I18nKey {
home = "home",
about = "about",
archive = "archive",
home = 'home',
about = 'about',
archive = 'archive',
tags = "tags",
categories = "categories",
recentPosts = "recentPosts",
tags = 'tags',
categories = 'categories',
recentPosts = 'recentPosts',
comments = "comments",
comments = 'comments',
untitled = "untitled",
uncategorized = "uncategorized",
noTags = "noTags",
untitled = 'untitled',
uncategorized = 'uncategorized',
noTags = 'noTags',
wordCount = "wordCount",
wordsCount = "wordsCount",
minuteCount = "minuteCount",
minutesCount = "minutesCount",
postCount = "postCount",
postsCount = "postsCount",
wordCount = 'wordCount',
wordsCount = 'wordsCount',
minuteCount = 'minuteCount',
minutesCount = 'minutesCount',
postCount = 'postCount',
postsCount = 'postsCount',
primaryColor = "primaryColor",
primaryColor = 'primaryColor',
more = "more",
more = 'more',
author = "author",
publishedAt = "publishedAt",
license = "license",
author = 'author',
publishedAt = 'publishedAt',
license = 'license',
}
export default I18nKey;
export default I18nKey

View File

@@ -1,33 +1,33 @@
import type { Translation } from "../translation.ts";
import Key from "../i18nKey.ts";
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
export const en: Translation = {
[Key.home]: "Home",
[Key.about]: "About",
[Key.archive]: "Archive",
[Key.home]: 'Home',
[Key.about]: 'About',
[Key.archive]: 'Archive',
[Key.tags]: "Tags",
[Key.categories]: "Categories",
[Key.recentPosts]: "Recent Posts",
[Key.tags]: 'Tags',
[Key.categories]: 'Categories',
[Key.recentPosts]: 'Recent Posts',
[Key.comments]: "Comments",
[Key.comments]: 'Comments',
[Key.untitled]: "Untitled",
[Key.uncategorized]: "Uncategorized",
[Key.noTags]: "No Tags",
[Key.untitled]: 'Untitled',
[Key.uncategorized]: 'Uncategorized',
[Key.noTags]: 'No Tags',
[Key.wordCount]: "word",
[Key.wordsCount]: "words",
[Key.minuteCount]: "minute",
[Key.minutesCount]: "minutes",
[Key.postCount]: "post",
[Key.postsCount]: "posts",
[Key.wordCount]: 'word',
[Key.wordsCount]: 'words',
[Key.minuteCount]: 'minute',
[Key.minutesCount]: 'minutes',
[Key.postCount]: 'post',
[Key.postsCount]: 'posts',
[Key.primaryColor]: "Primary Color",
[Key.primaryColor]: 'Primary Color',
[Key.more]: "More",
[Key.more]: 'More',
[Key.author]: "Author",
[Key.publishedAt]: "Published at",
[Key.license]: "License",
};
[Key.author]: 'Author',
[Key.publishedAt]: 'Published at',
[Key.license]: 'License',
}

33
src/i18n/languages/ja.ts Normal file
View File

@@ -0,0 +1,33 @@
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
export const ja: Translation = {
[Key.home]: 'Home',
[Key.about]: 'About',
[Key.archive]: 'Archive',
[Key.tags]: 'タグ',
[Key.categories]: 'カテゴリ',
[Key.recentPosts]: '最近の投稿',
[Key.comments]: 'コメント',
[Key.untitled]: 'タイトルなし',
[Key.uncategorized]: 'カテゴリなし',
[Key.noTags]: 'タグなし',
[Key.wordCount]: '文字',
[Key.wordsCount]: '文字',
[Key.minuteCount]: '分',
[Key.minutesCount]: '分',
[Key.postCount]: 'post',
[Key.postsCount]: 'posts',
[Key.primaryColor]: '原色',
[Key.more]: 'もっと',
[Key.author]: '作者',
[Key.publishedAt]: '公開日',
[Key.license]: 'ライセンス',
}

View File

@@ -1,33 +1,33 @@
import type { Translation } from "../translation.ts";
import Key from "../i18nKey.ts";
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
export const zh_CN: Translation = {
[Key.home]: "主页",
[Key.about]: "关于",
[Key.archive]: "归档",
[Key.home]: '主页',
[Key.about]: '关于',
[Key.archive]: '归档',
[Key.tags]: "标签",
[Key.categories]: "分类",
[Key.recentPosts]: "最新文章",
[Key.tags]: '标签',
[Key.categories]: '分类',
[Key.recentPosts]: '最新文章',
[Key.comments]: "评论",
[Key.comments]: '评论',
[Key.untitled]: "无标题",
[Key.uncategorized]: "未分类",
[Key.noTags]: "无标签",
[Key.untitled]: '无标题',
[Key.uncategorized]: '未分类',
[Key.noTags]: '无标签',
[Key.wordCount]: "字",
[Key.wordsCount]: "字",
[Key.minuteCount]: "分钟",
[Key.minutesCount]: "分钟",
[Key.postCount]: "篇文章",
[Key.postsCount]: "篇文章",
[Key.wordCount]: '字',
[Key.wordsCount]: '字',
[Key.minuteCount]: '分钟',
[Key.minutesCount]: '分钟',
[Key.postCount]: '篇文章',
[Key.postsCount]: '篇文章',
[Key.primaryColor]: "主题色",
[Key.primaryColor]: '主题色',
[Key.more]: "更多",
[Key.more]: '更多',
[Key.author]: "作者",
[Key.publishedAt]: "发布于",
[Key.license]: "许可协议",
};
[Key.author]: '作者',
[Key.publishedAt]: '发布于',
[Key.license]: '许可协议',
}

View File

@@ -1,33 +1,33 @@
import type { Translation } from "../translation.ts";
import Key from "../i18nKey.ts";
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
export const zh_TW: Translation = {
[Key.home]: "首頁",
[Key.about]: "關於",
[Key.archive]: "彙整",
[Key.home]: '首頁',
[Key.about]: '關於',
[Key.archive]: '彙整',
[Key.tags]: "標籤",
[Key.categories]: "分類",
[Key.recentPosts]: "最新文章",
[Key.tags]: '標籤',
[Key.categories]: '分類',
[Key.recentPosts]: '最新文章',
[Key.comments]: "評論",
[Key.comments]: '評論',
[Key.untitled]: "無標題",
[Key.uncategorized]: "未分類",
[Key.noTags]: "無標籤",
[Key.untitled]: '無標題',
[Key.uncategorized]: '未分類',
[Key.noTags]: '無標籤',
[Key.wordCount]: "字",
[Key.wordsCount]: "字",
[Key.minuteCount]: "分鐘",
[Key.minutesCount]: "分鐘",
[Key.postCount]: "篇文章",
[Key.postsCount]: "篇文章",
[Key.wordCount]: '字',
[Key.wordsCount]: '字',
[Key.minuteCount]: '分鐘',
[Key.minutesCount]: '分鐘',
[Key.postCount]: '篇文章',
[Key.postsCount]: '篇文章',
[Key.primaryColor]: "主題色",
[Key.primaryColor]: '主題色',
[Key.more]: "更多",
[Key.more]: '更多',
[Key.author]: "作者",
[Key.publishedAt]: "發佈於",
[Key.license]: "許可協議",
};
[Key.author]: '作者',
[Key.publishedAt]: '發佈於',
[Key.license]: '許可協議',
}

View File

@@ -1,30 +1,33 @@
import {en} from "./languages/en.ts";
import {zh_TW} from "./languages/zh_TW.ts";
import {zh_CN} from "./languages/zh_CN.ts";
import type I18nKey from "./i18nKey.ts";
import {siteConfig} from "../config.ts";
import { siteConfig } from '../config.ts'
import type I18nKey from './i18nKey.ts'
import { en } from './languages/en.ts'
import { ja } from './languages/ja.ts'
import { zh_CN } from './languages/zh_CN.ts'
import { zh_TW } from './languages/zh_TW.ts'
export type Translation = {
[K in I18nKey]: string;
[K in I18nKey]: string
}
const defaultTranslation = en;
const defaultTranslation = en
const map: { [key: string]: Translation } = {
"en": en,
"en_us": en,
"en_gb": en,
"en_au": en,
"zh_cn": zh_CN,
"zh_tw": zh_TW,
en: en,
en_us: en,
en_gb: en,
en_au: en,
zh_cn: zh_CN,
zh_tw: zh_TW,
ja: ja,
ja_jp: ja,
}
export function getTranslation(lang: string): Translation {
lang = lang.toLowerCase();
return map[lang] || defaultTranslation;
lang = lang.toLowerCase()
return map[lang] || defaultTranslation
}
export function i18n(key: I18nKey): string {
const lang = siteConfig.lang || "en";
return getTranslation(lang)[key];
}
const lang = siteConfig.lang || 'en'
return getTranslation(lang)[key]
}