-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-core-utils): Move page-data & HTML utils to package (#32861)
* Move some utils to core-utils * Move some utils to core-utils * Move some utils to core-utils * Move some utils to core-utils * moreUtils * Replace getPageHtmlFilePath in app * Backticks * replace fixedPagePath * Add more imports of fixedPagePath * change name of getPageHtmlFilePath * change name of getPageDataPath * change require * add deps, add windows test utils, delete unused remove function * revert cache-dir changes * add deps * fix remove function Co-authored-by: LekoArts <lekoarts@gmail.com>
- Loading branch information
1 parent
243c0ca
commit 114e3d3
Showing
20 changed files
with
129 additions
and
66 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os from "os" | ||
import { generatePageDataPath } from "../page-data" | ||
|
||
describe(`page-data`, () => { | ||
it(`returns correct page data path`, () => { | ||
if (os.platform() !== `win32`) { | ||
expect(generatePageDataPath(`public`, `/path/1`)).toBe( | ||
`public/page-data/path/1/page-data.json` | ||
) | ||
|
||
expect(generatePageDataPath(`public`, `/`)).toBe( | ||
`public/page-data/index/page-data.json` | ||
) | ||
} | ||
|
||
if (os.platform() === `win32`) { | ||
expect(generatePageDataPath(`public`, `/path/1`)).toBe( | ||
`public\\page-data\\path\\1\\page-data.json` | ||
) | ||
|
||
expect(generatePageDataPath(`public`, `/`)).toBe( | ||
`public\\page-data\\index\\page-data.json` | ||
) | ||
} | ||
}) | ||
}) |
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,26 @@ | ||
import os from "os" | ||
import { generateHtmlPath } from "../page-html" | ||
|
||
describe(`page-html`, () => { | ||
it(`returns correct html path`, () => { | ||
if (os.platform() !== `win32`) { | ||
expect(generateHtmlPath(`public`, `/path/1`)).toBe( | ||
`public/path/1/index.html` | ||
) | ||
|
||
expect(generateHtmlPath(`public`, `/path/1/index.html`)).toBe( | ||
`public/path/1/index.html` | ||
) | ||
} | ||
|
||
if (os.platform() === `win32`) { | ||
expect(generateHtmlPath(`public`, `/path/1`)).toBe( | ||
`public\\path\\1\\index.html` | ||
) | ||
|
||
expect(generateHtmlPath(`public`, `/path/1/index.html`)).toBe( | ||
`public\\path\\1\\index.html` | ||
) | ||
} | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import path from "path" | ||
|
||
export function fixedPagePath(pagePath: string): string { | ||
return pagePath === `/` ? `index` : pagePath | ||
} | ||
|
||
export function generatePageDataPath( | ||
publicDir: string, | ||
pagePath: string | ||
): string { | ||
return path.join( | ||
publicDir, | ||
`page-data`, | ||
fixedPagePath(pagePath), | ||
`page-data.json` | ||
) | ||
} |
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
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
Oops, something went wrong.