@nuasite/nua 0.0.56 → 0.0.57

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.
Files changed (3) hide show
  1. package/README.md +47 -25
  2. package/package.json +10 -6
  3. package/src/config.ts +69 -0
package/README.md CHANGED
@@ -29,44 +29,66 @@ same toolchain will execute locally.
29
29
 
30
30
  ## Usage
31
31
 
32
- Add the unified Astro integration to your `astro.config.mjs`:
32
+ Use the nua config wrapper for the simplest setup:
33
33
 
34
- ```js
35
- // astro.config.mjs
36
- import nua from '@nuasite/nua/integration'
37
- import { defineConfig } from 'astro/config'
34
+ ```ts
35
+ // astro.config.ts
36
+ import { defineConfig } from '@nuasite/nua/config'
38
37
 
39
- export default defineConfig({
40
- integrations: [nua()],
41
- })
38
+ export default defineConfig()
42
39
  ```
43
40
 
44
- This single integration enables Tailwind CSS, MDX, sitemap generation,
45
- CMS markers, and page markdown output—all pre-configured.
41
+ This single line gives you:
42
+
43
+ - Tailwind CSS 4 via `@tailwindcss/vite`
44
+ - MDX support via `@astrojs/mdx`
45
+ - Sitemap generation via `@astrojs/sitemap`
46
+ - CMS markers via `@nuasite/cms-marker`
47
+ - Page markdown output via `@nuasite/page-markdown`
48
+ - Sensible defaults: `site: 'http://localhost:4321'`, `vite.build.sourcemap: true`
46
49
 
47
50
  ### Configuration options
48
51
 
49
- Each sub-integration can be disabled or customized:
52
+ Pass standard Astro config options, plus a `nua` key for integration settings:
53
+
54
+ ```ts
55
+ import { defineConfig } from '@nuasite/nua/config'
50
56
 
51
- ```js
52
57
  export default defineConfig({
53
- integrations: [
54
- nua({
55
- tailwindcss: true, // Enable/disable Tailwind CSS (default: true)
56
- mdx: true, // Enable/disable MDX support (default: true)
57
- sitemap: true, // Enable/disable sitemap generation (default: true)
58
- cmsMarker: true, // Enable/disable CMS markers (default: true)
59
- pageMarkdown: true, // Enable/disable page markdown output (default: true)
60
- }),
61
- ],
58
+ site: 'https://example.com',
59
+ nua: {
60
+ tailwindcss: true, // Enable/disable Tailwind CSS (default: true)
61
+ mdx: true, // Enable/disable MDX support (default: true)
62
+ sitemap: true, // Enable/disable sitemap generation (default: true)
63
+ cmsMarker: true, // Enable/disable CMS markers (default: true)
64
+ pageMarkdown: true, // Enable/disable page markdown output (default: true)
65
+ },
62
66
  })
63
67
  ```
64
68
 
65
69
  Pass `false` to disable a feature, or pass an options object to customize it:
66
70
 
67
- ```js
68
- nua({
69
- sitemap: { filter: (page) => !page.includes('/draft/') },
70
- mdx: { remarkPlugins: [myRemarkPlugin] },
71
+ ```ts
72
+ import { defineConfig } from '@nuasite/nua/config'
73
+
74
+ export default defineConfig({
75
+ nua: {
76
+ sitemap: { filter: (page) => !page.includes('/draft/') },
77
+ mdx: { remarkPlugins: [myRemarkPlugin] },
78
+ },
79
+ })
80
+ ```
81
+
82
+ ### Using the integration directly
83
+
84
+ If you prefer more control, import the integration separately:
85
+
86
+ ```ts
87
+ // astro.config.ts
88
+ import nua from '@nuasite/nua/integration'
89
+ import { defineConfig } from 'astro/config'
90
+
91
+ export default defineConfig({
92
+ integrations: [nua()],
71
93
  })
72
94
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuasite/nua",
3
- "version": "0.0.56",
3
+ "version": "0.0.57",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "module": "src/index.ts",
@@ -10,6 +10,10 @@
10
10
  "types": "./src/index.ts",
11
11
  "import": "./src/index.ts"
12
12
  },
13
+ "./config": {
14
+ "types": "./src/config.ts",
15
+ "import": "./src/config.ts"
16
+ },
13
17
  "./integration": {
14
18
  "types": "./src/integration.ts",
15
19
  "import": "./src/integration.ts"
@@ -35,11 +39,11 @@
35
39
  "@astrojs/mdx": "4.3.8",
36
40
  "@astrojs/rss": "4.0.13",
37
41
  "@astrojs/sitemap": "3.6.0",
38
- "@nuasite/page-markdown": "0.0.56",
39
- "@nuasite/cli": "0.0.56",
40
- "@nuasite/cms-marker": "0.0.56",
41
- "@nuasite/components": "0.0.56",
42
- "@nuasite/core": "0.0.56",
42
+ "@nuasite/page-markdown": "0.0.57",
43
+ "@nuasite/cli": "0.0.57",
44
+ "@nuasite/cms-marker": "0.0.57",
45
+ "@nuasite/components": "0.0.57",
46
+ "@nuasite/core": "0.0.57",
43
47
  "@tailwindcss/vite": "^4.1.11",
44
48
  "astro": "^5.16.6",
45
49
  "flowbite": "3.1.2",
package/src/config.ts ADDED
@@ -0,0 +1,69 @@
1
+ import { defineConfig as astroDefineConfig } from 'astro/config'
2
+ import type { AstroUserConfig } from 'astro/config'
3
+ import nua from './integration'
4
+ import type { NuaIntegrationOptions } from './types'
5
+
6
+ export type { NuaIntegrationOptions } from './types'
7
+
8
+ export interface NuaConfig extends AstroUserConfig {
9
+ /**
10
+ * Configure the nua integration options.
11
+ * Set to `false` to disable the nua integration entirely.
12
+ */
13
+ nua?: NuaIntegrationOptions | false
14
+ }
15
+
16
+ /**
17
+ * Wrapper around Astro's `defineConfig` with nua integration pre-configured.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * // astro.config.ts
22
+ * import { defineConfig } from '@nuasite/nua/config'
23
+ *
24
+ * export default defineConfig({
25
+ * site: 'https://example.com',
26
+ * })
27
+ * ```
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * // With nua options
32
+ * import { defineConfig } from '@nuasite/nua/config'
33
+ *
34
+ * export default defineConfig({
35
+ * site: 'https://example.com',
36
+ * nua: {
37
+ * sitemap: false,
38
+ * tailwindcss: true,
39
+ * },
40
+ * })
41
+ * ```
42
+ */
43
+ export function defineConfig(config: NuaConfig = {}) {
44
+ const { nua: nuaOptions, integrations = [], vite = {}, ...astroConfig } = config
45
+
46
+ const mergedVite = {
47
+ ...vite,
48
+ build: {
49
+ sourcemap: true,
50
+ ...vite.build,
51
+ },
52
+ }
53
+
54
+ const defaults = {
55
+ site: 'http://localhost:4321',
56
+ vite: mergedVite,
57
+ }
58
+
59
+ // If nua is explicitly disabled, just pass through to Astro
60
+ if (nuaOptions === false) {
61
+ return astroDefineConfig({ ...defaults, ...astroConfig, integrations })
62
+ }
63
+
64
+ return astroDefineConfig({
65
+ ...defaults,
66
+ ...astroConfig,
67
+ integrations: [nua(nuaOptions), ...integrations],
68
+ })
69
+ }