Skip to content

Commit

Permalink
Merge pull request #69 from universal-ember/fix-name-cleaning
Browse files Browse the repository at this point in the history
Fix name cleaning
  • Loading branch information
NullVoxPopuli committed Apr 29, 2024
2 parents f53465d + ece8444 commit 9cfded3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/plugins/markdown-pages/discover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ describe('discover', () => {
"name": "c",
"pages": [
{
"cleanedName": "cb",
"cleanedName": "c b",
"groupName": "c",
"name": "c-b",
"path": "/c/c-b.md",
},
{
"cleanedName": "ca",
"cleanedName": "c a",
"groupName": "c",
"name": "c-a",
"path": "/c/c-a.md",
Expand All @@ -39,13 +39,13 @@ describe('discover', () => {
"name": "d",
"pages": [
{
"cleanedName": "da",
"cleanedName": "d a",
"groupName": "d",
"name": "d-a",
"path": "/c/d/d-a.md",
},
{
"cleanedName": "db",
"cleanedName": "d b",
"groupName": "d",
"name": "d-b",
"path": "/c/d/d-b.md",
Expand All @@ -57,13 +57,13 @@ describe('discover', () => {
"name": "e",
"pages": [
{
"cleanedName": "eb",
"cleanedName": "e b",
"groupName": "e",
"name": "e-b",
"path": "/c/e/e-b.md",
},
{
"cleanedName": "ea",
"cleanedName": "e a",
"groupName": "e",
"name": "e-a",
"path": "/c/e/e-a.md",
Expand Down Expand Up @@ -153,7 +153,7 @@ describe('discover', () => {
expect(result.groups[1]?.list).toMatchInlineSnapshot(`
[
{
"cleanedName": "somefile",
"cleanedName": "some file",
"groupName": "components",
"name": "some-file",
"path": "/Group 1/components/some-file.md",
Expand Down
32 changes: 30 additions & 2 deletions src/plugins/markdown-pages/parse.build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,29 @@ describe('build', () => {
`);
});

test('hypehenated group', () => {
let result = build([{ mdPath: 'top-level/nested.md' }]);

expect(result).toMatchInlineSnapshot(`
{
"name": "root",
"pages": [
{
"name": "top level",
"pages": [
{
"cleanedName": "nested",
"groupName": "top level",
"name": "nested",
"path": "/top-level/nested.md",
},
],
},
],
}
`);
});

test('multiple shallow paths', () => {
let result = build([
{ mdPath: 'top/nested.md' },
Expand All @@ -47,14 +70,19 @@ describe('build', () => {
"path": "/top/nested.md",
},
{
"cleanedName": "nestedsibling",
"cleanedName": "nested sibling",
"groupName": "top",
"name": "nested-sibling",
"path": "/top/nested-sibling.md",
},
],
},
{
"name": "top ",
"pages": [
{
"cleanedName": "other",
"groupName": "top",
"groupName": "top ",
"name": "other",
"path": "/top-2/other.md",
},
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/markdown-pages/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function deepSort(input) {
* @returns {string}
*/
function cleanSegment(segment) {
return stripExt(segment.replaceAll(/[\d-]/g, ''));
return stripExt(segment.replaceAll(/\d/g, '').replaceAll('-', ' '));
}

/**
Expand Down

0 comments on commit 9cfded3

Please sign in to comment.