-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a2d591
commit 0039da7
Showing
16 changed files
with
95 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
packages/apps/docs/src/scripts/fixLocalLinks/refactorAbsoluteDocsLink.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const refactorAbsoluteDocsLink = (path: string): string => { | ||
const regExp = /^(https?:\/\/docs\.kadena\.io)/; | ||
|
||
if (path.match(regExp)) return path.replace(regExp, '') || '/'; | ||
|
||
return path; | ||
}; |
36 changes: 36 additions & 0 deletions
36
...ages/apps/docs/src/scripts/fixLocalLinks/utils/__tests__/refactorAbsoluteDocsLink.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { refactorAbsoluteDocsLink } from '../../refactorAbsoluteDocsLink'; | ||
|
||
describe('utils refactorAbsoluteDocsLink', () => { | ||
it('should return the normal link if not absolute docs link', async () => { | ||
const start = 'https://he-man.com/masters-of-the-universe'; | ||
const expectedResult = start; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
}); | ||
it('should return relative link if it is a docs link', async () => { | ||
let start = 'https://docs.kadena.io/build/start'; | ||
let expectedResult = '/build/start'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
|
||
start = 'https://docs.kadena.io/build/start.md'; | ||
expectedResult = '/build/start.md'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
|
||
start = 'https://docs.kadena.io/build/start.md'; | ||
expectedResult = '/build/start.md'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
}); | ||
|
||
it('should return relative link if it is a docs link home', async () => { | ||
let start = 'https://docs.kadena.io'; | ||
let expectedResult = '/'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
|
||
start = 'https://docs.kadena.io/'; | ||
expectedResult = '/'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
|
||
start = 'http://docs.kadena.io/'; | ||
expectedResult = '/'; | ||
expect(refactorAbsoluteDocsLink(start)).toBe(expectedResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/apps/docs/src/scripts/utils/__test__/crawlpage.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { loadConfigPages } from '@/scripts/fixLocalLinks/utils/loadConfigPages.mock'; | ||
import { crawlPage } from '../crawlPage'; | ||
|
||
describe('utils crawlPage', () => { | ||
it('should crawl all the pages and call the function every time with correct props', async () => { | ||
const pages = await loadConfigPages(); | ||
const mock = vi.fn().mockImplementation(() => {}); | ||
|
||
for (let i = 0; i < pages.length; i++) { | ||
const page = pages[i]; | ||
await crawlPage(page, [], mock); | ||
} | ||
|
||
expect(mock).toHaveBeenCalledTimes(15); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...s/__tests__/getFileNameOfPageFile.test.ts → ...ls/__test__/getFileNameOfPageFile.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { IConfigTreeItem } from '@kadena/docs-tools'; | ||
|
||
export const crawlPage = async ( | ||
page: IConfigTreeItem, | ||
parentTree: IConfigTreeItem[], | ||
func: (page: IConfigTreeItem, parentTree: IConfigTreeItem[]) => Promise<void>, | ||
): Promise<void> => { | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
await func(page, parentTree); | ||
|
||
if (page.children) { | ||
for (let i = 0; i < page.children.length; i++) { | ||
const child = page.children[i]; | ||
await crawlPage(child, [...parentTree, page], func); | ||
} | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.