@nuasite/nua 0.0.52 → 0.0.54

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.md CHANGED
@@ -26,3 +26,47 @@ This ensures every developer machine and CI job installs the same stack that
26
26
  Nua Site uses when publishing your project. After installing, run your normal
27
27
  build command (for example `bunx nua-build` or `bun run build`) and the exact
28
28
  same toolchain will execute locally.
29
+
30
+ ## Usage
31
+
32
+ Add the unified Astro integration to your `astro.config.mjs`:
33
+
34
+ ```js
35
+ // astro.config.mjs
36
+ import nua from '@nuasite/nua/integration'
37
+ import { defineConfig } from 'astro/config'
38
+
39
+ export default defineConfig({
40
+ integrations: [nua()],
41
+ })
42
+ ```
43
+
44
+ This single integration enables Tailwind CSS, MDX, sitemap generation,
45
+ CMS markers, and page markdown output—all pre-configured.
46
+
47
+ ### Configuration options
48
+
49
+ Each sub-integration can be disabled or customized:
50
+
51
+ ```js
52
+ 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
+ ],
62
+ })
63
+ ```
64
+
65
+ Pass `false` to disable a feature, or pass an options object to customize it:
66
+
67
+ ```js
68
+ nua({
69
+ sitemap: { filter: (page) => !page.includes('/draft/') },
70
+ mdx: { remarkPlugins: [myRemarkPlugin] },
71
+ })
72
+ ```
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "@nuasite/nua",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
+ "type": "module",
4
5
  "license": "Apache-2.0",
6
+ "module": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.ts",
11
+ "import": "./src/index.ts"
12
+ },
13
+ "./integration": {
14
+ "types": "./src/integration.ts",
15
+ "import": "./src/integration.ts"
16
+ }
17
+ },
5
18
  "files": [
6
19
  "dist/**",
7
20
  "src/**",
@@ -22,10 +35,11 @@
22
35
  "@astrojs/mdx": "4.3.8",
23
36
  "@astrojs/rss": "4.0.13",
24
37
  "@astrojs/sitemap": "3.6.0",
25
- "@nuasite/cli": "0.0.52",
26
- "@nuasite/cms-marker": "0.0.52",
27
- "@nuasite/components": "0.0.52",
28
- "@nuasite/core": "0.0.52",
38
+ "@nuasite/page-markdown": "0.0.54",
39
+ "@nuasite/cli": "0.0.54",
40
+ "@nuasite/cms-marker": "0.0.54",
41
+ "@nuasite/components": "0.0.54",
42
+ "@nuasite/core": "0.0.54",
29
43
  "@tailwindcss/vite": "^4.1.11",
30
44
  "astro": "^5.16.6",
31
45
  "flowbite": "3.1.2",
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default, default as nua } from './integration'
2
+ export type { CmsMarkerOptions, MdxOptions, NuaIntegrationOptions, PageMarkdownOptions, ResolvedIntegrationOptions, SitemapOptions } from './types'
@@ -0,0 +1,57 @@
1
+ import mdx from '@astrojs/mdx'
2
+ import sitemap from '@astrojs/sitemap'
3
+ import cmsMarker from '@nuasite/cms-marker'
4
+ import pageMarkdown from '@nuasite/page-markdown'
5
+ import tailwindcss from '@tailwindcss/vite'
6
+ import type { AstroIntegration } from 'astro'
7
+ import { type NuaIntegrationOptions, resolveOptions } from './types'
8
+
9
+ export default function nua(options: NuaIntegrationOptions = {}): AstroIntegration {
10
+ const resolved = resolveOptions(options)
11
+
12
+ return {
13
+ name: '@nuasite/nua',
14
+ hooks: {
15
+ 'astro:config:setup': ({ updateConfig, logger }) => {
16
+ const integrations: AstroIntegration[] = []
17
+ const vitePlugins: unknown[] = []
18
+
19
+ // Add Tailwind CSS Vite plugin
20
+ if (resolved.tailwindcss) {
21
+ vitePlugins.push(tailwindcss())
22
+ logger.info('Tailwind CSS enabled')
23
+ }
24
+
25
+ // Add nuasite integrations
26
+ if (resolved.cmsMarker !== false) {
27
+ integrations.push(cmsMarker(resolved.cmsMarker))
28
+ logger.info('CMS Marker enabled')
29
+ }
30
+
31
+ if (resolved.pageMarkdown !== false) {
32
+ integrations.push(pageMarkdown(resolved.pageMarkdown))
33
+ logger.info('Page Markdown enabled')
34
+ }
35
+
36
+ // Add official Astro integrations
37
+ if (resolved.mdx !== false) {
38
+ integrations.push(mdx(resolved.mdx))
39
+ logger.info('MDX enabled')
40
+ }
41
+
42
+ if (resolved.sitemap !== false) {
43
+ integrations.push(sitemap(resolved.sitemap))
44
+ logger.info('Sitemap enabled')
45
+ }
46
+
47
+ // Inject Vite plugins and integrations
48
+ updateConfig({
49
+ vite: {
50
+ plugins: vitePlugins,
51
+ },
52
+ integrations,
53
+ })
54
+ },
55
+ },
56
+ }
57
+ }
package/src/types.ts ADDED
@@ -0,0 +1,49 @@
1
+ import type { Options as MdxOptions } from '@astrojs/mdx'
2
+ import type { SitemapOptions } from '@astrojs/sitemap'
3
+ import type { CmsMarkerOptions } from '@nuasite/cms-marker'
4
+ import type { PageMarkdownOptions } from '@nuasite/page-markdown'
5
+
6
+ export type { Options as MdxOptions } from '@astrojs/mdx'
7
+ export type { SitemapOptions } from '@astrojs/sitemap'
8
+ export type { CmsMarkerOptions } from '@nuasite/cms-marker'
9
+ export type { PageMarkdownOptions } from '@nuasite/page-markdown'
10
+
11
+ export interface NuaIntegrationOptions {
12
+ /** Enable/disable or configure @nuasite/cms-marker (default: true) */
13
+ cmsMarker?: boolean | CmsMarkerOptions
14
+ /** Enable/disable or configure @nuasite/page-markdown (default: true) */
15
+ pageMarkdown?: boolean | PageMarkdownOptions
16
+ /** Enable/disable or configure @astrojs/mdx (default: true) */
17
+ mdx?: boolean | MdxOptions
18
+ /** Enable/disable or configure @astrojs/sitemap (default: true) */
19
+ sitemap?: boolean | SitemapOptions
20
+ /** Enable/disable @tailwindcss/vite plugin (default: true) */
21
+ tailwindcss?: boolean
22
+ }
23
+
24
+ export interface ResolvedIntegrationOptions {
25
+ cmsMarker: CmsMarkerOptions | false
26
+ pageMarkdown: PageMarkdownOptions | false
27
+ mdx: MdxOptions | false
28
+ sitemap: SitemapOptions | false
29
+ tailwindcss: boolean
30
+ }
31
+
32
+ /**
33
+ * Resolves a boolean | Options value to Options | false
34
+ */
35
+ function resolveOption<T extends object>(value: boolean | T | undefined, defaultOptions: T = {} as T): T | false {
36
+ if (value === false) return false
37
+ if (value === true || value === undefined) return defaultOptions
38
+ return value
39
+ }
40
+
41
+ export function resolveOptions(options: NuaIntegrationOptions = {}): ResolvedIntegrationOptions {
42
+ return {
43
+ cmsMarker: resolveOption(options.cmsMarker),
44
+ pageMarkdown: resolveOption(options.pageMarkdown),
45
+ mdx: resolveOption(options.mdx),
46
+ sitemap: resolveOption(options.sitemap),
47
+ tailwindcss: options.tailwindcss !== false,
48
+ }
49
+ }