orga-build 0.8.0 → 0.9.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
@@ -78,29 +78,35 @@ export default {
78
78
  // CSS class(es) to wrap rendered org content
79
79
  containerClass: ['prose', 'prose-lg'],
80
80
 
81
- // Global stylesheet URLs (explicit, no magic files)
82
- // These are injected in dev SSR <head> and imported by the client entry.
83
- styles: ['/style.css'],
81
+ // Global stylesheets paths relative to orga.config.js (leading / optional).
82
+ // Injected in dev SSR <head> and imported by the client entry.
83
+ styles: ['pages/style.css'],
84
84
 
85
85
  // Extra rehype plugins appended to orga-build defaults
86
86
  // Useful for syntax highlighting (e.g. rehype-pretty-code).
87
87
  rehypePlugins: [],
88
88
 
89
89
  // Additional Vite plugins
90
- vitePlugins: []
90
+ vitePlugins: [],
91
+
92
+ // Glob patterns (relative to root) to exclude from content scanning.
93
+ // Useful for generated or declaration files that must live inside root
94
+ // but should not be treated as pages or endpoints.
95
+ exclude: ['**/*.d.ts']
91
96
  }
92
97
  #+end_src
93
98
 
94
99
  ** Configuration Options
95
100
 
96
- | Option | Type | Default | Description |
97
- |----------------+-------------------+---------+------------------------------------------------------|
98
- | =root= | =string= | ='pages'= | Directory containing content files |
99
- | =outDir= | =string= | ='out'= | Output directory for production build |
100
- | =containerClass= | =string \vert string[]= | =[]= | CSS class(es) for content wrapper |
101
- | =styles= | =string[]= | =[]= | Global stylesheet URLs injected/imported explicitly |
102
- | =rehypePlugins= | =PluggableList= | =[]= | Extra rehype plugins appended to orga-build defaults |
103
- | =vitePlugins= | =PluginOption[]= | =[]= | Additional Vite plugins |
101
+ | Option | Type | Default | Description |
102
+ |----------------+-------------------+---------+-----------------------------------------------------------------|
103
+ | =root= | =string= | ='pages'= | Directory containing content files |
104
+ | =outDir= | =string= | ='out'= | Output directory for production build |
105
+ | =containerClass= | =string \vert string[]= | =[]= | CSS class(es) for content wrapper |
106
+ | =styles= | =string[]= | =[]= | Stylesheets to inject/import; paths relative to =orga.config.js= |
107
+ | =exclude= | =string[]= | =[]= | Glob patterns (relative to =root=) excluded from content scanning |
108
+ | =rehypePlugins= | =PluggableList= | =[]= | Extra rehype plugins appended to orga-build defaults |
109
+ | =vitePlugins= | =PluginOption[]= | =[]= | Additional Vite plugins |
104
110
 
105
111
  ** Syntax Highlighting Example
106
112
 
@@ -116,11 +116,13 @@ export function GET() {
116
116
  })
117
117
 
118
118
  test('processes configured global styles through vite and injects built css', async () => {
119
+ const styleUrl =
120
+ '/' + path.relative(process.cwd(), path.join(fixtureDir, 'style.css'))
119
121
  await build({
120
122
  root: fixtureDir,
121
123
  outDir: outDir,
122
124
  containerClass: [],
123
- styles: ['/style.css'],
125
+ styles: [styleUrl],
124
126
  vitePlugins: [],
125
127
  preBuild: [],
126
128
  postBuild: []
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, rehypePlugins, vitePlugins }: import("./config.js").Config, projectRoot?: string): Promise<void>;
5
+ export function build({ outDir, root, containerClass, styles, rehypePlugins, vitePlugins, exclude }: 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":"AAgBA;;;GAGG;AACH,4FAHW,OAAO,aAAa,EAAE,MAAM,gBAC5B,MAAM,iBAyLhB;;sBArM4C,aAAa"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["build.js"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,qGAHW,OAAO,aAAa,EAAE,MAAM,gBAC5B,MAAM,iBA0LhB;;sBAtM4C,aAAa"}
package/lib/build.js CHANGED
@@ -25,7 +25,8 @@ export async function build(
25
25
  containerClass,
26
26
  styles = [],
27
27
  rehypePlugins = [],
28
- vitePlugins = []
28
+ vitePlugins = [],
29
+ exclude = []
29
30
  },
30
31
  projectRoot = process.cwd()
31
32
  ) {
@@ -39,12 +40,12 @@ export async function build(
39
40
  containerClass,
40
41
  styles,
41
42
  rehypePlugins,
42
- vitePlugins
43
+ vitePlugins,
44
+ exclude
43
45
  })
44
46
 
45
47
  // Shared config with environment-specific build settings
46
48
  const builder = await createBuilder({
47
- root,
48
49
  plugins,
49
50
  resolve,
50
51
  ssr: { noExternal: true },
package/lib/config.d.ts CHANGED
@@ -24,5 +24,9 @@ export type Config = {
24
24
  * - Extra rehype plugins appended to orga-build defaults
25
25
  */
26
26
  rehypePlugins?: import("unified").PluggableList;
27
+ /**
28
+ * - Glob patterns for files to exclude from content scanning
29
+ */
30
+ exclude?: string[];
27
31
  };
28
32
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["config.js"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,qCAHW,MAAM,EAAE,GACN,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAiD5D;;YA3Ea,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;;;;cAC/B,MAAM,EAAE"}
package/lib/config.js CHANGED
@@ -11,6 +11,7 @@ import path from 'node:path'
11
11
  * @property {string[]|string} containerClass
12
12
  * @property {string[]} [styles] - Global stylesheet URLs injected in dev SSR and imported by client entry
13
13
  * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
14
+ * @property {string[]} [exclude] - Glob patterns for files to exclude from content scanning
14
15
  */
15
16
 
16
17
  /** @type {Config} */
@@ -22,7 +23,8 @@ const defaultConfig = {
22
23
  vitePlugins: [],
23
24
  containerClass: [],
24
25
  styles: [],
25
- rehypePlugins: []
26
+ rehypePlugins: [],
27
+ exclude: []
26
28
  }
27
29
 
28
30
  /**
@@ -68,7 +70,9 @@ export async function loadConfig(...files) {
68
70
  result.outDir = resolveConfigPath(result.outDir)
69
71
  const styles = result.styles
70
72
  result.styles = Array.isArray(styles)
71
- ? styles.filter((v) => typeof v === 'string')
73
+ ? styles
74
+ .filter((v) => typeof v === 'string')
75
+ .map((v) => '/' + v.replace(/^\/+/, ''))
72
76
  : []
73
77
  return {
74
78
  config: result,
package/lib/files.d.ts CHANGED
@@ -2,9 +2,11 @@
2
2
  * @param {string} dir
3
3
  * @param {object} [options]
4
4
  * @param {string} [options.outDir] - Output directory to exclude from file discovery
5
+ * @param {string[]} [options.exclude] - Additional glob patterns to exclude from file discovery
5
6
  */
6
- export function setup(dir: string, { outDir }?: {
7
+ export function setup(dir: string, { outDir, exclude }?: {
7
8
  outDir?: string | undefined;
9
+ exclude?: string[] | undefined;
8
10
  }): {
9
11
  pages: (() => Promise<Record<string, Page>>) & {
10
12
  invalidate: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["files.js"],"names":[],"mappings":"AAoFA;;;;GAIG;AACH,2BAJW,MAAM,eAEd;IAAyB,MAAM;CACjC;;0BA0LqD,IAAI;;iBApB7C,MAAM;;0BAoBmC,IAAI;;sBAd7C,MAAM;;0BAcmC,IAAI;;;0BAAJ,IAAI;;;0BAAJ,IAAI;;;EATzD;AA8BD;;;GAGG;AACH,4DAFW,MAAM,UAoBhB;;cAtTa,MAAM;;;;YACN,MAAM;;;WAMN,MAAM;cACN,MAAM;;;QAKN,MAAM;UACN,MAAM;UACN,MAAM;cACN,MAAM;SACN,KAAK,GAAG,KAAK,GAAG,KAAK;UACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC"}
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["files.js"],"names":[],"mappings":"AAoFA;;;;;GAKG;AACH,2BALW,MAAM,wBAEd;IAAyB,MAAM;IACJ,OAAO;CACpC;;0BA6LqD,IAAI;;iBApB7C,MAAM;;0BAoBmC,IAAI;;sBAd7C,MAAM;;0BAcmC,IAAI;;;0BAAJ,IAAI;;;0BAAJ,IAAI;;;EATzD;AA8BD;;;GAGG;AACH,4DAFW,MAAM,UAoBhB;;cA1Ta,MAAM;;;;YACN,MAAM;;;WAMN,MAAM;cACN,MAAM;;;QAKN,MAAM;UACN,MAAM;UACN,MAAM;cACN,MAAM;SACN,KAAK,GAAG,KAAK,GAAG,KAAK;UACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC"}
package/lib/files.js CHANGED
@@ -86,8 +86,9 @@ function getContentId(slug) {
86
86
  * @param {string} dir
87
87
  * @param {object} [options]
88
88
  * @param {string} [options.outDir] - Output directory to exclude from file discovery
89
+ * @param {string[]} [options.exclude] - Additional glob patterns to exclude from file discovery
89
90
  */
90
- export function setup(dir, { outDir } = {}) {
91
+ export function setup(dir, { outDir, exclude = [] } = {}) {
91
92
  const outDirRelative = outDir ? path.relative(dir, outDir) : null
92
93
  // Only exclude outDir if it's inside the root (not an external path like ../out)
93
94
  const outDirExclude =
@@ -104,7 +105,8 @@ export function setup(dir, { outDir } = {}) {
104
105
  '!**/.*/**',
105
106
  '!**/.*',
106
107
  '!node_modules/**',
107
- ...(outDirExclude ? [outDirExclude] : [])
108
+ ...(outDirExclude ? [outDirExclude] : []),
109
+ ...exclude.map((p) => `!${p}`)
108
110
  ],
109
111
  { cwd: dir }
110
112
  )
@@ -155,7 +157,8 @@ export function setup(dir, { outDir } = {}) {
155
157
  '!**/.*/**',
156
158
  '!**/.*',
157
159
  '!node_modules/**',
158
- ...(outDirExclude ? [outDirExclude] : [])
160
+ ...(outDirExclude ? [outDirExclude] : []),
161
+ ...exclude.map((p) => `!${p}`)
159
162
  ],
160
163
  {
161
164
  cwd: dir
@@ -179,7 +182,8 @@ export function setup(dir, { outDir } = {}) {
179
182
  '!**/.*/**',
180
183
  '!**/.*',
181
184
  '!node_modules/**',
182
- ...(outDirExclude ? [outDirExclude] : [])
185
+ ...(outDirExclude ? [outDirExclude] : []),
186
+ ...exclude.map((p) => `!${p}`)
183
187
  ],
184
188
  {
185
189
  cwd: dir
package/lib/plugin.d.ts CHANGED
@@ -5,6 +5,7 @@
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
7
  * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
8
+ * @property {string[]} [exclude] - Glob patterns for files to exclude from content scanning
8
9
  */
9
10
  /**
10
11
  * Creates the canonical orga-build plugin preset.
@@ -13,7 +14,7 @@
13
14
  * @param {OrgaBuildPluginOptions} options
14
15
  * @returns {import('vite').PluginOption[]}
15
16
  */
16
- export function orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePlugins }: OrgaBuildPluginOptions): import("vite").PluginOption[];
17
+ export function orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePlugins, exclude }: OrgaBuildPluginOptions): import("vite").PluginOption[];
17
18
  /**
18
19
  * Creates the full Vite config options for orga-build.
19
20
  * Includes plugins, resolve aliases, and other shared config.
@@ -21,7 +22,7 @@ export function orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePl
21
22
  * @param {OrgaBuildPluginOptions & { outDir?: string, vitePlugins?: import('vite').PluginOption[], includeFallbackHtml?: boolean, projectRoot?: string }} options
22
23
  * @returns {{ plugins: import('vite').PluginOption[], resolve: { alias: typeof alias } }}
23
24
  */
24
- export function createOrgaBuildConfig({ root, outDir, containerClass, styles, rehypePlugins, vitePlugins, includeFallbackHtml, projectRoot }: OrgaBuildPluginOptions & {
25
+ export function createOrgaBuildConfig({ root, outDir, containerClass, styles, rehypePlugins, vitePlugins, includeFallbackHtml, projectRoot, exclude }: OrgaBuildPluginOptions & {
25
26
  outDir?: string;
26
27
  vitePlugins?: import("vite").PluginOption[];
27
28
  includeFallbackHtml?: boolean;
@@ -76,5 +77,9 @@ export type OrgaBuildPluginOptions = {
76
77
  * - Extra rehype plugins appended to orga-build defaults
77
78
  */
78
79
  rehypePlugins?: import("unified").PluggableList;
80
+ /**
81
+ * - Glob patterns for files to exclude from content scanning
82
+ */
83
+ exclude?: string[];
79
84
  };
80
85
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["plugin.js"],"names":[],"mappings":"AAwBA;;;;;;;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,CAsHjC;AAxND;;GAEG;AACH;;;;EAIC;;;;;UAIa,MAAM;;;;aACN,MAAM,GAAG,SAAS;;;;qBAClB,MAAM,GAAC,MAAM,EAAE;;;;aACf,MAAM,EAAE;;;;oBACR,OAAO,SAAS,EAAE,aAAa"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["plugin.js"],"names":[],"mappings":"AAwBA;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,kGAHW,sBAAsB,GACpB,OAAO,MAAM,EAAE,YAAY,EAAE,CAezC;AAED;;;;;;GAMG;AACH,uJAHW,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,CAiCxF;AAiBD;;;;;;;;;;;;;GAaG;AACH,gDAJW,MAAM,WACN,MAAM,EAAE,GACN,OAAO,MAAM,EAAE,MAAM,CAsHjC;AAlOD;;GAEG;AACH;;;;EAIC;;;;;UAIa,MAAM;;;;aACN,MAAM,GAAG,SAAS;;;;qBAClB,MAAM,GAAC,MAAM,EAAE;;;;aACf,MAAM,EAAE;;;;oBACR,OAAO,SAAS,EAAE,aAAa;;;;cAC/B,MAAM,EAAE"}
package/lib/plugin.js CHANGED
@@ -29,6 +29,7 @@ export const alias = {
29
29
  * @property {string|string[]} [containerClass] - CSS class(es) to wrap rendered content
30
30
  * @property {string[]} [styles] - Global stylesheet URLs to import/inject
31
31
  * @property {import('unified').PluggableList} [rehypePlugins] - Extra rehype plugins appended to orga-build defaults
32
+ * @property {string[]} [exclude] - Glob patterns for files to exclude from content scanning
32
33
  */
33
34
 
34
35
  /**
@@ -43,12 +44,13 @@ export function orgaBuildPlugin({
43
44
  outDir,
44
45
  containerClass = [],
45
46
  styles = [],
46
- rehypePlugins = []
47
+ rehypePlugins = [],
48
+ exclude = []
47
49
  }) {
48
50
  return [
49
51
  setupOrga({ containerClass, root, rehypePlugins }),
50
52
  react(),
51
- pluginFactory({ dir: root, outDir, styles })
53
+ pluginFactory({ dir: root, outDir, styles, exclude })
52
54
  ]
53
55
  }
54
56
 
@@ -67,11 +69,19 @@ export function createOrgaBuildConfig({
67
69
  rehypePlugins = [],
68
70
  vitePlugins = [],
69
71
  includeFallbackHtml = false,
70
- projectRoot = process.cwd()
72
+ projectRoot = process.cwd(),
73
+ exclude = []
71
74
  }) {
72
75
  const plugins = [
73
76
  ...vitePlugins,
74
- ...orgaBuildPlugin({ root, outDir, containerClass, styles, rehypePlugins })
77
+ ...orgaBuildPlugin({
78
+ root,
79
+ outDir,
80
+ containerClass,
81
+ styles,
82
+ rehypePlugins,
83
+ exclude
84
+ })
75
85
  ]
76
86
  if (includeFallbackHtml) {
77
87
  // HTML fallback must be first so it can handle HTML navigation requests
package/lib/serve.js CHANGED
@@ -18,11 +18,11 @@ export async function serve(config, port = 3000, projectRoot = process.cwd()) {
18
18
  rehypePlugins: config.rehypePlugins ?? [],
19
19
  vitePlugins: config.vitePlugins,
20
20
  includeFallbackHtml: true,
21
- projectRoot
21
+ projectRoot,
22
+ exclude: config.exclude ?? []
22
23
  })
23
24
 
24
25
  const server = await createServer({
25
- root: config.root,
26
26
  plugins,
27
27
  appType: 'custom',
28
28
  // Aliases are scoped to the client environment only.
package/lib/vite.d.ts CHANGED
@@ -3,12 +3,14 @@
3
3
  * @param {string} options.dir
4
4
  * @param {string} [options.outDir]
5
5
  * @param {string[]} [options.styles]
6
+ * @param {string[]} [options.exclude]
6
7
  * @returns {import('vite').Plugin}
7
8
  */
8
- export function pluginFactory({ dir, outDir, styles }: {
9
+ export function pluginFactory({ dir, outDir, styles, exclude }: {
9
10
  dir: string;
10
11
  outDir?: string | undefined;
11
12
  styles?: string[] | undefined;
13
+ exclude?: string[] | undefined;
12
14
  }): import("vite").Plugin;
13
15
  export const appEntryId: "/@orga-build/main.js";
14
16
  //# sourceMappingURL=vite.d.ts.map
package/lib/vite.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["vite.js"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,uDALG;IAAwB,GAAG,EAAnB,MAAM;IACW,MAAM;IACJ,MAAM;CACjC,GAAU,OAAO,MAAM,EAAE,MAAM,CA4LjC;AAtMD,gDAAuD"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["vite.js"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,gEANG;IAAwB,GAAG,EAAnB,MAAM;IACW,MAAM;IACJ,MAAM;IACN,OAAO;CAClC,GAAU,OAAO,MAAM,EAAE,MAAM,CA4LjC;AAvMD,gDAAuD"}
package/lib/vite.js CHANGED
@@ -14,10 +14,11 @@ const endpointModulePrefix = `${endpointsModuleId}/__route__/`
14
14
  * @param {string} options.dir
15
15
  * @param {string} [options.outDir]
16
16
  * @param {string[]} [options.styles]
17
+ * @param {string[]} [options.exclude]
17
18
  * @returns {import('vite').Plugin}
18
19
  */
19
- export function pluginFactory({ dir, outDir, styles = [] }) {
20
- const files = setup(dir, { outDir })
20
+ export function pluginFactory({ dir, outDir, styles = [], exclude = [] }) {
21
+ const files = setup(dir, { outDir, exclude })
21
22
 
22
23
  return {
23
24
  name: 'vite-plugin-orga-pages',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orga-build",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A simple tool that builds org-mode files into a website",
5
5
  "type": "module",
6
6
  "engines": {