-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapplication.ts
59 lines (52 loc) · 1.7 KB
/
application.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Route from '@ember/routing/route';
import { service } from '@ember/service';
import rehypeShikiFromHighlighter from '@shikijs/rehype/core';
import { colorScheme, sync } from 'ember-primitives/color-scheme';
import { getHighlighterCore } from 'shiki/core';
import getWasm from 'shiki/wasm';
sync();
import type { DocsService, Manifest } from 'kolay';
export default class ApplicationRoute extends Route {
@service('kolay/docs') declare docs: DocsService;
async model(): Promise<{ manifest: Manifest }> {
const highlighter = await getHighlighterCore({
themes: [import('shiki/themes/github-dark.mjs'), import('shiki/themes/github-light.mjs')],
langs: [
import('shiki/langs/javascript.mjs'),
import('shiki/langs/typescript.mjs'),
import('shiki/langs/bash.mjs'),
import('shiki/langs/css.mjs'),
import('shiki/langs/html.mjs'),
import('shiki/langs/glimmer-js.mjs'),
import('shiki/langs/glimmer-ts.mjs'),
],
langAlias: {
gjs: 'glimmer-js',
gts: 'glimmer-ts',
},
loadWasm: getWasm,
});
await this.docs.setup({
apiDocs: import('kolay/api-docs:virtual'),
manifest: import('kolay/manifest:virtual'),
resolve: {
'ember-primitives': import('ember-primitives'),
kolay: import('kolay'),
},
rehypePlugins: [
[
rehypeShikiFromHighlighter,
highlighter,
{
defaultColor: colorScheme.current === 'dark' ? 'dark' : 'light',
themes: {
light: 'github-light',
dark: 'github-dark',
},
},
],
],
});
return { manifest: this.docs.manifest };
}
}