Skip to content

Make most features work in CommonMark mode: head, live code blocks, tabs... #9092

@slorber

Description

@slorber

Motivation

Related to the CommonMark support issue: #3018

Some custom elements we created do not work when using the CommonMark parser mode, that you can turn on using:

  • frontMatter.mdx.format: 'md'
  • config.markdown.format: 'detect' + using the .md extension

I think it would be convenient for users to have features working fine in both modes in a consistent way. I believe it is possible, but may require some adaptations.

Here are some components that do not currently work:


SEO

This should work in CommonMark too, but currently does not:

<head>
  <title>HEAD Markdown Page tests title</title>
  <meta name="keywords" content="cooking, blog">
</head>

Summary/details

Renders as:

CleanShot 2023-06-22 at 17 06 05

Instead of:

CleanShot 2023-06-22 at 17 07 11


Live code editor

Renders as:

CleanShot 2023-06-22 at 17 07 58

Instead of:

CleanShot 2023-06-22 at 17 07 28


Tabs

Renders as: N/A because we don't have any syntax that does not require using MDX/ESM imports.

Instead of:

CleanShot 2023-06-22 at 17 08 35

Possible solution? IMHO this syntax should be allowed without imports:

<tabs>
  <tabItem value="apple" label="Apple" default>
    This is an apple 🍎
  </tabItem>
  <tabItem value="orange" label="Orange">
    This is an orange 🍊
  </tabItem>
  <tabItem value="banana" label="Banana">
    This is a banana 🍌
  </tabItem>
</tabs>

Structured data

As part of #9669 we are adding a @theme/StructuredData helper component:

import StructuredData from "@theme/StructuredData";

<head>
  <meta name="keywords" content="cooking, blog" />
  <meta name="twitter:card" content="summary_large_image" />
  <link rel="preconnect" href="https://example.com" />
  <StructuredData structuredData={{
    '@context': 'https://schema.org/',
    '@type': 'Organization',
    name: 'Meta Open Source',
    url: 'https://opensource.fb.com/',
    logo: 'https://opensource.fb.com/img/logos/Meta-Open-Source.svg',
  }} />
</head>

# Title

We should figure out how to define structured data in CommonMark mode

Self-service

  • I'd be willing to do some initial work on this proposal myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    domain: markdownRelated to Markdown parsing or syntaxproposalThis issue is a proposal, usually non-trivial change

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions