Add code snippet embed support

Adds the ability to read snippets from a file

Signed-off-by: Alison Dowdney <alison@alisondowdney.com>
This commit is contained in:
Alison Dowdney 2021-07-07 16:59:07 +01:00
parent 24d24591e9
commit 82408af5cf
3 changed files with 31 additions and 0 deletions

View File

@ -85,3 +85,16 @@ If you want to illustrate the documentation and make things easier to read, ther
- [`tabpane`](https://www.docsy.dev/docs/adding-content/shortcodes/#tabbed-panes) for pieces of text that go in different tabs
- [`cardpane` and `card`](https://www.docsy.dev/docs/adding-content/shortcodes/#card-panes) for adding cards and card panes
- [`gist`, `youtube`, `tweet` and more](https://gohugo.io/content-management/shortcodes/): lots of shortcodes we get from Hugo itself.
## Code snippets
You can embed code snippets from a file.
``language`` is any [language supported by GitHub flavored markdown](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml).
``file`` is the path to the file you want to use in the code block.
```go-html-template
{{%/* codeblock file="/static/snippet/example.yaml" language="yaml" */%}}
```
{{% codeblock file="/static/snippet/example.yaml" language="yaml" %}}

View File

@ -0,0 +1,3 @@
{{ $file := .Get "file" | readFile }}
{{ $lang := .Get "language" }}
{{ (print "```" $lang "\n" $file "\n```") | markdownify }}

View File

@ -0,0 +1,15 @@
apiVersion: source.toolkit.fluxcd.io/v1beta1
kind: GitRepository
metadata:
name: podinfo
namespace: flux-system
spec:
interval: 1m
url: https://github.com/stefanprodan/podinfo
ref:
branch: master
ignore: |
# exclude all
/*
# include charts directory
!/charts/