-
Notifications
You must be signed in to change notification settings - Fork 877
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
Shortcode for including remote markdown files #1739
base: main
Are you sure you want to change the base?
Conversation
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.
@fekete-robert this is fan-flipping-tastic! I ran into one feature request that I've added here. Take a look.
{{ end }} | ||
|
||
{{/* Output stuff after the frontmatter if a frontmatter was detected. */}} | ||
{{- index $split 2 | markdownify | safeHTML -}} |
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.
{{- index $split 2 | markdownify | safeHTML -}} | |
{{- delimit (last 1 $split) "" | markdownify | safeHTML -}} |
I have some GitHub README's that have H1s (#
) instead of frontmatter. I want to be able to trim those H1s from my pages. This small change will allow us to use the trim parameter to trim H1s too. 🎊
The `include-remote-md` shortcode fetches a remote markdown file and includes it in the page. This happens only when your Docsy project is built, so future changes of the remote markdown file are only included when you rebuild your project. | ||
|
||
If the file has a frontmatter, define the marker of the frontmatter in the second parameter of the shortcode (defaults to `---`). Note that if the content after the frontmatter includes the marker (for example, includes `---` as part of a markdown-formatted table) the content is truncated. | ||
|
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.
If the file has a H1 (`# ....`) instead of frontmatter, you can put the title line in as the second parameter and it will be removed instead. For example: | |
```go-html-template | |
{{</* include-remote-md "https://raw.githubusercontent.com/google/docsy/main/README.md" "# Docsy" */>}} | |
\``` |
(The leading \
on the end of the code fence will need to be removed because I'm not sure how to put a fence in a suggestion without breaking it)
Fixes #1716