{
  "id": "nextjs/layout-segment-config-export",
  "signature": "Error: Layout segment config 'X' is not allowed. Use generateMetadata or generateStaticParams instead.",
  "signature_zh": "错误：不允许使用布局段配置 'X'。请改用 generateMetadata 或 generateStaticParams。",
  "regex": "Error: Layout segment config '.*' is not allowed",
  "domain": "nextjs",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "In Next.js app directory, layout segment configs like 'layout' or 'template' cannot be exported directly; they must be replaced with the correct data-fetching or metadata APIs.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Next.js app 目录中，布局段配置（如 'layout' 或 'template'）不能直接导出；必须替换为正确的数据获取或元数据 API。",
  "versions": [
    {
      "version": "next@13.5.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "next@14.1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The layout still needs to define metadata or static params; removing the export breaks the page functionality.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Next.js only recognizes specific exports; arbitrary names are ignored and cause build errors.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Client components cannot use metadata or static params; this creates a different error.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Replace the layout segment config with generateMetadata. For example, if you exported 'metadata', change to:\n\nexport async function generateMetadata({ params }) {\n  const data = await fetchData(params.slug);\n  return { title: data.title };\n}",
      "success_rate": 0.9,
      "how": "Replace the layout segment config with generateMetadata. For example, if you exported 'metadata', change to:\n\nexport async function generateMetadata({ params }) {\n  const data = await fetchData(params.slug);\n  return { title: data.title };\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the config was for static generation, use generateStaticParams:\n\nexport async function generateStaticParams() {\n  const posts = await fetchPosts();\n  return posts.map(post => ({ slug: post.slug }));\n}",
      "success_rate": 0.85,
      "how": "If the config was for static generation, use generateStaticParams:\n\nexport async function generateStaticParams() {\n  const posts = await fetchPosts();\n  return posts.map(post => ({ slug: post.slug }));\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "For dynamic segments, ensure the layout has a default.tsx or loading.tsx to handle fallback states.",
      "success_rate": 0.75,
      "how": "For dynamic segments, ensure the layout has a default.tsx or loading.tsx to handle fallback states.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将布局段配置替换为 generateMetadata。例如，如果你导出了 'metadata'，改为：\n\nexport async function generateMetadata({ params }) {\n  const data = await fetchData(params.slug);\n  return { title: data.title };\n}",
    "如果配置用于静态生成，使用 generateStaticParams：\n\nexport async function generateStaticParams() {\n  const posts = await fetchPosts();\n  return posts.map(post => ({ slug: post.slug }));\n}",
    "对于动态段，确保布局有 default.tsx 或 loading.tsx 来处理回退状态。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nextjs.org/docs/app/api-reference/functions/generate-metadata",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-10-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}