@nuasite/nua 0.63.2 → 0.64.2
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 +22 -2
- package/package.json +13 -12
- package/src/config.ts +12 -1
- package/src/integration.ts +14 -8
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ This single line gives you:
|
|
|
44
44
|
- Sitemap generation via `@astrojs/sitemap`
|
|
45
45
|
- CMS markers via `@nuasite/cms-marker`
|
|
46
46
|
- Page markdown output via `@nuasite/llm-enhancements`
|
|
47
|
-
- Sensible defaults: `site: 'http://localhost:4321'`, `vite.build.sourcemap: true`
|
|
47
|
+
- Sensible defaults: `site: 'http://localhost:4321'`, `vite.build.sourcemap: true`, `compressHTML: true` (Astro 6's whitespace handling) and the `unified()` markdown processor (see [Markdown](#markdown))
|
|
48
48
|
|
|
49
49
|
### Configuration options
|
|
50
50
|
|
|
@@ -72,11 +72,29 @@ import { defineConfig } from '@nuasite/nua/config'
|
|
|
72
72
|
export default defineConfig({
|
|
73
73
|
nua: {
|
|
74
74
|
sitemap: { filter: (page) => !page.includes('/draft/') },
|
|
75
|
-
mdx: { remarkPlugins: [myRemarkPlugin] },
|
|
76
75
|
},
|
|
77
76
|
})
|
|
78
77
|
```
|
|
79
78
|
|
|
79
|
+
### Markdown
|
|
80
|
+
|
|
81
|
+
Astro 7 renders `.md` and `.mdx` with Sätteri by default, which does not run remark or rehype plugins. The CMS's directives (`:::list{.class}`, `::youtube{#id}`) and its markdown markers are remark and rehype plugins, so `defineConfig` sets `markdown.processor` to `unified()` from `@astrojs/markdown-remark`, and the integrations add their plugins to it. MDX uses the same processor.
|
|
82
|
+
|
|
83
|
+
To add plugins of your own, pass your own `unified()`. The integrations add theirs to it:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { unified } from '@astrojs/markdown-remark'
|
|
87
|
+
import { defineConfig } from '@nuasite/nua/config'
|
|
88
|
+
|
|
89
|
+
export default defineConfig({
|
|
90
|
+
markdown: {
|
|
91
|
+
processor: unified({ remarkPlugins: [myRemarkPlugin] }),
|
|
92
|
+
},
|
|
93
|
+
})
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
With another processor (`satteri()`), the CMS directives do not render and markdown is not marked for editing. The dev server and build warn about it.
|
|
97
|
+
|
|
80
98
|
### Using the integration directly
|
|
81
99
|
|
|
82
100
|
If you prefer more control, import the integration separately:
|
|
@@ -91,6 +109,8 @@ export default defineConfig({
|
|
|
91
109
|
})
|
|
92
110
|
```
|
|
93
111
|
|
|
112
|
+
Astro's own `defineConfig` does not set nua's defaults. Set `markdown.processor: unified()` from `@astrojs/markdown-remark` for the CMS directives, and `compressHTML: true` to keep the whitespace between inline elements.
|
|
113
|
+
|
|
94
114
|
## Redirects
|
|
95
115
|
|
|
96
116
|
A site can declare redirects in three places, and the build merges them into one `dist/_redirects`:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuasite/nua",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"module": "src/index.ts",
|
|
@@ -35,21 +35,22 @@
|
|
|
35
35
|
"prepack": "bun run ../../scripts/workspace-deps/resolve-deps.ts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@astrojs/check": "0.9.
|
|
39
|
-
"@astrojs/
|
|
40
|
-
"@astrojs/
|
|
41
|
-
"@
|
|
42
|
-
"@nuasite/
|
|
43
|
-
"@nuasite/
|
|
44
|
-
"@nuasite/
|
|
45
|
-
"@nuasite/
|
|
46
|
-
"@nuasite/
|
|
38
|
+
"@astrojs/check": "0.9.12",
|
|
39
|
+
"@astrojs/markdown-remark": "7.3.4",
|
|
40
|
+
"@astrojs/mdx": "8.1.1",
|
|
41
|
+
"@astrojs/sitemap": "3.7.4",
|
|
42
|
+
"@nuasite/checks": "0.64.2",
|
|
43
|
+
"@nuasite/llm-enhancements": "0.64.2",
|
|
44
|
+
"@nuasite/cli": "0.64.2",
|
|
45
|
+
"@nuasite/cms": "0.64.2",
|
|
46
|
+
"@nuasite/components": "0.64.2",
|
|
47
|
+
"@nuasite/core": "0.64.2",
|
|
47
48
|
"@tailwindcss/vite": "^4.2.2",
|
|
48
49
|
"@tailwindcss/typography": "^0.5.19",
|
|
49
|
-
"astro": "
|
|
50
|
+
"astro": "7.4.2",
|
|
50
51
|
"flowbite": "4.0.1",
|
|
51
52
|
"tailwindcss": "4.2.2",
|
|
52
53
|
"typescript": "^6.0.2",
|
|
53
|
-
"vite": "^
|
|
54
|
+
"vite": "^8.3.4"
|
|
54
55
|
}
|
|
55
56
|
}
|
package/src/config.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unified } from '@astrojs/markdown-remark'
|
|
1
2
|
import { defineConfig as astroDefineConfig } from 'astro/config'
|
|
2
3
|
import nua from './integration'
|
|
3
4
|
import type { NuaIntegrationOptions } from './types'
|
|
@@ -41,7 +42,7 @@ export interface NuaConfig extends AstroUserConfig {
|
|
|
41
42
|
* ```
|
|
42
43
|
*/
|
|
43
44
|
export function defineConfig(config: NuaConfig = {}) {
|
|
44
|
-
const { nua: nuaOptions, integrations = [], vite = {}, ...astroConfig } = config
|
|
45
|
+
const { nua: nuaOptions, integrations = [], vite = {}, markdown = {}, ...astroConfig } = config
|
|
45
46
|
|
|
46
47
|
const mergedVite = {
|
|
47
48
|
...vite,
|
|
@@ -54,6 +55,16 @@ export function defineConfig(config: NuaConfig = {}) {
|
|
|
54
55
|
const defaults = {
|
|
55
56
|
site: 'http://localhost:4321',
|
|
56
57
|
vite: mergedVite,
|
|
58
|
+
// Astro 7 strips whitespace between elements by JSX rules by default (`'jsx'`), so
|
|
59
|
+
// `<span>a</span> <em>b</em>` renders as "ab". Sites built on nua keep Astro 6's output.
|
|
60
|
+
compressHTML: true,
|
|
61
|
+
// Astro 7 renders markdown with Sätteri by default, which does not run remark or rehype
|
|
62
|
+
// plugins. The CMS's directives and markers are remark/rehype plugins, so nua keeps the
|
|
63
|
+
// `unified()` pipeline unless the site chose a processor itself.
|
|
64
|
+
markdown: {
|
|
65
|
+
...markdown,
|
|
66
|
+
processor: markdown.processor ?? unified(),
|
|
67
|
+
},
|
|
57
68
|
legacy: {
|
|
58
69
|
collectionsBackwardsCompat: true,
|
|
59
70
|
},
|
package/src/integration.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import mdx from '@astrojs/mdx'
|
|
2
2
|
import sitemap from '@astrojs/sitemap'
|
|
3
3
|
import checks from '@nuasite/checks'
|
|
4
|
-
import cms, { cmsRemarkPlugins, mergeConfigRedirectsInto } from '@nuasite/cms'
|
|
4
|
+
import cms, { addMarkdownPlugins, cmsRemarkPlugins, mergeConfigRedirectsInto } from '@nuasite/cms'
|
|
5
5
|
import tailwindcss from '@tailwindcss/vite'
|
|
6
6
|
import type { AstroConfig, AstroIntegration } from 'astro'
|
|
7
7
|
import pageMarkdown from '../../llm-enhancements/src'
|
|
@@ -74,17 +74,23 @@ export default function nua(options: NuaIntegrationOptions = {}): AstroIntegrati
|
|
|
74
74
|
// them: Astro deep-merges config updates, so it still renders its own meta-refresh pages.
|
|
75
75
|
capturedRedirects = config.redirects ?? {}
|
|
76
76
|
|
|
77
|
-
// Inject Vite plugins and integrations.
|
|
78
77
|
// CMS list-style directives (`:::list{.class}`) need `remark-directive`
|
|
79
|
-
// in the markdown pipeline
|
|
78
|
+
// in the markdown pipeline, both to render `<ul class="class">` and to
|
|
80
79
|
// stop MDX from parsing the `{.class}` attributes as a JS expression
|
|
81
|
-
// (which crashes acorn). `@astrojs/mdx` inherits
|
|
82
|
-
// `extendMarkdownConfig` (default true).
|
|
80
|
+
// (which crashes acorn). `@astrojs/mdx` inherits the processor via
|
|
81
|
+
// `extendMarkdownConfig` (default true). `defineConfig` sets the `unified()`
|
|
82
|
+
// processor that runs them; a site that chose another one is told why
|
|
83
|
+
// directives do not render.
|
|
84
|
+
if (!addMarkdownPlugins(config, { remarkPlugins: cmsRemarkPlugins })) {
|
|
85
|
+
logger.warn(
|
|
86
|
+
`The "${config.markdown.processor.name}" markdown processor does not run remark plugins, so CMS directives`
|
|
87
|
+
+ ` (\`:::list{.class}\`, \`::youtube{#id}\`) do not render. Set \`markdown.processor: unified()\` from @astrojs/markdown-remark.`,
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Inject Vite plugins and integrations.
|
|
83
92
|
updateConfig({
|
|
84
93
|
redirects: {},
|
|
85
|
-
markdown: {
|
|
86
|
-
remarkPlugins: cmsRemarkPlugins,
|
|
87
|
-
},
|
|
88
94
|
vite: {
|
|
89
95
|
plugins: vitePlugins,
|
|
90
96
|
ssr: {
|