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

Shortcode for including remote markdown files #1739

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

Conversation

fekete-robert
Copy link
Collaborator

Fixes #1716

Copy link

@froboy froboy left a 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 -}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{{- 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.

Copy link

@froboy froboy Jun 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

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.

feature: Ability to easily embed markdown docs NOT iframe
2 participants