Adds support for custom_css and custom_js

This commit is contained in:
François Scala
2024-11-28 16:50:46 +01:00
parent 74b2fa2fe0
commit 3fb31add4f
2 changed files with 23 additions and 1 deletions

View File

@@ -137,6 +137,19 @@ you can add MathJax:true to frontmatter
``` ```
mathJax: true mathJax: true
``` ```
## Custom CSS and JS
Add your files in the static folder and list them in the custom_css and custom_js parameters
For example, with static/css/custom.css and static/js/custom.js, add to `config.toml`
```toml
[params]
custom_css = ["css/custom.css"]
custom_js = ["js/custom.js"]
```
## config.toml example ## config.toml example
```toml ```toml
@@ -167,6 +180,8 @@ pygmentsUseClasses = true
headerIcon = "/images/GitHub-Mark-Light-32px.png" headerIcon = "/images/GitHub-Mark-Light-32px.png"
location = "China" location = "China"
enableGitalk = true enableGitalk = true
custom_css = ["css/custom.css"]
custom_js = ["js/custom.js"]
[params.gitalk] [params.gitalk]
clientID = "Your client ID" clientID = "Your client ID"

View File

@@ -16,6 +16,13 @@
{{ end }} {{ end }}
<meta name="theme-color" content="#1e2327"> <meta name="theme-color" content="#1e2327">
{{ range .Site.Params.custom_css -}}
<link rel="stylesheet" href="{{ . | absURL }}">
{{- end }}
{{ range .Site.Params.custom_js -}}
<script type="text/javascript" src="{{ . | absURL }}"></script>
{{- end }}
<!-- Extended head section--> <!-- Extended head section-->
{{ partial "extended_head.html" . }} {{ partial "extended_head.html" . }}
</head> </head>