-
Notifications
You must be signed in to change notification settings - Fork 19
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
Fragment plugin #354
Fragment plugin #354
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Pull Request Test Coverage Report for Build 5023338253
💛 - Coveralls |
This is really cool @lilyvc. Nice work! |
…xisting ReadingTime plugin
|
||
## Use Cases | ||
|
||
Fragments offer various use cases, such as: |
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.
Nice
Here is another example, where the fragment files each contain a `<Tile>` component. | ||
|
||
``` | ||
:fragment{src="../fragments/tile-a.mdx"} :fragment{src="../fragments/tile-b.mdx"} |
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.
Might be nice to use a regex here to include all files in the fragments dir
The below code snippet will render the content from the content-fragment.mdx file in your target file: | ||
|
||
``` | ||
:fragment{src="../fragments/content-fragment.mdx"} |
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.
Would be interested to see what happens when the content fragment uses a meta data expression. Does it render the correct meta data?
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.
Just tried this, it does render but it's rendering int he context of the page "host" page and not the fragment page.
So if you edit the content-fragment.mdx
page like:
- ### Fragment title
+ #### {meta.title}
You should see the title of that section on the Fragments
page be Content Fragment
but what you get is Fragments
One for a follow up
@@ -20,7 +20,7 @@ const ReadingTimePlugin: PluginType<ReadingTimePluginPage> = { | |||
async $afterSource(pages) { | |||
const processor = unified().use(markdown); | |||
for (const page of pages) { | |||
const tree = await processor.parse(page.content); | |||
const tree: any = await processor.parse(page.content); |
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 think this should have type Node
. It's already being used in the file
Summary
A plugin that enables the embedding of pages into pages using the syntax
:fragment{src="path-to-fragment"}
This PR