Skip to content

Auto-generated description/og:description leaks the first line of a multi-line JSX element #12214

Closed

Description

@FranjoMindek

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

Related: #11818 (same createExcerpt regex)

createExcerpt (in @docusaurus/utils) is used to auto-generate a page's meta description / og:description when no description is set in frontmatter. It strips HTML/JSX tags with the regex /<[^>]*>/g, which only matches a tag that opens and closes on the same line.

When the first content node of a doc is a multi-line JSX/MDX element, only its first line is seen (e.g. <MyComponent), the regex finds no >, nothing is stripped, and that literal partial tag becomes the page description.

So a self-closing component written across multiple lines leaks <ComponentName into <meta name="description"> and <meta property="og:description">.

Reproducible demo

Codesandbox didn't display meta tags.

Instead here is the deployment of an old dev commit where we noticed it:

https://2e482d9e.wasp-docs-on-main.pages.dev/docs/guides/debugging/db-studio-fly-io

Notice that it says:

<meta name="description" content="&lt;LastCheckedWithVersionsNotice" data-rh="true">
<meta property="og:description" content="&lt;LastCheckedWithVersionsNotice" data-rh="true">

Source file of the page is:

wasp-lang/wasp@9e9e739#diff-d8b5abb713973340ba8c74763cc1f66fd480a99a60769fe2be013086e363e853

---
title: Database Studio with Fly.io
comments: true
---

import LastCheckedWithVersionsNotice from "@site/src/components/LastCheckedWithVersionsNotice";

<LastCheckedWithVersionsNotice
  versions={{ Wasp: "0.24", "Fly CLI": "0.4.11" }}
/>

This guide shows you how to connect to your production database on Fly.io and run `wasp db studio` to inspect or modify your data.

Steps to reproduce

  1. Scaffold a fresh site: npm init docusaurus@latest my-site classic.

  2. Create a doc with no description frontmatter, whose first body content is a multi-line JSX element, then a real paragraph:

    ---
    title: Repro
    ---
    
    <SomeComponent
      foo="bar"
    />
    
    This paragraph should become the description.
  3. npm run start (or build) and inspect the page <head>.

Expected behavior

The auto-generated description / og:description should be the first real paragraph:

This paragraph should become the description.

The JSX element should be ignored, the same way a single-line <SomeComponent foo="bar" /> already is.

Actual behavior

description and og:description are set to the first line of the element:

<meta name="description" content="<SomeComponent">
<meta property="og:description" content="<SomeComponent">

Your environment

System:

  • OS: macOS 26.5
  • CPU: (12) arm64 Apple M4 Pro
  • Memory: 3.72 GB / 48.00 GB
  • Shell: 5.9 - /bin/zsh

Binaries:

  • Node: 24.14.1 - /Users/mindek/.nvm/versions/node/v24.14.1/bin/node
  • npm: 11.12.1 - /Users/mindek/.nvm/versions/node/v24.14.1/bin/npm
  • pnpm: 10.10.0 - /Users/mindek/Library/pnpm/pnpm
  • bun: 1.3.14 - /opt/homebrew/bin/bun

Browsers:

  • Chrome: 150.0.7871.47
  • Firefox Developer Edition: 153.0
  • Safari: 26.5

npmPackages:

  • @docusaurus/core: ~3.10.1 => 3.10.1
  • @docusaurus/faster: ~3.10.1 => 3.10.1
  • @docusaurus/module-type-aliases: ~3.10.1 => 3.10.1
  • @docusaurus/preset-classic: ~3.10.1 => 3.10.1
  • @docusaurus/theme-mermaid: ~3.10.1 => 3.10.1
  • @docusaurus/tsconfig: ~3.10.1 => 3.10.1

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bug
    status: needs triage
    on Jun 30, 2026
  2. gunjanjaswal commented on Jul 1, 2026

    @gunjanjaswal
    Contributor

    Opened #12215 for this. It adds an inHTML state to createExcerpt so an opening <Tag line with no > is skipped until the element closes, instead of leaking into the description. Existing single-line/self-closing tag handling is unchanged, plus a test for the multi-line case.

  3. removed
    status: needs triage
    on Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions