|
1 | | -### 📕 Community templates |
| 1 | +<table> |
| 2 | + <tr><th colspan="2"><h3>📕 Community templates</h3></th></tr> |
| 3 | + <tr><td colspan="2" align="center">A template capable of rendering markdown from a given template file.</td></tr> |
| 4 | + <tr> |
| 5 | + <td colspan="2" align="center"> |
| 6 | + <img src="https://github.com/lowlighter/lowlighter/blob/master/metrics.markdown.png" alt=""></img> |
| 7 | + <img width="900" height="1" alt=""> |
| 8 | + </td> |
| 9 | + </tr> |
| 10 | +</table> |
2 | 11 |
|
3 | | -It is possible to use official releases with templates from forked repositories (whether you own them or not). |
| 12 | +___ |
4 | 13 |
|
5 | | -Use `setup_community_templates` option to specify additional external sources using following format: `user/repo@branch:template`. |
6 | | -Templates added this way will be downloaded through git and can be used by prefixing their name with an `@`. |
| 14 | +Community templates are a way to use official releases of [lowlighter/metrics](https://github.com/lowlighter/metrics) while using templates from external repositories (owned or not). |
7 | 15 |
|
8 | | -By default, community templates use `template.mjs` from official `classic` template instead of their own, to prevent executing malicious code and avoid token leaks. |
| 16 | +## 📮 Using community templates |
9 | 17 |
|
10 | | -If you trust it, append `+trust` after their name. |
| 18 | +Use `setup_community_templates` option to specify additional external sources using following format: |
| 19 | +``` |
| 20 | +user/repo@branch:template |
| 21 | +``` |
| 22 | + |
| 23 | +These templates will be downloaded through git and will be usable by prefixing their name with an `@`. |
| 24 | + |
| 25 | +*Example: using `my-theme` template by downloading it from `user/repo`* |
| 26 | +```yml |
| 27 | +- uses: lowlighter/metrics@latest |
| 28 | + with: |
| 29 | + template: "@my-theme" |
| 30 | + setup_community_templates: "user/repo@main:my-theme" |
| 31 | +``` |
| 32 | +
|
| 33 | +For security reasons, community templates will use the `classic` template `template.mjs` instead of their own. |
| 34 | +If you trust a community template, append `+trust` to it. |
11 | 35 |
|
12 | | -```yaml |
| 36 | +*Example: using and trusting `my-theme` template by downloading it from `user/repo`* |
| 37 | +```yml |
13 | 38 | - uses: lowlighter/metrics@latest |
14 | 39 | with: |
15 | | - # ... other options |
16 | | - template: "@super-metrics" |
17 | | - # Download "super-metrics" and "trusted-metrics" templates from "octocat/metrics@master" |
18 | | - # "@trusted-metrics" template can execute remote JavaScript code |
19 | | - setup_community_templates: octocat/metrics@master:super-metrics, octocat/metrics@master:trusted-metrics+trust |
| 40 | + template: "@my-theme" |
| 41 | + setup_community_templates: "user/repo@main:my-theme+trust" |
20 | 42 | ``` |
21 | 43 |
|
22 | | -To create a new community template, fork this repository and create a new folder in `/source/templates` with same structure as current templates. |
23 | | -Then, it's just as simple as HTML and CSS with a bit of JavaScript! |
| 44 | +> ⚠️ Note that it basically allow remote code execution and the template may have access to **sensitive data** along with **tokens**! Use this feature only from a trusted source. Remember that its content may also change at any time... |
| 45 | + |
| 46 | +## 📪 Creating community templates |
| 47 | + |
| 48 | +To create a new template, start a new repository and create a new folder in `/source/templates` with the same file structure as in [lowlighter/metrics](https://github.com/lowlighter/metrics) templates: |
| 49 | + |
| 50 | +* `/source/templates` |
| 51 | + * `{template-name}` |
| 52 | + * `README.md`, |
| 53 | + * `metadata.yml`, |
| 54 | + * `image.svg` |
| 55 | + * `partials/` |
| 56 | + * `_.json` |
| 57 | + * `*.ejs` |
| 58 | + |
| 59 | +Then use HTML, CSS, and [EJS](https://github.com/mde/ejs) to create something awesome! |
| 60 | +Do not hesitate to share it on [GitHub discussions](https://github.com/lowlighter/metrics/discussions)! |
24 | 61 |
|
25 | | -If you made something awesome, please share it here! |
| 62 | +For more information, see [contribution guide](/CONTRIBUTING.md). |
0 commit comments