-
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.
feat: bump transform to 4.32.2, use transform metadata utilities
- Loading branch information
1 parent
8b2dad1
commit a21fc3e
Showing
15 changed files
with
160 additions
and
278 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,11 +1,19 @@ | ||
import {parseExistingMetadata} from './parse'; | ||
import {emplaceMetadata} from './utils'; | ||
import { | ||
emplaceFrontMatter, | ||
separateAndExtractFrontMatter, | ||
} from '@diplodoc/transform/lib/frontmatter'; | ||
import {normalizeLineEndings} from './utils'; | ||
|
||
export const addSourcePath = (fileContent: string, sourcePath: string) => { | ||
const {metadata, metadataStrippedContent} = parseExistingMetadata(fileContent, sourcePath); | ||
|
||
return emplaceMetadata(metadataStrippedContent, { | ||
...metadata, | ||
const {frontMatter, frontMatterStrippedContent} = separateAndExtractFrontMatter( | ||
fileContent, | ||
sourcePath, | ||
}); | ||
); | ||
|
||
return normalizeLineEndings( | ||
emplaceFrontMatter(frontMatterStrippedContent, { | ||
...frontMatter, | ||
sourcePath, | ||
}), | ||
); | ||
}; |
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 was deleted.
Oops, something went wrong.
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,10 +1,6 @@ | ||
import {carriageReturn} from '../../utils'; | ||
import {FileMetadata, serializeMetadata} from './parse'; | ||
|
||
// 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); | ||
|
||
export const emplaceMetadata = (metadataStrippedContent: string, metadata: FileMetadata) => | ||
normalizeLineEndings(`${serializeMetadata(metadata)}${metadataStrippedContent}`); |
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.