Skip to content

TOC should render statically analyzable embedded expressions in headings (esp. imported partials) #9772

Open
@anatolykopyl

Description

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

If a prop is passed to a partial Markdown file, then the ToC displays {props.propname}, instead of the actual value.

As @slorber pointed out in #9684, this is a known limitaion that stems from that even in non-partial files headings don't support expressions.
While having expressions in non-partial headings is a feature, that would be nice for completeness, it's probably not too practical. On the other hand, having expressions in headings of partials can be very useful.

Reproducible demo

No response

Steps to reproduce

  1. Create a partial file that uses a prop in a heading
  2. Import that file
  3. Use the partial

Expected behavior

The ToC shows the value passed to the partial

Actual behavior

The ToC shows {props.propname}

Your environment

No response

Self-service

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

Metadata

Assignees

No one assigned

    Labels

    difficulty: advancedIssues that are complex, e.g. large scoping for long-term maintainability.domain: markdownRelated to Markdown parsing or syntaxfeatureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions