Skip to content

Commit 45b5411

Browse files
committed
default template as external file and update of HOWTO
1 parent 8754227 commit 45b5411

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

HOWTO.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ All this theme are hosted on GitHub pages of the [markdown-css](https://github.c
2424
The custom HTML template can contain the following variables:
2525

2626
- `{{.html}}` contains the parsed html code from the markdown;
27-
- `{{.css}}` contains the css link obtained by the `--css` parameter;
27+
- `{{.css}}` contains a list of css links or codes obtained from the `--css` parameter;
2828
- `{{.title}}` contains the first `h1` title, or the `--title` parameter if no `h1` title is present in the code.
2929

3030
```shell
@@ -34,12 +34,14 @@ The custom HTML template can contain the following variables:
3434
We can use a file or a string as `--html` parameter (run in bash here):
3535

3636
```shell
37-
> echo "*test*" | gm -t "Test page" -c air --html $'title: {{.title}}\ncss: {{.css}}\nhtml: {{.html}}'
37+
> echo "*test*" | gm -q -t "Test page" -c air --html $'title: {{.title}}\ncss: {{.css}}\nhtml: {{.html}}'
3838
title: Test page
39-
css: https://kpym.github.io/markdown-css/air.min.css
39+
css: [{https://kpym.github.io/markdown-css/air.min.css }]
4040
html: <p><em>test</em></p>
4141
```
4242

43+
The default template is [gm_template.html](gm_template.html).
44+
4345
## Serve at localhost
4446

4547
When used with `--serve`/`-s` flag `gm` start serving all files from the specified folder. The `.md` files are converted and served as `html` but all other files are staticly served. To serve the current folder you can simply run:
@@ -64,7 +66,7 @@ Here is an example of possible `.gitlab-ci.yml`:
6466
pages:
6567
image: alpine
6668
script:
67-
- wget -c https://github.com/kpym/gm/releases/download/v0.18.3/gm_0.18.3_Linux_64bit.tar.gz -O - | tar -C /usr/local/bin -xz gm
69+
- wget -c https://github.com/kpym/gm/releases/download/v0.20.0/gm_0.20.0_Linux_intel64.tar.gz -O - | tar -C /usr/local/bin -xz gm
6870
- gm --pages '**/*'
6971
artifacts:
7072
paths:

gm_template.go

+3-27
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,9 @@ import (
55
)
66

77
// defaultHTMLTemplate is the default value for `html` flag
8-
var defaultHTMLTemplate string = `<!DOCTYPE html>
9-
<html>
10-
<head>
11-
<meta charset="utf-8">
12-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
13-
{{- range .css }}
14-
{{- with .Url }}
15-
<link rel="stylesheet" type="text/css" href="{{.}}">
16-
{{- end }}
17-
{{- with .Code }}
18-
{{.}}
19-
{{- end }}
20-
{{- end }}
21-
{{- with .title }}
22-
<title>{{.}}</title>
23-
{{- end }}
24-
</head>
25-
<body>
26-
<article class="markdown-body">
27-
{{.html}}
28-
</article>
29-
{{- if .liveupdate }}
30-
<script src="live.js#html,css"></script>
31-
{{- end }}
32-
</body>
33-
</html>
34-
`
8+
//
9+
//go:embed gm_template.html
10+
var defaultHTMLTemplate string
3511

3612
// the favicon image for all served pages
3713
//

gm_template.html

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
{{- range .css }}
8+
{{- with .Url }}
9+
<link rel="stylesheet" type="text/css" href="{{.}}">
10+
{{- end }}
11+
{{- with .Code }}
12+
{{.}}
13+
{{- end }}
14+
{{- end }}
15+
{{- with .title }}
16+
<title>{{.}}</title>
17+
{{- end }}
18+
</head>
19+
20+
<body>
21+
<article class="markdown-body">
22+
{{.html}}
23+
</article>
24+
{{- if .liveupdate }}
25+
<script src="live.js#html,css"></script>
26+
{{- end }}
27+
</body>
28+
29+
</html>

0 commit comments

Comments
 (0)