-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Move page generators to page folder
- Loading branch information
Showing
14 changed files
with
100 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export {generateStaticMarkup} from './document' | ||
export {generateStaticRedirect} from './redirect' | ||
export {generateStaticSearch} from './search' |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {carriageReturn} from '../../utils'; | ||
import {CARRIAGE_RETURN} from '~/constants'; | ||
|
||
// IMO, we should just always apply this at the end of the whole processing pipeline, | ||
// not when dumping meta/front matter | ||
export const normalizeLineEndings = (input: string): string => | ||
input.replace(/\r?\n/g, carriageReturn); | ||
input.replace(/\r?\n/g, CARRIAGE_RETURN); |
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,52 @@ | ||
import {cloneDeepWith, flatMapDeep, isArray, isObject, isString} from 'lodash'; | ||
import {isFileExists, resolveRelativePath} from '@diplodoc/transform/lib/utilsFS'; | ||
|
||
export function findAllValuesByKeys(obj: object, keysToFind: string[]) { | ||
return flatMapDeep(obj, (value: string | string[], key: string) => { | ||
if ( | ||
keysToFind?.includes(key) && | ||
(isString(value) || (isArray(value) && value.every(isString))) | ||
) { | ||
return [value]; | ||
} | ||
|
||
if (isObject(value)) { | ||
return findAllValuesByKeys(value, keysToFind); | ||
} | ||
|
||
return []; | ||
}); | ||
} | ||
|
||
export function modifyValuesByKeys( | ||
originalObj: object, | ||
keysToFind: string[], | ||
modifyFn: (value: string) => string, | ||
) { | ||
// Clone the object deeply with a customizer function that modifies matching keys | ||
return cloneDeepWith(originalObj, function (value: unknown, key) { | ||
if (keysToFind.includes(key as string) && isString(value)) { | ||
return modifyFn(value); | ||
} | ||
|
||
return value; | ||
}); | ||
} | ||
|
||
export function getLinksWithContentExtersion(link: string) { | ||
return new RegExp(/^\S.*\.(md|ya?ml|html)$/gm).test(link); | ||
} | ||
|
||
export function getLinksWithExtension(link: string) { | ||
const oneLineWithExtension = new RegExp( | ||
/^\S.*\.(md|html|yaml|svg|png|gif|jpg|jpeg|bmp|webp|ico)$/gm, | ||
); | ||
|
||
return oneLineWithExtension.test(link); | ||
} | ||
|
||
export function checkPathExists(path: string, parentFilePath: string) { | ||
const includePath = resolveRelativePath(parentFilePath, path); | ||
|
||
return isFileExists(includePath); | ||
} |
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