-
Notifications
You must be signed in to change notification settings - Fork 3
Document parameterized markdown snippets feature #1865
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4bac067
Document parameterized markdown snippets feature
devin-ai-integration[bot] 4651ecb
Add example snippet files for documentation
devin-ai-integration[bot] 05bda5b
Move parameterized snippets documentation to existing reusable snippe…
devin-ai-integration[bot] ccbd47d
clean up doc
devalog 5c6a8a6
Merge branch 'main' into devin/1762621931-parameterized-snippets
devalog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,23 @@ | ||
| ## Parameterized markdown snippets | ||
|
|
||
| Reusable markdown snippets can now accept arbitrary parameters that can be used as variables in the snippet. This enables flexible, reusable content templates. | ||
|
|
||
| Create a snippet with parameter placeholders using curly braces: | ||
|
|
||
| ```mdx fern/snippets/feature.mdx | ||
| This feature is only available on the {plan} plan. | ||
| ``` | ||
|
|
||
| Pass parameters when including the snippet: | ||
|
|
||
| ```mdx page.mdx | ||
| <Markdown src="/snippets/feature.mdx" plan="pro" /> | ||
| ``` | ||
|
|
||
| This renders as: | ||
|
|
||
| ``` | ||
| This feature is only available on the pro plan. | ||
| ``` | ||
|
|
||
| Learn more about [reusable markdown snippets](/learn/docs/content/markdown#reusable-markdown-snippets). | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -51,6 +51,70 @@ The value for `page` is used as the content of the top `<h1>` element of this pa | |
|
|
||
| Fern has a built-in component library you can use in Markdown. [Explore the components.](/learn/docs/content/components/overview) | ||
|
|
||
| ## Reusable markdown snippets | ||
|
|
||
| You can create reusable markdown snippets and include them in multiple pages using the `<Markdown>` component. This is useful for content that appears in multiple places, such as warnings, common instructions, or version numbers. | ||
|
|
||
| ### Basic usage | ||
|
|
||
| Create a snippet file in your `fern/snippets/` folder: | ||
|
|
||
| <CodeBlock title='fern/snippets/common-warning.mdx'> | ||
| ```mdx | ||
| <Warning> | ||
| This feature is in beta and may change in future releases. | ||
|
||
| </Warning> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| Then include it in any page using the `<Markdown>` component: | ||
|
|
||
| <CodeBlock title='page.mdx'> | ||
| ```mdx | ||
| <Markdown src="/snippets/common-warning.mdx" /> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| ### Parameterized snippets | ||
|
|
||
| Snippets can accept arbitrary parameters that can be used as variables within the snippet content. This allows you to create flexible, reusable content templates. | ||
|
|
||
| Create a snippet with parameter placeholders using curly braces: | ||
|
|
||
| <CodeBlock title='fern/snippets/feature.mdx'> | ||
| ```mdx | ||
| This feature is only available on the {plan} plan. | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| Pass parameters when including the snippet: | ||
|
|
||
| <CodeBlock title='page.mdx'> | ||
| ```mdx | ||
| <Markdown src="/snippets/feature.mdx" plan="pro" /> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| This renders as: | ||
|
|
||
| ``` | ||
| This feature is only available on the pro plan. | ||
| ``` | ||
|
|
||
| You can use multiple parameters in a single snippet: | ||
|
|
||
| <CodeBlock title='fern/snippets/sdk-install.mdx'> | ||
| ```mdx | ||
| Install the {language} SDK version {version} using {packageManager}. | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| <CodeBlock title='page.mdx'> | ||
| ```mdx | ||
| <Markdown src="/snippets/sdk-install.mdx" language="TypeScript" version="3.28.1" packageManager="npm" /> | ||
| ``` | ||
| </CodeBlock> | ||
|
|
||
| ## Links in Markdown | ||
|
|
||
| ### Link target | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[FernStyles.Current] Avoid time-relative terms like 'now' that become outdated