Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ reproduce literal output.
A conforming [document][term-document] MUST contain elements in the following
order. Items marked OPTIONAL MAY be omitted entirely.

1. **Title heading** (REQUIRED) - Exactly one [ATX heading][cm-atx-heading]
at depth 1.
1. **Title heading** (OPTIONAL, RECOMMENDED) - An [ATX heading][cm-atx-heading] at depth 1.
2. **[Simple directives][§6.2]** (OPTIONAL) - Zero or more
[HTML comment][cm-html-comment] directives providing
[document][term-document]-level metadata. These MUST immediately follow
Expand Down Expand Up @@ -174,7 +173,7 @@ NOT be used.

#### 4.2.1. Depth 1

The [document][term-document] title. Exactly one depth-1 heading MUST appear
The [document][term-document] title. Exactly one depth-1 heading SHOULD appear
per document.

#### 4.2.2. Depth 2
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/generators/metadata/utils/parse.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const parseApiDoc = ({ path, tree, mdx = false }, typeMap) => {
// Handles the normalisation URLs that reference to API doc files with .md extension
visit(tree, UNIST.isMarkdownUrl, node => visitMarkdownLink(node));

// If the document has no headings but it has content, we add a fake heading to the top
// If the document has no headings but it has content, we add a fake heading to the top, it will not be rendered
if (headingNodes.length === 0 && tree.children.length > 0) {
tree.children.unshift(createTree('heading', { depth: 1 }, []));
}
Comment thread
moshams272 marked this conversation as resolved.
Expand Down
5 changes: 5 additions & 0 deletions packages/react/src/jsx-ast/utils/buildContent.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ export const extractHeadingContent = content => {
* @param {import('unist').Node|null} changeElement - The change history element, if available
*/
export const createHeadingElement = (content, changeElement) => {
// If the heading is empty, we don't render it
if (!content.children || content.children.length === 0) {
return { type: 'text', value: '' };
}

const { type, slug } = content.data;

let headingContent = extractHeadingContent(content);
Expand Down
Loading