create-kywi-app 0.28.0 → 0.29.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/lib/templates.mjs CHANGED
@@ -409,10 +409,19 @@ function nextConfig(a) {
409
409
  * - serverExternalPackages: core's server deps (sharp, drizzle, postgres, …)
410
410
  * stay server-side and out of the client bundle.
411
411
  *
412
+ * - withKywi: core's \`beforeFiles\` rewrite that completes
413
+ * \`Accept: text/markdown\` on page URLs. The middleware
414
+ * marks such a request; this rewrite, which (unlike the
415
+ * middleware) still sees Next's RSC headers, sends it to
416
+ * the page's Markdown copy and lets client navigations
417
+ * through. Without it page URLs always answer HTML.
418
+ *
412
419
  * Note: core sanitizes all CMS HTML itself with a DOM-free sanitizer
413
420
  * (sanitize-html), so there is no jsdom-based sanitizer to work around and no
414
421
  * client-side sanitizer stub to wire up here.
415
422
  */
423
+ import { withKywi } from '@kywi-software/core/next/config'
424
+
416
425
  /** @type {import('next').NextConfig} */
417
426
  const nextConfig = {
418
427
  transpilePackages: ['@kywi-software/core'],
@@ -434,7 +443,7 @@ const nextConfig = {
434
443
  },
435
444
  }
436
445
 
437
- export default nextConfig
446
+ export default withKywi(nextConfig)
438
447
  `
439
448
  }
440
449
 
package/lib/upgrade.mjs CHANGED
@@ -243,7 +243,7 @@ export function planUpgrade(projectDir, { force = false, dryRun = false } = {})
243
243
  // ever cause a write or change the exit code.
244
244
  plan.warns.push(...danglingImportWarns(projectDir, plan, expectedFor('runtime', RENDER_LANDMARK_PATHS.runtime)))
245
245
  if (wanted.kywiJs) plan.warns.push(...kywiJsWarns(projectDir))
246
- if (wanted.middleware) plan.warns.push(...nodeMiddlewareWarns(projectDir))
246
+ if (wanted.middleware) plan.warns.push(...nodeMiddlewareWarns(projectDir), ...withKywiWarns(projectDir))
247
247
  const installedCore = installedCoreVersion(projectDir)
248
248
  for (const { path, artifact, version } of scanEjectedArtifacts(projectDir)) {
249
249
  if (installedCore === null || version === installedCore) continue
@@ -410,6 +410,31 @@ function indexingCarryOver(envText) {
410
410
  )
411
411
  }
412
412
 
413
+ /**
414
+ * Since 0.29.0 `Accept: text/markdown` on a page URL needs the project's
415
+ * `next.config` wrapped with core's `withKywi`: the middleware only marks the
416
+ * request, and that config's `beforeFiles` rewrite completes it. `upgrade`
417
+ * never edits next.config, so a config that never calls `withKywi(` is a
418
+ * warn (`.md` addresses keep working either way).
419
+ * @returns {string[]}
420
+ */
421
+ function withKywiWarns(projectDir) {
422
+ for (const name of ['next.config.mjs', 'next.config.js', 'next.config.ts', 'next.config.cjs', 'next.config.mts']) {
423
+ let text
424
+ try {
425
+ text = readFileSync(join(projectDir, name), 'utf8')
426
+ } catch {
427
+ continue
428
+ }
429
+ if (/\bwithKywi\s*\(/.test(text)) return []
430
+ return [
431
+ `${name} does not use withKywi, so Accept: text/markdown on page URLs answers HTML (.md addresses still work) — ` +
432
+ `import { withKywi } from '@kywi-software/core/next/config' and export default withKywi(nextConfig)`,
433
+ ]
434
+ }
435
+ return []
436
+ }
437
+
413
438
  function nodeMiddlewareWarns(projectDir) {
414
439
  const warns = []
415
440
  let pkg = null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-kywi-app",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Scaffold a new Kywi CMS project — npx create-kywi-app my-site",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/Kywi-Software/kywi-cms#readme",