mirror of
https://github.com/adulau/mastodon-markdown-archive.git
synced 2024-11-24 19:07:09 +00:00
Add sprig example to README
This commit is contained in:
parent
566e47a1f5
commit
d18757447e
1 changed files with 16 additions and 0 deletions
16
README.md
16
README.md
|
@ -307,6 +307,22 @@ For both the post and filename templates, the following functions and variables
|
||||||
* `toMarkdown` to convert the post's HTML content to Markdown, without escaping any markdown syntax
|
* `toMarkdown` to convert the post's HTML content to Markdown, without escaping any markdown syntax
|
||||||
* `toMarkdownEscaped` to convert the post's HTML content to Markdown, escaping any markdown syntax
|
* `toMarkdownEscaped` to convert the post's HTML content to Markdown, escaping any markdown syntax
|
||||||
|
|
||||||
|
Sprig is particularly useful for arbitrary customization, such as [string manipulation](https://masterminds.github.io/sprig/strings.html).
|
||||||
|
|
||||||
|
For example, let's assume we want to convert the casing of the tags from Mastodon. The [default template](files/templates/post.tmpl) passes the tags as-is, but we want them in kebab-case. You would need to create a custom template, and use the `kebabcase` function where the tags are rendered:
|
||||||
|
|
||||||
|
```
|
||||||
|
---
|
||||||
|
date: {{ .Post.CreatedAt }}
|
||||||
|
tags:
|
||||||
|
{{- range .Post.AllTags }}
|
||||||
|
- {{ .Name | kebabcase }}
|
||||||
|
{{- end }}
|
||||||
|
---
|
||||||
|
```
|
||||||
|
|
||||||
|
You would keep this file somewhere, and pass its path to the `--template` argument when invoking the tool.
|
||||||
|
|
||||||
#### Variables
|
#### Variables
|
||||||
* [Post](https://pkg.go.dev/git.garrido.io/gabriel/mastodon-markdown-archive/client#Post)
|
* [Post](https://pkg.go.dev/git.garrido.io/gabriel/mastodon-markdown-archive/client#Post)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue