Skip to content

Commit 9cfded3

Browse files
Merge pull request #69 from universal-ember/fix-name-cleaning
Fix name cleaning
2 parents f53465d + ece8444 commit 9cfded3

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

src/plugins/markdown-pages/discover.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ describe('discover', () => {
2323
"name": "c",
2424
"pages": [
2525
{
26-
"cleanedName": "cb",
26+
"cleanedName": "c b",
2727
"groupName": "c",
2828
"name": "c-b",
2929
"path": "/c/c-b.md",
3030
},
3131
{
32-
"cleanedName": "ca",
32+
"cleanedName": "c a",
3333
"groupName": "c",
3434
"name": "c-a",
3535
"path": "/c/c-a.md",
@@ -39,13 +39,13 @@ describe('discover', () => {
3939
"name": "d",
4040
"pages": [
4141
{
42-
"cleanedName": "da",
42+
"cleanedName": "d a",
4343
"groupName": "d",
4444
"name": "d-a",
4545
"path": "/c/d/d-a.md",
4646
},
4747
{
48-
"cleanedName": "db",
48+
"cleanedName": "d b",
4949
"groupName": "d",
5050
"name": "d-b",
5151
"path": "/c/d/d-b.md",
@@ -57,13 +57,13 @@ describe('discover', () => {
5757
"name": "e",
5858
"pages": [
5959
{
60-
"cleanedName": "eb",
60+
"cleanedName": "e b",
6161
"groupName": "e",
6262
"name": "e-b",
6363
"path": "/c/e/e-b.md",
6464
},
6565
{
66-
"cleanedName": "ea",
66+
"cleanedName": "e a",
6767
"groupName": "e",
6868
"name": "e-a",
6969
"path": "/c/e/e-a.md",
@@ -153,7 +153,7 @@ describe('discover', () => {
153153
expect(result.groups[1]?.list).toMatchInlineSnapshot(`
154154
[
155155
{
156-
"cleanedName": "somefile",
156+
"cleanedName": "some file",
157157
"groupName": "components",
158158
"name": "some-file",
159159
"path": "/Group 1/components/some-file.md",

src/plugins/markdown-pages/parse.build.test.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ describe('build', () => {
2626
`);
2727
});
2828

29+
test('hypehenated group', () => {
30+
let result = build([{ mdPath: 'top-level/nested.md' }]);
31+
32+
expect(result).toMatchInlineSnapshot(`
33+
{
34+
"name": "root",
35+
"pages": [
36+
{
37+
"name": "top level",
38+
"pages": [
39+
{
40+
"cleanedName": "nested",
41+
"groupName": "top level",
42+
"name": "nested",
43+
"path": "/top-level/nested.md",
44+
},
45+
],
46+
},
47+
],
48+
}
49+
`);
50+
});
51+
2952
test('multiple shallow paths', () => {
3053
let result = build([
3154
{ mdPath: 'top/nested.md' },
@@ -47,14 +70,19 @@ describe('build', () => {
4770
"path": "/top/nested.md",
4871
},
4972
{
50-
"cleanedName": "nestedsibling",
73+
"cleanedName": "nested sibling",
5174
"groupName": "top",
5275
"name": "nested-sibling",
5376
"path": "/top/nested-sibling.md",
5477
},
78+
],
79+
},
80+
{
81+
"name": "top ",
82+
"pages": [
5583
{
5684
"cleanedName": "other",
57-
"groupName": "top",
85+
"groupName": "top ",
5886
"name": "other",
5987
"path": "/top-2/other.md",
6088
},

src/plugins/markdown-pages/parse.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function deepSort(input) {
4848
* @returns {string}
4949
*/
5050
function cleanSegment(segment) {
51-
return stripExt(segment.replaceAll(/[\d-]/g, ''));
51+
return stripExt(segment.replaceAll(/\d/g, '').replaceAll('-', ' '));
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)