-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Created a plugin for frontmatter #51
base: main
Are you sure you want to change the base?
Created a plugin for frontmatter #51
Conversation
Run & review this pull request in StackBlitz Codeflow. |
src/plugins/pluginTypes.ts
Outdated
@@ -35,6 +35,11 @@ export type IPlugin = { | |||
// simple regex replacements on the markdown output | |||
regexMarkdownModifications?: IRegexMarkdownModification[]; | |||
|
|||
// operations on pages to define the markdown's frontmatter | |||
frontmatterTransform?: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely sold on the frontmatterTransform
name. Can you think of a better one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about frontMatterGenerator
? I'm camel casing "Matter" because front matter
is normally written as two words.
src/plugins/pluginTypes.ts
Outdated
@@ -35,6 +35,11 @@ export type IPlugin = { | |||
// simple regex replacements on the markdown output | |||
regexMarkdownModifications?: IRegexMarkdownModification[]; | |||
|
|||
// operations on pages to define the markdown's frontmatter | |||
frontmatterTransform?: { | |||
build: (page: NotionPage) => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about getFrontMatter()
to be parallel with getStringFromBlock()
and getReplacement()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recently I broke the plugin API when someone needed the context: IDocuNotionContext,
. Although I don't know why it might be needed, let's just include it here, from the start. Please make it the 1st argument.
Great suggestions @hatton! I've applied them all 👍 |
Created a plugin for frontmatter as some of the comments in the codebase suggested. This is helpful for people that might want to create their custom frontmatter. E.g. Adding
created_time
or a different property name to it.Notes for reviewers
I had to make a new field in
IPlugin
type to work on the page level. I haven't found a way to avoid that, but feel free to recommend one.This change is