orga-build 0.6.3 → 0.7.0

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/README.org CHANGED
@@ -82,6 +82,10 @@ export default {
82
82
  // These are injected in dev SSR <head> and imported by the client entry.
83
83
  styles: ['/style.css'],
84
84
 
85
+ // Extra rehype plugins appended to orga-build defaults
86
+ // Useful for syntax highlighting (e.g. rehype-pretty-code).
87
+ rehypePlugins: [],
88
+
85
89
  // Additional Vite plugins
86
90
  vitePlugins: []
87
91
  }
@@ -95,8 +99,19 @@ export default {
95
99
  | =outDir= | =string= | ='out'= | Output directory for production build |
96
100
  | =containerClass= | =string \vert string[]= | =[]= | CSS class(es) for content wrapper |
97
101
  | =styles= | =string[]= | =[]= | Global stylesheet URLs injected/imported explicitly |
102
+ | =rehypePlugins= | =PluggableList= | =[]= | Extra rehype plugins appended to orga-build defaults |
98
103
  | =vitePlugins= | =PluginOption[]= | =[]= | Additional Vite plugins |
99
104
 
105
+ ** Syntax Highlighting Example
106
+
107
+ #+begin_src javascript
108
+ import rehypePrettyCode from 'rehype-pretty-code'
109
+
110
+ export default {
111
+ rehypePlugins: [[rehypePrettyCode, { theme: 'github-dark' }]]
112
+ }
113
+ #+end_src
114
+
100
115
  * TypeScript Setup
101
116
 
102
117
  If you're using TypeScript and want type support for the =orga-build:content= virtual module, you need to add a reference to the type definitions.
@@ -9,6 +9,21 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
9
  const fixtureDir = path.join(__dirname, 'fixtures')
10
10
  const outDir = path.join(__dirname, '.test-output')
11
11
 
12
+ function markCodeBlocks() {
13
+ /**
14
+ * @param {any} tree
15
+ */
16
+ return (tree) => {
17
+ tree.children ||= []
18
+ tree.children.unshift({
19
+ type: 'element',
20
+ tagName: 'div',
21
+ properties: { id: 'rehype-plugin-ran' },
22
+ children: []
23
+ })
24
+ }
25
+ }
26
+
12
27
  describe('orga-build', () => {
13
28
  before(async () => {
14
29
  await fs.mkdir(fixtureDir, { recursive: true })
@@ -111,4 +126,41 @@ Here's [[file:more.org][another page]].
111
126
  'built css should include configured global style content'
112
127
  )
113
128
  })
129
+
130
+ test('applies custom rehype plugins from config', async () => {
131
+ const fixtureDirRehype = path.join(__dirname, 'fixtures-rehype')
132
+ const outDirRehype = path.join(__dirname, '.test-output-rehype')
133
+
134
+ try {
135
+ await fs.mkdir(fixtureDirRehype, { recursive: true })
136
+ await fs.writeFile(
137
+ path.join(fixtureDirRehype, 'index.org'),
138
+ `#+title: Rehype Test
139
+
140
+ This page verifies custom rehype plugins.`
141
+ )
142
+
143
+ await build({
144
+ root: fixtureDirRehype,
145
+ outDir: outDirRehype,
146
+ containerClass: [],
147
+ rehypePlugins: [markCodeBlocks],
148
+ vitePlugins: [],
149
+ preBuild: [],
150
+ postBuild: []
151
+ })
152
+
153
+ const html = await fs.readFile(
154
+ path.join(outDirRehype, 'index.html'),
155
+ 'utf-8'
156
+ )
157
+ assert.ok(
158
+ html.includes('rehype-plugin-ran'),
159
+ 'should apply user-provided rehype plugins to rendered HTML'
160
+ )
161
+ } finally {
162
+ await fs.rm(outDirRehype, { recursive: true, force: true })
163
+ await fs.rm(fixtureDirRehype, { recursive: true, force: true })
164
+ }
165
+ })
114
166
  })
package/lib/build.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @param {import('./config.js').Config} config
3
3
  * @param {string} [projectRoot]
4
4
  */
5
- export function build({ outDir, root, containerClass, styles, vitePlugins }: import("./config.js").Config, projectRoot?: string): Promise<void>;
5
+ export function build({ outDir, root, containerClass, styles, rehypePlugins, vitePlugins }: import("./config.js").Config, projectRoot?: string): Promise<void>;
6
6
  export { alias };
7
7
  import { alias } from './plugin.js';
8
8
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,6EAHW,OAAO,aAAa,EAAE,MAAM,gBAC5B,MAAM,iBAsJhB;;sBAlK4C,aAAa"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.js"],"names":[],"mappings":"AAeA;;;GAGG;AACH,4FAHW,OAAO,aAAa,EAAE,MAAM,gBAC5B,MAAM,iBA8JhB;;sBA1K4C,aAAa"}
package/lib/build.js CHANGED
@@ -18,7 +18,14 @@ const defaultIndexHtml = fileURLToPath(new URL('./index.html', import.meta.url))
18
18
  * @param {string} [projectRoot]
19
19
  */
20
20
  export async function build(
21
- { outDir, root, containerClass, styles = [], vitePlugins = [] },
21
+ {
22
+ outDir,
23
+ root,
24
+ containerClass,
25
+ styles = [],
26
+ rehypePlugins = [],
27
+ vitePlugins = []
28
+ },
22
29
  projectRoot = process.cwd()
23
30
  ) {
24
31
  await emptyDir(outDir)
@@ -30,6 +37,7 @@ export async function build(
30
37
  outDir,
31
38
  containerClass,
32
39
  styles,
40
+ rehypePlugins,
33
41
  vitePlugins
34
42
  })
35
43
 
package/lib/config.d.ts CHANGED
@@ -20,5 +20,9 @@ export type Config = {
20
20
  * - Global stylesheet URLs injected in dev SSR and imported by client entry
21
21
  */
22
22
  styles?: string[];
23
+ /**
24
+ * - Extra rehype plugins appended to orga-build defaults
25
+ */
26
+ rehypePlugins?: import("unified").PluggableList;
23
27
  };
24
28
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":"AAyBA;;;GAGG;AACH,qCAHW,MAAM,EAAE,GACN,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA+C5D;;YArEa,MAAM;UACN,MAAM;cACN,MAAM,EAAE;eACR,MAAM,EAAE;;;;iBACR,OAAO,MAAM,EAAE,YAAY,EAAE;oBAC7B,MAAM,EAAE,GAAC,MAAM;;;;aACf,MAAM,EAAE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,qCAHW,MAAM,EAAE,GACN,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA+C5D;;YAvEa,MAAM;UACN,MAAM;cACN,MAAM,EAAE;eACR,MAAM,EAAE;;;;iBACR,OAAO,MAAM,EAAE,YAAY,EAAE;oBAC7B,MAAM,EAAE,GAAC,MAAM;;;;aACf,MAAM,EAAE;;;;oBACR,OAAO,SAAS,EAAE,aAAa"}
package/lib/config.js CHANGED
@@ -10,6 +10,7 @@ import path from 'node:path'
10
10
  * @property {import('vite').PluginOption[]} vitePlugins - Array of Vite plugins
11
11
  * @property {string[]|string} containerClass
12
12
  * @property {string[]} [styles] - Global stylesheet URLs injected in dev SSR and imported by client entry
13
+ * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
13
14
  */
14
15
 
15
16
  /** @type {Config} */
@@ -20,7 +21,8 @@ const defaultConfig = {
20
21
  postBuild: [],
21
22
  vitePlugins: [],
22
23
  containerClass: [],
23
- styles: []
24
+ styles: [],
25
+ rehypePlugins: []
24
26
  }
25
27
 
26
28
  /**
package/lib/orga.d.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  * @param {Object} options
3
3
  * @param {string|string[]} options.containerClass - CSS class name(s) to wrap the rendered content
4
4
  * @param {string} options.root - Root directory for content files
5
+ * @param {import('unified').PluggableList} [options.rehypePlugins] - Extra rehype plugins appended to defaults
5
6
  */
6
- export function setupOrga({ containerClass, root }: {
7
+ export function setupOrga({ containerClass, root, rehypePlugins }: {
7
8
  containerClass: string | string[];
8
9
  root: string;
10
+ rehypePlugins?: import("unified").PluggableList | undefined;
9
11
  }): import("@orgajs/rollup").Plugin;
10
12
  //# sourceMappingURL=orga.d.ts.map
package/lib/orga.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"orga.d.ts","sourceRoot":"","sources":["orga.js"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,oDAHG;IAAiC,cAAc,EAAvC,MAAM,GAAC,MAAM,EAAE;IACC,IAAI,EAApB,MAAM;CAChB,mCAYA"}
1
+ {"version":3,"file":"orga.d.ts","sourceRoot":"","sources":["orga.js"],"names":[],"mappings":"AAQA;;;;;GAKG;AACH,mEAJG;IAAiC,cAAc,EAAvC,MAAM,GAAC,MAAM,EAAE;IACC,IAAI,EAApB,MAAM;IACoC,aAAa;CACjE,mCAaA"}
package/lib/orga.js CHANGED
@@ -10,13 +10,15 @@ import { getSlugFromContentFilePath } from './files.js'
10
10
  * @param {Object} options
11
11
  * @param {string|string[]} options.containerClass - CSS class name(s) to wrap the rendered content
12
12
  * @param {string} options.root - Root directory for content files
13
+ * @param {import('unified').PluggableList} [options.rehypePlugins] - Extra rehype plugins appended to defaults
13
14
  */
14
- export function setupOrga({ containerClass, root }) {
15
+ export function setupOrga({ containerClass, root, rehypePlugins = [] }) {
15
16
  return _orga({
16
17
  rehypePlugins: [
17
18
  [rehypeWrap, { className: containerClass }],
18
19
  [rewriteOrgFileLinks, { root }],
19
- mediaAssets
20
+ mediaAssets,
21
+ ...rehypePlugins
20
22
  ],
21
23
  reorgRehypeOptions: {
22
24
  linkHref: (link) => link.path.value
package/lib/plugin.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * @property {string | undefined} [outDir] - Output directory (excluded from file discovery)
5
5
  * @property {string|string[]} [containerClass] - CSS class(es) to wrap rendered content
6
6
  * @property {string[]} [styles] - Global stylesheet URLs to import/inject
7
+ * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
7
8
  */
8
9
  /**
9
10
  * Creates the canonical orga-build plugin preset.
@@ -12,7 +13,7 @@
12
13
  * @param {OrgaBuildPluginOptions} options
13
14
  * @returns {import('vite').PluginOption[]}
14
15
  */
15
- export function orgaBuildPlugin({ root, outDir, containerClass, styles }: OrgaBuildPluginOptions): import("vite").PluginOption[];
16
+ export function orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePlugins }: OrgaBuildPluginOptions): import("vite").PluginOption[];
16
17
  /**
17
18
  * Creates the full Vite config options for orga-build.
18
19
  * Includes plugins, resolve aliases, and other shared config.
@@ -20,7 +21,7 @@ export function orgaBuildPlugin({ root, outDir, containerClass, styles }: OrgaBu
20
21
  * @param {OrgaBuildPluginOptions & { outDir?: string, vitePlugins?: import('vite').PluginOption[], includeFallbackHtml?: boolean, projectRoot?: string }} options
21
22
  * @returns {{ plugins: import('vite').PluginOption[], resolve: { alias: typeof alias } }}
22
23
  */
23
- export function createOrgaBuildConfig({ root, outDir, containerClass, styles, vitePlugins, includeFallbackHtml, projectRoot }: OrgaBuildPluginOptions & {
24
+ export function createOrgaBuildConfig({ root, outDir, containerClass, styles, rehypePlugins, vitePlugins, includeFallbackHtml, projectRoot }: OrgaBuildPluginOptions & {
24
25
  outDir?: string;
25
26
  vitePlugins?: import("vite").PluginOption[];
26
27
  includeFallbackHtml?: boolean;
@@ -71,5 +72,9 @@ export type OrgaBuildPluginOptions = {
71
72
  * - Global stylesheet URLs to import/inject
72
73
  */
73
74
  styles?: string[];
75
+ /**
76
+ * - Extra rehype plugins appended to orga-build defaults
77
+ */
78
+ rehypePlugins?: import("unified").PluggableList;
74
79
  };
75
80
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["plugin.js"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AAEH;;;;;;GAMG;AACH,0EAHW,sBAAsB,GACpB,OAAO,MAAM,EAAE,YAAY,EAAE,CAazC;AAED;;;;;;GAMG;AACH,+HAHW,sBAAsB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5I;IAAE,OAAO,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,KAAK,CAAA;KAAE,CAAA;CAAE,CAwBxF;AAiBD;;;;;;;;;;;;;GAaG;AACH,gDAJW,MAAM,WACN,MAAM,EAAE,GACN,OAAO,MAAM,EAAE,MAAM,CAmFjC;AAlLD;;GAEG;AACH;;;;EAIC;;;;;UAIa,MAAM;;;;aACN,MAAM,GAAG,SAAS;;;;qBAClB,MAAM,GAAC,MAAM,EAAE;;;;aACf,MAAM,EAAE"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["plugin.js"],"names":[],"mappings":"AAuBA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,yFAHW,sBAAsB,GACpB,OAAO,MAAM,EAAE,YAAY,EAAE,CAczC;AAED;;;;;;GAMG;AACH,8IAHW,sBAAsB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5I;IAAE,OAAO,EAAE,OAAO,MAAM,EAAE,YAAY,EAAE,CAAC;IAAC,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,KAAK,CAAA;KAAE,CAAA;CAAE,CAyBxF;AAiBD;;;;;;;;;;;;;GAaG;AACH,gDAJW,MAAM,WACN,MAAM,EAAE,GACN,OAAO,MAAM,EAAE,MAAM,CAmFjC;AArLD;;GAEG;AACH;;;;EAIC;;;;;UAIa,MAAM;;;;aACN,MAAM,GAAG,SAAS;;;;qBAClB,MAAM,GAAC,MAAM,EAAE;;;;aACf,MAAM,EAAE;;;;oBACR,OAAO,SAAS,EAAE,aAAa"}
package/lib/plugin.js CHANGED
@@ -27,6 +27,7 @@ export const alias = {
27
27
  * @property {string | undefined} [outDir] - Output directory (excluded from file discovery)
28
28
  * @property {string|string[]} [containerClass] - CSS class(es) to wrap rendered content
29
29
  * @property {string[]} [styles] - Global stylesheet URLs to import/inject
30
+ * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
30
31
  */
31
32
 
32
33
  /**
@@ -40,10 +41,11 @@ export function orgaBuildPlugin({
40
41
  root,
41
42
  outDir,
42
43
  containerClass = [],
43
- styles = []
44
+ styles = [],
45
+ rehypePlugins = []
44
46
  }) {
45
47
  return [
46
- setupOrga({ containerClass, root }),
48
+ setupOrga({ containerClass, root, rehypePlugins }),
47
49
  react(),
48
50
  pluginFactory({ dir: root, outDir, styles })
49
51
  ]
@@ -61,13 +63,14 @@ export function createOrgaBuildConfig({
61
63
  outDir,
62
64
  containerClass = [],
63
65
  styles = [],
66
+ rehypePlugins = [],
64
67
  vitePlugins = [],
65
68
  includeFallbackHtml = false,
66
69
  projectRoot = process.cwd()
67
70
  }) {
68
71
  const plugins = [
69
72
  ...vitePlugins,
70
- ...orgaBuildPlugin({ root, outDir, containerClass, styles })
73
+ ...orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePlugins })
71
74
  ]
72
75
  if (includeFallbackHtml) {
73
76
  // HTML fallback must be first so it can handle HTML navigation requests
@@ -1 +1 @@
1
- {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["serve.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,8BAJW,OAAO,aAAa,EAAE,MAAM,SAC5B,MAAM,gBACN,MAAM,iBAsChB"}
1
+ {"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["serve.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,8BAJW,OAAO,aAAa,EAAE,MAAM,SAC5B,MAAM,gBACN,MAAM,iBAuChB"}
package/lib/serve.js CHANGED
@@ -15,6 +15,7 @@ export async function serve(config, port = 3000, projectRoot = process.cwd()) {
15
15
  outDir: config.outDir,
16
16
  containerClass: config.containerClass,
17
17
  styles: config.styles ?? [],
18
+ rehypePlugins: config.rehypePlugins ?? [],
18
19
  vitePlugins: config.vitePlugins,
19
20
  includeFallbackHtml: true,
20
21
  projectRoot
package/lib/vite.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["vite.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,uDALG;IAAwB,GAAG,EAAnB,MAAM;IACW,MAAM;IACJ,MAAM;CACjC,GAAU,OAAO,MAAM,EAAE,MAAM,CA8JjC;AAvKD,gDAAuD"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["vite.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,uDALG;IAAwB,GAAG,EAAnB,MAAM;IACW,MAAM;IACJ,MAAM;CACjC,GAAU,OAAO,MAAM,EAAE,MAAM,CAoJjC;AA7JD,gDAAuD"}
package/lib/vite.js CHANGED
@@ -25,16 +25,6 @@ export function pluginFactory({ dir, outDir, styles = [] }) {
25
25
  removePluginHookSsrArgument: 'warn',
26
26
  removePluginHookHandleHotUpdate: 'warn',
27
27
  removeSsrLoadModule: 'warn'
28
- },
29
- optimizeDeps: {
30
- include: [
31
- 'react',
32
- 'react/jsx-runtime',
33
- 'react-dom',
34
- 'react-dom/client',
35
- 'wouter'
36
- ],
37
- exclude: ['orga-build']
38
28
  }
39
29
  }),
40
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orga-build",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "description": "A simple tool that builds org-mode files into a website",
5
5
  "type": "module",
6
6
  "engines": {
@@ -48,6 +48,7 @@
48
48
  "react": "^19.0.0",
49
49
  "react-dom": "^19.0.0",
50
50
  "rehype-katex": "^7.0.1",
51
+ "unified": "^11.0.5",
51
52
  "unist-util-visit-parents": "^6.0.1",
52
53
  "vite": "^7.3.1",
53
54
  "wouter": "^3.7.0",
@@ -55,7 +56,7 @@
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/hast": "^3.0.4",
58
- "@types/node": "^22.13.1",
59
+ "@types/node": "^25.3.2",
59
60
  "@types/react": "^19.0.8",
60
61
  "@types/react-dom": "^19.0.3",
61
62
  "orga": "4.7.1"