Skip to content

Commit 2b68d8e

Browse files
committed
feat: switch dynamic import on theme
1 parent b3665dd commit 2b68d8e

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

apps/web/src/lib/themes/index.ts

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import type { Theme } from '@tabitabi/types';
2-
import minimalTheme from './minimal';
3-
import standardTheme from './standard';
4-
5-
const themes: Record<string, Theme> = {
6-
minimal: minimalTheme,
7-
standard: standardTheme
8-
};
92

3+
// 動的 import に切り替え(未選択テーマをバンドルしない)
104
export async function loadTheme(themeId: string): Promise<Theme> {
11-
const theme = themes[themeId] || themes.minimal;
12-
return theme;
5+
switch (themeId) {
6+
case 'standard':
7+
return (await import('./standard')).default;
8+
case 'minimal':
9+
default:
10+
return (await import('./minimal')).default;
11+
}
1312
}
1413

1514
export function getEnabledFeatures(theme: Theme): string[] {
@@ -18,12 +17,14 @@ export function getEnabledFeatures(theme: Theme): string[] {
1817
.map(([name]) => name);
1918
}
2019

20+
// メタ情報だけを静的に保持(テーマ本体は読み込まない)
21+
const THEME_CATALOG: Array<{ id: AvailableTheme; name: string; description: string }> = [
22+
{ id: 'minimal', name: 'ミニマル', description: '必要最小限のシンプルなテーマ' },
23+
{ id: 'standard', name: 'スタンダード', description: 'デフォルトテーマ' }
24+
];
25+
2126
export function getAvailableThemes(): Array<{ id: string; name: string; description: string }> {
22-
return Object.values(themes).map(theme => ({
23-
id: theme.id,
24-
name: theme.name,
25-
description: theme.description
26-
}));
27+
return THEME_CATALOG;
2728
}
2829

2930
export const availableThemes = ['minimal', 'standard'] as const;

0 commit comments

Comments
 (0)