Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

FranciscoMoretti
Copy link
Contributor

@FranciscoMoretti FranciscoMoretti commented Apr 18, 2023

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 Reviewable

@stackblitz
Copy link

stackblitz bot commented Apr 18, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@@ -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?: {
Copy link
Contributor Author

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?

Copy link
Member

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.

@@ -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;
Copy link
Member

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().

Copy link
Member

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.

@FranciscoMoretti
Copy link
Contributor Author

Great suggestions @hatton! I've applied them all 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants