Add markdown template (#209)
This commit is contained in:
29
source/templates/markdown/README.md
Normal file
29
source/templates/markdown/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
### 📒 Markdown (🚧 v3.7)
|
||||
|
||||
Markdown template can render a **markdown template** by interpreting **templating brackets** `{{` and `}}`.
|
||||
|
||||
<table>
|
||||
<td align="center">
|
||||
<img width="900" height="1" alt="">
|
||||
</td>
|
||||
</table>
|
||||
|
||||
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.
|
||||
|
||||
See [example.md](/source/templates/markdown/example.md) for a markdown template example.
|
||||
|
||||
#### ℹ️ Examples workflows
|
||||
|
||||
```yaml
|
||||
- uses: lowlighter/metrics@latest
|
||||
with:
|
||||
# ... other options
|
||||
template: markdown
|
||||
filename: README.md # Output file
|
||||
markdown: TEMPLATE.md # Template file
|
||||
markdown_cache: .cache # Cache folder
|
||||
config_output: markdown # Output as markdown file
|
||||
```
|
||||
27
source/templates/markdown/example.md
Normal file
27
source/templates/markdown/example.md
Normal file
@@ -0,0 +1,27 @@
|
||||
# 📒 Markdown template example
|
||||
|
||||
This is a markdown template example which explain the basic usage of this template.
|
||||
|
||||
## 🈂️ Templating syntax:
|
||||
|
||||
* Regular EJS syntax is supported
|
||||
* `{{` and `}}` will be interpolated as EJS brackets (syntaxic sugar)
|
||||
* `{%` and `%}` can be used as control statements
|
||||
* Use [metrics.lecoq.io](https://metrics.lecoq.io/) with `config.output=json` to see available data
|
||||
* You can also use `config_output: json` in GitHub Actions and/or inspect [metrics](https://github.com/lowlighter/metrics) code to get available data too
|
||||
|
||||
## 🧩 Markdown plugins
|
||||
|
||||
Most of plugins from SVG templates can be reused directly by including image source in markdown, but some have them have their own **markdown** version which includes hyperlinks.
|
||||
|
||||
### 📰 Recent activity
|
||||
|
||||
<%- await include(`partials/activity.ejs`) %>
|
||||
|
||||
### ✒️ Recent posts
|
||||
|
||||
*Coming soon*
|
||||
|
||||
### 🗼 Rss feed
|
||||
|
||||
*Coming soon*
|
||||
1
source/templates/markdown/image.svg
Normal file
1
source/templates/markdown/image.svg
Normal file
@@ -0,0 +1 @@
|
||||
You did not provide a valid "markdown" query parameter, which is required to use this template.
|
||||
1
source/templates/markdown/partials/_.json
Normal file
1
source/templates/markdown/partials/_.json
Normal file
@@ -0,0 +1 @@
|
||||
[]
|
||||
44
source/templates/markdown/partials/activity.ejs
Normal file
44
source/templates/markdown/partials/activity.ejs
Normal file
@@ -0,0 +1,44 @@
|
||||
<%_ if (plugins.activity) { _%>
|
||||
<%_ if (plugins.activity.error) { _%>
|
||||
<%= plugins.activity.error.message _%>
|
||||
<%_ } else if (plugins.activity.events.length) { _%>
|
||||
<%_ for (const {actor, type, repo, timestamp, ...event} of plugins.activity.events) { _%>
|
||||
<%_ if (type === "comment") { _%>
|
||||
* 💬 Commented on [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/<%= {issue:"issues", pr:"pulls", commit:"commit"}[event.on] %>/<%= event.number %>) from [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "member") { _%>
|
||||
* 💼 Added [<%= event.user %>](https://github.com/<%= event.user %>) as collaborator in [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "star") { _%>
|
||||
* 🌟 Starred [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "release") { _%>
|
||||
* 📦 <%- event.draft ? "Drafted release" : event.prerelease ? "Pre-released" : "Released" %> **<%= event.name %>** of [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "fork") { _%>
|
||||
* 🍽️ Forked [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "push") { _%>
|
||||
* ➡️ Pushed <%= event.size %> commit<%= s(event.size) %> in [<%= repo %>](https://github.com/<%= repo %>) <%= event.branch ? `on branch \`${event.branch}\`` : "" %>
|
||||
<%_ for (const commit of event.commits) { _%>
|
||||
* [#<%= commit.sha %>](https://github.com/<%= repo %>/commit/<%= commit.sha %>) <%= commit.message %>
|
||||
<%_ } _%>
|
||||
<%_ } else if (type === "issue") { _%>
|
||||
* #️⃣ <%- event.action === "opened" ? "Opened" : event.action === "reopened" ? "Reopened" : "Closed" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/issues/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "pr") { _%>
|
||||
* 🔃 <%- event.action === "opened" ? "Opened" : "Merged" %> [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pulls/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||
* <%= event.files.changed %> file<%= s(event.files.changed) %> changed `++<%= event.lines.added %> --<%= event.lines.deleted%>`
|
||||
<%_ } else if (type === "wiki") { _%>
|
||||
* 📝 Updated <%= event.pages.length %> wiki page<%= s(event.pages.length) %> in [<%= repo %>](https://github.com/<%= repo %>/wiki)
|
||||
<%_ for (const page of event.pages) { _%>
|
||||
* <%= page %>
|
||||
<%_ } _%>
|
||||
<%_ } else if (type === "public") { _%>
|
||||
* 🚀 Made [<%= repo %>](https://github.com/<%= repo %>) public
|
||||
<%_ } else if (type === "review") { _%>
|
||||
* 🔍 Reviewed [#<%= event.number %> <%= event.title %>](https://github.com/<%= repo %>/pulls/<%= event.number %>) in [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "ref/create") { _%>
|
||||
* ⏺️ Created new <%= event.ref.type %> `<%= event.ref.name %>` in [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } else if (type === "ref/create") { _%>
|
||||
* 🚮 Deleted <%= event.ref.type %> `<%= event.ref.name %>` from [<%= repo %>](https://github.com/<%= repo %>)
|
||||
<%_ } _%>
|
||||
<%_ } _%>
|
||||
<%_ } else { _%>
|
||||
No recent activity
|
||||
<%_ } _%>
|
||||
<%_ } _%>
|
||||
Reference in New Issue
Block a user