Skip to content

Commit 234863c

Browse files
trevorbladesDSchau
authored andcommitted
fix(gatsby-plugin-mdx): fix filter by heading depth (#16344)
1 parent f9d51bb commit 234863c

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/gatsby-plugin-mdx/gatsby/source-nodes.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module.exports = (
5959
const { createTypes } = actions;
6060

6161
const options = defaultOptions(pluginOptions);
62-
62+
const headingsMdx = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
6363
createTypes(`
6464
type MdxFrontmatter {
6565
title: String!
@@ -71,12 +71,7 @@ module.exports = (
7171
}
7272
7373
enum HeadingsMdx {
74-
h1,
75-
h2,
76-
h3,
77-
h4,
78-
h5,
79-
h6
74+
${headingsMdx}
8075
}
8176
8277
type MdxWordCount {
@@ -172,8 +167,8 @@ module.exports = (
172167
depth: heading.depth
173168
});
174169
});
175-
if (typeof depth === `number`) {
176-
headings = headings.filter(heading => heading.depth === depth);
170+
if (headingsMdx.includes(depth)) {
171+
headings = headings.filter(heading => `h${heading.depth}` === depth);
177172
}
178173
return headings;
179174
}

0 commit comments

Comments
 (0)