This commit is contained in:
kakkokari-gtyih 2023-12-12 23:07:15 +09:00
commit 94603bcf57
8 changed files with 1459 additions and 18 deletions

17
assets/data/locales.ts Normal file
View File

@ -0,0 +1,17 @@
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
export const localesConst = [
{ files: [ 'ja-JP.json' ], code: 'ja', iso: 'ja-JP', name: '日本語' },
{ files: [ 'en-US.json' ], code: 'en', iso: 'en-US', name: 'English' },
{ files: [ 'id-ID.json' ], code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' },
{ files: [ 'ko-KR.json' ], code: 'ko', iso: 'ko-KR', name: '한국어' },
{ files: [ 'it-IT.json' ], code: 'it', iso: 'it-IT', name: 'Italiano' },
{ files: [ 'pl-PL.json' ], code: 'pl', iso: 'pl-PL', name: 'Polski' },
{ files: [ 'fr-FR.json' ], code: 'fr', iso: 'fr-FR', name: 'Français' },
{ files: [ 'zh-CN.json' ], code: 'cn', iso: 'zh-CN', name: '简体中文' },
{ files: [ 'zh-TW.json' ], code: 'tw', iso: 'zh-TW', name: '繁体中文' },
] as const;
export type LocaleCodes = typeof localesConst[number]['code'];
export const locales = localesConst as unknown as LocaleObject[];

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
---
description: '「Misskey & Webテクロジー最前線」の12月の記事が公開されました'
date: 2023-12-12
---
# 「Misskey & Webテクロジー最前線」12月
Webメディア[gihyo.jp](https://gihyo.jp/)にて行われている、Misskeyプロジェクトリーダー syuiloによるMisskeyの技術についての連載「Misskey & Webテクロジー最前線」の12月の記事が公開されました
[「2023年Misskey開発まとめ」](https://gihyo.jp/article/2023/11/misskey-09)

View File

@ -1,8 +1,10 @@
# AiScript
AiScriptは、Misskeyで使用できるスクリプト言語です。
::: tip
:::tip
AiScript実装はMisskeyとは別リポジトリで、[オープンソースで公開されています](https://github.com/syuilo/aiscript)。
:::
## 使い方

View File

@ -3,30 +3,16 @@ import yaml from '@rollup/plugin-yaml';
import svgLoader from 'vite-svg-loader';
import { readFileSync } from 'fs';
import { genApiTranslationFiles } from './scripts/gen-api-translations';
import type { LocaleObject } from '@nuxtjs/i18n/dist/runtime/composables';
import { getOldHubRedirects } from './scripts/get-old-hub-redirects';
import { genLocalesJson } from './scripts/gen-locales';
import { getStaticEndpoints } from './scripts/get-static-endpoints';
import { locales } from './assets/data/locales';
import type { NuxtConfig } from 'nuxt/schema';
// 公開時のドメイン(末尾スラッシュなし)
const baseUrl = 'https://misskey-hub-next.vercel.app';
// 言語定義
export const localesConst = [
{ files: [ 'ja-JP.json' ], code: 'ja', iso: 'ja-JP', name: '日本語' },
{ files: [ 'en-US.json' ], code: 'en', iso: 'en-US', name: 'English' },
{ files: [ 'id-ID.json' ], code: 'id', iso: 'id-ID', name: 'Bahasa Indonesia' },
{ files: [ 'ko-KR.json' ], code: 'ko', iso: 'ko-KR', name: '한국어' },
{ files: [ 'it-IT.json' ], code: 'it', iso: 'it-IT', name: 'Italiano' },
{ files: [ 'pl-PL.json' ], code: 'pl', iso: 'pl-PL', name: 'Polski' },
{ files: [ 'fr-FR.json' ], code: 'fr', iso: 'fr-FR', name: 'Français' },
{ files: [ 'zh-CN.json' ], code: 'cn', iso: 'zh-CN', name: '简体中文' },
{ files: [ 'zh-TW.json' ], code: 'tw', iso: 'zh-TW', name: '繁体中文' },
] as const;
export type LocaleCodes = typeof localesConst[number]['code'];
export const locales = localesConst as unknown as LocaleObject[];
// 言語定義は /assets/data/locales.ts に移動しました
function getRouteRules(): NuxtConfig['routeRules'] {
// 言語ごとに割り当てる必要のないRouteRules
@ -164,6 +150,13 @@ export default defineNuxtConfig({
},
nitro: {
preset: 'vercel',
vercel: {
config: {
routes: [
...getOldHubRedirects(),
],
}
},
plugins: [
'@/server/plugins/appendComment.ts',
'@/server/plugins/i18nRedirector.ts',

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

View File

@ -0,0 +1,77 @@
import { writeFileSync } from 'fs';
import { redirects } from './../assets/data/old-hub-redirects';
import { localesConst } from './../assets/data/locales';
import type { LocaleCodes } from './../assets/data/locales';
import type { NuxtConfig } from 'nuxt/schema';
import { joinURL, cleanDoubleSlashes } from 'ufo';
type VercelRouteSource = {
src: string;
dest?: string;
headers?: Record<string, string>;
methods?: string[];
continue?: boolean;
caseSensitive?: boolean;
check?: boolean;
status?: number;
has?: Array<unknown>;
missing?: Array<unknown>;
locale?: {
redirect?: Record<string, string>;
cookie?: string;
};
middlewareRawSrc?: string[];
middlewarePath?: string;
};
export function getOldHubRedirects():VercelRouteSource[] {
// 旧Hub時代の各言語のプレフィックス
const hubLocales: Record<LocaleCodes, string> = {
ja: '/',
en: '/en',
id: '/id',
ko: '/ko',
it: '/it',
pl: '/pl',
fr: '/fr',
cn: '/zh-CN',
tw: '/zh-TW',
};
const out:VercelRouteSource[] = [];
redirects.forEach((route) => {
if (route[0].startsWith('/ns')) return;
let destination = route[1];
if (!new RegExp(`^/(${localesConst.map((e) => e.code).join('|')})/`, 'g').test(destination)) {
destination = joinURL(`$1/`, destination);
}
out.push({
src: joinURL(`(${Object.values(hubLocales).map((v) => v === '/' ? '' : v).join('|')})/`, route[0]).replace(/(?<!\\)\./g, '\\.'),
headers: {
'Location': destination,
},
status: 308,
});
});
out.push({
src: '/zh-CN/(.*)',
headers: {
'Location': '/cn/$1',
},
status: 307,
}, {
src: '/zh-TW/(.*)',
headers: {
'Location': '/tw/$1',
},
status: 307,
});
return out;
}