mirror of
https://github.com/nunocoracao/blowfish.git
synced 2025-02-02 03:22:33 -06:00
Added codeimporter shortcode
- updated exampleSite.
This commit is contained in:
parent
13ff6f5341
commit
07d1396986
2 changed files with 33 additions and 0 deletions
|
@ -522,6 +522,31 @@ This shortcode allows you to import markdown files from external sources. This i
|
|||
{{< mdimporter url="https://raw.githubusercontent.com/nunocoracao/nunocoracao/master/README.md" >}}
|
||||
|
||||
|
||||
<br/><br/>
|
||||
|
||||
## Code Importer
|
||||
|
||||
This shortcode is for importing code from external sources easily without copying and pasting.
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
| Parameter | Description |
|
||||
| --------- | ------------------------------------------------------- |
|
||||
| `url` | **Required** URL to an externally hosted code file. |
|
||||
| `type` | Code type used for syntax highlighting. |
|
||||
|
||||
|
||||
<!-- prettier-ignore-end -->
|
||||
|
||||
|
||||
**Example:**
|
||||
|
||||
```md
|
||||
{{</* codeimporter url="https://raw.githubusercontent.com/nunocoracao/blowfish/main/layouts/shortcodes/mdimporter.html" type="go" */>}}
|
||||
|
||||
```
|
||||
{{< codeimporter url="https://raw.githubusercontent.com/nunocoracao/blowfish/main/layouts/shortcodes/mdimporter.html" type="go" >}}
|
||||
|
||||
|
||||
<br/><br/>
|
||||
|
||||
## Mermaid
|
||||
|
|
8
layouts/shortcodes/codeimporter.html
Normal file
8
layouts/shortcodes/codeimporter.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{ $url := .Get "url" }}
|
||||
{{ $type := .Get "type" }}
|
||||
{{ with resources.GetRemote (printf $url) }}
|
||||
{{ $codeBlock := printf "```%s\n%s\n```" $type .Content }}
|
||||
{{ $codeBlock | markdownify }}
|
||||
{{ else }}
|
||||
{{ errorf "Code Importer Shortcode - Unable to get remote resource" . }}
|
||||
{{ end }}
|
Loading…
Reference in a new issue