File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import 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 に切り替え(未選択テーマをバンドルしない)
104export 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
1514export 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+
2126export 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
2930export const availableThemes = [ 'minimal' , 'standard' ] as const ;
You can’t perform that action at this time.
0 commit comments