@brillout/docpress 0.16.25 → 0.16.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/+config.ts CHANGED
@@ -2,7 +2,7 @@ export { config as default }
2
2
 
3
3
  import type { Config } from 'vike/types'
4
4
  import { viteConfig } from './vite.config.js'
5
- import type { Config as DocpressConfig, ChoicesConfig } from './types/Config.js'
5
+ import type { Config as DocpressConfig } from './types/Config.js'
6
6
  import type { PageSection } from './parsePageSections.js'
7
7
  import type { Resolved } from './resolvePageContext.js'
8
8
 
@@ -21,10 +21,6 @@ const config = {
21
21
  env: { server: true, client: true, config: true },
22
22
  global: true,
23
23
  },
24
- choices: {
25
- env: { server: true, client: true, config: true },
26
- global: true,
27
- },
28
24
  },
29
25
  prefetch: {
30
26
  staticAssets: 'hover',
@@ -41,11 +37,9 @@ declare global {
41
37
  }
42
38
  interface Config {
43
39
  docpress?: DocpressConfig
44
- choices?: ChoicesConfig
45
40
  }
46
41
  interface ConfigResolved {
47
42
  docpress: DocpressConfig
48
- choices: ChoicesConfig
49
43
  pageSectionsExport: PageSection[] | undefined
50
44
  }
51
45
  }
@@ -111,7 +111,7 @@ function generateChoiceGroupCode(choiceNodes: ChoiceNode[], parent?: Parent): Md
111
111
  }
112
112
 
113
113
  function findChoiceGroup(vikeConfig: VikeConfig, choices: string[]) {
114
- const { choices: choicesConfig } = vikeConfig.config
114
+ const { choices: choicesConfig } = vikeConfig.config.docpress
115
115
  const choicesAll = { ...CHOICES_BUILT_IN, ...choicesConfig }
116
116
 
117
117
  const groupName = Object.keys(choicesAll).find((key) => {
@@ -1,3 +1,4 @@
1
- .highlighted {
1
+ .highlighted,
2
+ .highlighted-word {
2
3
  background: rgba(0, 0, 0, 0.1);
3
4
  }
package/dist/+config.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { config as default };
2
- import type { Config as DocpressConfig, ChoicesConfig } from './types/Config.js';
2
+ import type { Config as DocpressConfig } from './types/Config.js';
3
3
  import type { PageSection } from './parsePageSections.js';
4
4
  import type { Resolved } from './resolvePageContext.js';
5
5
  declare const config: {
@@ -25,14 +25,6 @@ declare const config: {
25
25
  };
26
26
  global: true;
27
27
  };
28
- choices: {
29
- env: {
30
- server: true;
31
- client: true;
32
- config: true;
33
- };
34
- global: true;
35
- };
36
28
  };
37
29
  prefetch: {
38
30
  staticAssets: "hover";
@@ -48,11 +40,9 @@ declare global {
48
40
  }
49
41
  interface Config {
50
42
  docpress?: DocpressConfig;
51
- choices?: ChoicesConfig;
52
43
  }
53
44
  interface ConfigResolved {
54
45
  docpress: DocpressConfig;
55
- choices: ChoicesConfig;
56
46
  pageSectionsExport: PageSection[] | undefined;
57
47
  }
58
48
  }
package/dist/+config.js CHANGED
@@ -15,10 +15,6 @@ const config = {
15
15
  env: { server: true, client: true, config: true },
16
16
  global: true,
17
17
  },
18
- choices: {
19
- env: { server: true, client: true, config: true },
20
- global: true,
21
- },
22
18
  },
23
19
  prefetch: {
24
20
  staticAssets: 'hover',
@@ -88,7 +88,7 @@ function generateChoiceGroupCode(choiceNodes, parent) {
88
88
  };
89
89
  }
90
90
  function findChoiceGroup(vikeConfig, choices) {
91
- const { choices: choicesConfig } = vikeConfig.config;
91
+ const { choices: choicesConfig } = vikeConfig.config.docpress;
92
92
  const choicesAll = { ...CHOICES_BUILT_IN, ...choicesConfig };
93
93
  const groupName = Object.keys(choicesAll).find((key) => {
94
94
  // get only the values that exist in both choices and choicesAll[key].choices
@@ -1,4 +1,4 @@
1
- export type { Config, ChoicesConfig };
1
+ export type { Config };
2
2
  import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading.js';
3
3
  import type React from 'react';
4
4
  type Config = {
@@ -39,6 +39,7 @@ type Config = {
39
39
  navLogoStyle?: React.CSSProperties;
40
40
  navLogoTextStyle?: React.CSSProperties;
41
41
  globalNote?: React.ReactNode;
42
+ choices?: Record<string, Choice>;
42
43
  };
43
44
  /** Order in Algolia search results */
44
45
  type Category = string | {
@@ -46,7 +47,6 @@ type Category = string | {
46
47
  /** Hide from Algolia search */
47
48
  hide?: boolean;
48
49
  };
49
- type ChoicesConfig = Record<string, Choice>;
50
50
  type Choice = {
51
51
  choices: string[];
52
52
  default: string;
@@ -5,7 +5,12 @@ import { parsePageSections } from './parsePageSections.js';
5
5
  import rehypePrettyCode from 'rehype-pretty-code';
6
6
  import remarkGfm from 'remark-gfm';
7
7
  import remarkDirective from 'remark-directive';
8
- import { transformerNotationDiff, transformerNotationHighlight } from '@shikijs/transformers';
8
+ import { transformerNotationDiff, transformerNotationWordHighlight } from '@shikijs/transformers';
9
+ // @brillout/shiki-transformers adds color parameter `[!code highlight:#abc]` where #abc is a color
10
+ // https://github.com/shikijs/shiki/issues/1264
11
+ // https://shiki.style/packages/transformers#transformernotationhighlight
12
+ // https://github.com/shikijs/shiki/compare/main...brillout:shiki:brillout/highlight-color-param
13
+ import { transformerNotationHighlight } from '@brillout/shiki-transformers';
9
14
  import { rehypeMetaToProps } from './code-blocks/rehypeMetaToProps.js';
10
15
  import { remarkDetype } from './code-blocks/remarkDetype.js';
11
16
  import { shikiTransformerAutoLinks } from './code-blocks/shikiTransformerAutoLinks.js';
@@ -17,7 +22,12 @@ const prettyCode = [
17
22
  {
18
23
  theme: 'github-light',
19
24
  keepBackground: false,
20
- transformers: [transformerNotationDiff(), transformerNotationHighlight(), shikiTransformerAutoLinks()],
25
+ transformers: [
26
+ transformerNotationDiff(),
27
+ transformerNotationHighlight(),
28
+ transformerNotationWordHighlight(),
29
+ shikiTransformerAutoLinks(),
30
+ ],
21
31
  },
22
32
  ];
23
33
  const rehypePlugins = [prettyCode, [rehypeMetaToProps]];
package/package.json CHANGED
@@ -1,15 +1,16 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.16.25",
3
+ "version": "0.16.26",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@brillout/picocolors": "^1.0.10",
7
+ "@brillout/shiki-transformers": "^4.0.2",
7
8
  "@docsearch/css": "3.9.0",
8
9
  "@docsearch/react": "3.9.0",
9
10
  "@mdx-js/mdx": "3.0.1",
10
11
  "@mdx-js/react": "3.0.1",
11
12
  "@mdx-js/rollup": "3.0.1",
12
- "@shikijs/transformers": "1.2.0",
13
+ "@shikijs/transformers": "^4.0.2",
13
14
  "@vitejs/plugin-react-swc": "^3.10.2",
14
15
  "detype": "^2.0.2",
15
16
  "estree-util-value-to-estree": "^3.5.0",
@@ -113,7 +113,7 @@ async function initUmami(pageContext: PageContextClient) {
113
113
  }
114
114
 
115
115
  // Simple way to plug in umami
116
- const umamiId = pageContext.config.docpress.umamiId;
116
+ const umamiId = pageContext.config.docpress.umamiId
117
117
  if (!umamiId) {
118
118
  return
119
119
  }
@@ -145,6 +145,6 @@ type Umami = {
145
145
  declare global {
146
146
  interface Window {
147
147
  /** Script load is not guaranteed */
148
- umami?: Umami;
148
+ umami?: Umami
149
149
  }
150
150
  }
package/types/Config.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { Config, ChoicesConfig }
1
+ export type { Config }
2
2
 
3
3
  import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading.js'
4
4
  import type React from 'react'
@@ -50,6 +50,7 @@ type Config = {
50
50
  navLogoTextStyle?: React.CSSProperties
51
51
 
52
52
  globalNote?: React.ReactNode
53
+ choices?: Record<string, Choice>
53
54
  }
54
55
 
55
56
  /** Order in Algolia search results */
@@ -61,8 +62,6 @@ type Category =
61
62
  hide?: boolean
62
63
  }
63
64
 
64
- type ChoicesConfig = Record<string, Choice>
65
-
66
65
  type Choice = {
67
66
  choices: string[]
68
67
  default: string
package/vite.config.ts CHANGED
@@ -7,7 +7,12 @@ import { parsePageSections } from './parsePageSections.js'
7
7
  import rehypePrettyCode from 'rehype-pretty-code'
8
8
  import remarkGfm from 'remark-gfm'
9
9
  import remarkDirective from 'remark-directive'
10
- import { transformerNotationDiff, transformerNotationHighlight } from '@shikijs/transformers'
10
+ import { transformerNotationDiff, transformerNotationWordHighlight } from '@shikijs/transformers'
11
+ // @brillout/shiki-transformers adds color parameter `[!code highlight:#abc]` where #abc is a color
12
+ // https://github.com/shikijs/shiki/issues/1264
13
+ // https://shiki.style/packages/transformers#transformernotationhighlight
14
+ // https://github.com/shikijs/shiki/compare/main...brillout:shiki:brillout/highlight-color-param
15
+ import { transformerNotationHighlight } from '@brillout/shiki-transformers'
11
16
  import { rehypeMetaToProps } from './code-blocks/rehypeMetaToProps.js'
12
17
  import { remarkDetype } from './code-blocks/remarkDetype.js'
13
18
  import { shikiTransformerAutoLinks } from './code-blocks/shikiTransformerAutoLinks.js'
@@ -20,7 +25,12 @@ const prettyCode = [
20
25
  {
21
26
  theme: 'github-light',
22
27
  keepBackground: false,
23
- transformers: [transformerNotationDiff(), transformerNotationHighlight(), shikiTransformerAutoLinks()],
28
+ transformers: [
29
+ transformerNotationDiff(),
30
+ transformerNotationHighlight(),
31
+ transformerNotationWordHighlight(),
32
+ shikiTransformerAutoLinks(),
33
+ ],
24
34
  },
25
35
  ]
26
36
  const rehypePlugins: any = [prettyCode, [rehypeMetaToProps]]