From 2fc94cb5999a68f9ba28fb01d4d1258c3ca81129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20Cora=C3=A7=C3=A3o?= Date: Thu, 14 Dec 2023 12:37:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20External=20Markdown=20Importer=20Sh?= =?UTF-8?q?ortcode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exampleSite/content/docs/shortcodes/index.md | 25 ++++++++++++++++++++ layouts/shortcodes/mdimporter.html | 6 +++++ 2 files changed, 31 insertions(+) create mode 100644 layouts/shortcodes/mdimporter.html diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md index 156bf607..8fa2db74 100644 --- a/exampleSite/content/docs/shortcodes/index.md +++ b/exampleSite/content/docs/shortcodes/index.md @@ -456,6 +456,31 @@ The `where` and `value` values are used in the following query `where .Site.Regu


+## Markdown Importer + +This shortcode allows you to import markdown files from external sources. This is useful for including content from other repositories or websites without having to copy and paste the content. + + +| Parameter | Description | +| --------- | ------------------------------------------------------- | +| `url` | **Required** URL to an externally hosted markdown file. | + + + + + +**Example:** + +```md +{{}} + +``` + +{{< mdimporter url="https://raw.githubusercontent.com/nunocoracao/nunocoracao/master/README.md" >}} + + +

+ ## Mermaid `mermaid` allows you to draw detailed diagrams and visualisations using text. It uses Mermaid under the hood and supports a wide variety of diagrams, charts and other output formats. diff --git a/layouts/shortcodes/mdimporter.html b/layouts/shortcodes/mdimporter.html new file mode 100644 index 00000000..28b24fe2 --- /dev/null +++ b/layouts/shortcodes/mdimporter.html @@ -0,0 +1,6 @@ +{{ $url := .Get "url"}} +{{ with resources.GetRemote (printf $url) }} +{{ .Content | markdownify }} +{{ else }} +{{ errorf "Mardown Importer Shortcode - Unable to get remote resource" . }} +{{ end }} \ No newline at end of file