Skip to content

Commit f35b307

Browse files
mendrewsapegin
authored andcommitted
Fix: Section anchors shouldn't conflict with component anchors (styleguidist#1364)
Prefix section anchors with `section-`. Closes styleguidist#1342
1 parent 010761b commit f35b307

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/loaders/utils/__tests__/__snapshots__/getSections.spec.js.snap

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Array [
1515
"name": "Readme",
1616
"sectionDepth": 0,
1717
"sections": Array [],
18-
"slug": "readme-1",
18+
"slug": "section-readme-1",
1919
"usageMode": "collapse",
2020
},
2121
Object {
@@ -97,7 +97,7 @@ Array [
9797
"name": "Components",
9898
"sectionDepth": 0,
9999
"sections": Array [],
100-
"slug": "components-1",
100+
"slug": "section-components-1",
101101
"usageMode": "collapse",
102102
},
103103
Object {
@@ -179,7 +179,7 @@ Array [
179179
"name": "Ignore",
180180
"sectionDepth": 0,
181181
"sections": Array [],
182-
"slug": "ignore-1",
182+
"slug": "section-ignore-1",
183183
"usageMode": "collapse",
184184
},
185185
]
@@ -265,7 +265,7 @@ Object {
265265
"name": "Components",
266266
"sectionDepth": 0,
267267
"sections": Array [],
268-
"slug": "components",
268+
"slug": "section-components",
269269
"usageMode": "collapse",
270270
}
271271
`;
@@ -284,7 +284,7 @@ Object {
284284
"name": "Readme",
285285
"sectionDepth": 0,
286286
"sections": Array [],
287-
"slug": "readme",
287+
"slug": "section-readme",
288288
"usageMode": "collapse",
289289
}
290290
`;
@@ -369,7 +369,7 @@ Object {
369369
"name": "Ignore",
370370
"sectionDepth": 0,
371371
"sections": Array [],
372-
"slug": "ignore",
372+
"slug": "section-ignore",
373373
"usageMode": "collapse",
374374
}
375375
`;

src/loaders/utils/getSections.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function processSection(section, config, parentDepth) {
6565
usageMode: section.usageMode || config.usageMode,
6666
sectionDepth,
6767
description: section.description,
68-
slug: slugger.slug(section.name),
68+
slug: `section-${slugger.slug(section.name)}`,
6969
sections: getSections(section.sections || [], config, sectionDepth),
7070
filepath: contentRelativePath,
7171
href: section.href,

0 commit comments

Comments
 (0)