Fix embed function in action
This commit is contained in:
@@ -83,9 +83,10 @@
|
||||
console.debug(error)
|
||||
}
|
||||
//Embed method
|
||||
const embed = async(q, name = Math.random().toString().substring(2)) => {
|
||||
const embed = async(name, q) => {
|
||||
q = Object.fromEntries([...Object.entries(q).map(([key, value]) => [key.replace(/^plugin_/, "").replace(/_/g, "."), value]), ["base", false], ["config.animations", false]])
|
||||
const {rendered} = await metrics({login, q}, {...arguments[1], convert:null}, arguments[2])
|
||||
const plugins = Object.fromEntries(Object.entries(arguments[1].plugins).map(([key, value]) => [key, {...value, enabled:true}]))
|
||||
const {rendered} = await metrics({login, q}, {...arguments[1], plugins, convert:null}, arguments[2])
|
||||
return `<img class="metrics-cachable" data-name="${name}" src="data:image/svg+xml;base64,${Buffer.from(rendered).toString("base64")}">`
|
||||
}
|
||||
//Rendering template source
|
||||
|
||||
@@ -12,7 +12,7 @@ Markdown template can render a **markdown template** by interpreting **templatin
|
||||
It can be used to render custom markdown which include data gathered by metrics.
|
||||
Unlike SVG templates, it is possible to include revelant hyperlinks since it'll be rendered as regular markdown.
|
||||
|
||||
You can even mix it with SVG plugins for even more customization.
|
||||
You can even mix it with SVG plugins for even more customization using `embed` function.
|
||||
|
||||
See [example.md](/source/templates/markdown/example.md) for a markdown template example.
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ I joined GitHub on `{{ f.date(REGISTRATION_DATE, {dateStyle:"short"}) }}`.
|
||||
I contributed to `{{ REPOSITORIES_CONTRIBUTED_TO }}` repositories and made `{{ COMMITS }}` commits.
|
||||
```
|
||||
|
||||
<%- await embed({isocalendar:true}) %>
|
||||
|
||||
## 🧩 Plugins
|
||||
|
||||
### Using markdown plugins
|
||||
@@ -50,8 +48,12 @@ ___
|
||||
|
||||
### Embedding SVG metrics
|
||||
|
||||
You can also generate "on-the-fly" SVGs metrics image using the `embed` function:
|
||||
To include SVGs metrics images without creating additional jobs, use the `embed` function:
|
||||
|
||||
<%- await embed({isocalendar:true, isocalendar_duration:"full-year"}) %>
|
||||
<%- await embed("example-isocalendar", {isocalendar:true, isocalendar_duration:"full-year"}) %>
|
||||
|
||||
Available configuration options are mostly the same as [action.yml](https://github.com/lowlighter/metrics/blob/master/action.yml). Note that tokens options must **not** be passed to this function. These will be automatically passed down when defined in your workflow job.
|
||||
It takes two arguments:
|
||||
- An unique identifier which will be used as filename withing `markdown_cache` folder
|
||||
- Configuration options (see [action.yml](https://github.com/lowlighter/metrics/blob/master/action.yml))
|
||||
- Tokens options are automatically passed down from your workflow job, do not pass them again
|
||||
- Options syntax is same as web instance (i.e. dots (`.`) instead of underscores (`_`) and no `plugin_` prefixes)
|
||||
|
||||
Reference in New Issue
Block a user