1- import { shiki } from '@node-core/rehype-shiki' ;
1+ import { LANGS } from '@node-core/rehype-shiki' ;
22
33/**
44 * Constructs a set of static, minimal data to send from server to client.
@@ -14,32 +14,11 @@ export const createStaticData = () => {
1414 // Create a display name map with aliases from Shiki's loaded languages
1515 const shikiDisplayNameMap = [
1616 ...new Map (
17- // 1. Get all currently loaded language identifiers (e.g., 'js', 'ts', 'python')
18- shiki
19- . getLoadedLanguages ( )
20-
21- // 2. Map each ID to its full language object
22- . map ( shiki . getLanguage )
23-
24- // 3. Extract:
25- // - `name`: canonical ID (e.g., "javascript")
26- // - `_grammar.aliases`: alternate names for the language (e.g., ["js"])
27- // - `displayName`: user-friendly name for UI (e.g., "JavaScript")
28- //
29- // 4. Build key-value pairs of:
30- // name => [[aliases + name], displayName]
31- //
32- // Example output:
33- // "javascript" => [["js", "javascript"], "JavaScript"]
34- //
35- // This structure allows clients to match by any alias and still show a clean label.
36- . map ( ( { name, _grammar : { aliases = [ ] , displayName } } ) => [
37- name ,
38- [ [ ...aliases , name ] , displayName ] ,
39- ] )
40-
41- // Step 5: Deduplicate by canonical name using a `Map`
42- // The `Map` constructor ensures uniqueness by key (`name`)
17+ // Get all languages, and map aliases to display names
18+ LANGS . map ( ( { name, aliases = [ ] , displayName } ) => [
19+ name ,
20+ [ [ ...aliases , name ] , displayName ] ,
21+ ] )
4322 ) . values ( ) , // Get just the values (alias/displayName pairs)
4423 ] ;
4524
0 commit comments