Skip to content

Commit

Permalink
add github button script
Browse files Browse the repository at this point in the history
  • Loading branch information
bdfinst committed Mar 12, 2024
1 parent a112475 commit 56add62
Show file tree
Hide file tree
Showing 8 changed files with 222 additions and 88 deletions.
19 changes: 19 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
public/
node_modules/
.cache
.history
dist
coverage
docs/app
__mocks__
userguide/
.release-please-manifest.json
CHANGELOG.md
.vscode/
assets/js/drawio.js
assets/js/markmap.js
assets/js/mermaid.js
assets/js/plantuml.js
assets/js/base.js
static/js/deflate.js
static/js/swagger*.js
22 changes: 22 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"plugins": [
"prettier-plugin-go-template"
],
"trailingComma": "es5",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"bracketSpacing": true,
"editorconfig": true,
"htmlWhitespaceSensitivity": "ignore",
"overrides": [
{
"files": [
"*.html"
],
"options": {
"parser": "go-template"
}
}
]
}
30 changes: 17 additions & 13 deletions layouts/home.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{{ define "main" }} {{ if not .Site.Params.homePage -}} {{ with .Content }} {{ .
}} {{ end }} {{ else -}} {{ with .Site.Params.homePage -}}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0;url={{.}}" />

{{ with .Site.Params.custom_js }} {{ range . -}}
<script async defer src="{{ . | absURL }}"></script>
{{- end }} {{- end }}
</head>
</html>
{{ end -}} {{ end -}} {{ end }}
{{ define "main" }}
{{ $site := . }} {{/* Save the global context */}}
{{ if not
.Site.Params.homePage
}}
{{ with .Content }}{{ . }}{{ end }}
{{ else }}
{{ with .Site.Params.homePage }}
<!doctype html>
<html>
<head>
<meta http-equiv="refresh" content="0;url={{ . }}" />
</head>
</html>
{{ end }}
{{ end }}
{{ end }}
105 changes: 105 additions & 0 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
{{ range .AlternativeOutputFormats -}}
<link
rel="{{ .Rel }}"
type="{{ .MediaType.Type }}"
href="{{ .Permalink | safeURL }}"
/>
{{ end -}}
{{ $outputFormat := partial "outputformat.html" . -}}
{{ if and
hugo.IsProduction (ne $outputFormat "print")
-}}
<meta name="robots" content="index, follow" />
{{ else -}}
<meta name="robots" content="noindex, nofollow" />
{{ end -}}
{{ partialCached "favicons.html" . }}
<title>
{{- if .IsHome -}}
{{ .Site.Title -}}
{{ else -}}
{{ with .Title }}{{ . }} |{{ end -}} {{ .Site.Title -}}
{{ end -}}
</title>
<meta
name="description"
content="{{ template "partials/page-description.html" . }}"
/>
{{ template "_internal/opengraph.html" . -}}
{{ template
"_internal/schema.html" .
-}}
{{ template "_internal/twitter_cards.html" . -}}
{{ partialCached "head-css.html" . "asdf" -}}
<script
src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
crossorigin="anonymous"
></script>
{{ if .Site.Params.offlineSearch -}}
<script
defer
src="https://unpkg.com/[email protected]/lunr.min.js"
integrity="sha384-203J0SNzyqHby3iU6hzvzltrWi/M41wOP5Gu+BiJMz5nwKykbkUx8Kp7iti0Lpli"
crossorigin="anonymous"
></script>
{{ end -}}
{{ with .Site.Params.custom_js }}
{{ range . }}
<script async defer src="{{ . | absURL }}"></script>
{{ end }}
{{ end }}
{{ if .Site.Params.prism_syntax_highlighting -}}
<link rel="stylesheet" href="{{ "css/prism.css" | relURL }}" />
{{ end -}}
{{ template
"algolia/head" .
-}}
{{ partial "hooks/head-end.html" . -}}
{{/* To comply with
GDPR, cookie consent scripts places in head-end must execute before Google
Analytics is enabled */
-}}
{{ if hugo.IsProduction -}}
{{ $enableGtagForUniversalAnalytics := not
.Site.Params.disableGtagForUniversalAnalytics
-}}
{{ if (or
$enableGtagForUniversalAnalytics (hasPrefix
.Site.Config.Services.GoogleAnalytics.ID "G-"))
-}}
{{ template
"_internal/google_analytics_gtag.html" .
-}}
{{ else -}}
{{ template
"_internal/google_analytics_async.html" .
-}}
{{ end -}}
{{ end -}}
{{ define
"algolia/head"
-}}
{{ if and .Site.Params.search (isset .Site.Params.search
"algolia")
-}}
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@docsearch/[email protected]"
integrity="sha512-TW5eKlwwg7OfQUVBqxjp94/uqtjJJbhkRE3++XGEQjAL1n3y//QVqS3acPkwqkzInaFRtj+w05uyxDbfDXiI1A=="
crossorigin="anonymous"
/>
{{ end -}}
{{ if ne .Site.Params.algolia_docsearch nil -}}
{{ warnf `Config
'params.algolia_docsearch' is deprecated: use 'params.search.algolia' For
details, see
https://www.docsy.dev/docs/adding-content/search/#algolia-docsearch.`
-}}
{{ end -}}
{{ end -}}
14 changes: 14 additions & 0 deletions layouts/partials/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@
{{ end }}
</ul>
</div>
{{- with .Site.Params.github_repo }}
<nav>
<a
class="github-button"
href="{{.}}"
target="_blank"
data-color-scheme="no-preference: light; light: light; dark: dark;"
data-size="large"
data-show-count="true"
aria-label="Star {{.}} on GitHub"
>Star</a>
</nav>
{{- end}}

{{ if .Site.Params.ui.navbar_search -}}
<div class="d-none d-lg-block" id="search">
{{ partial "search-input.html" . }}
Expand Down
73 changes: 0 additions & 73 deletions layouts/partials/section-index copy.html

This file was deleted.

43 changes: 42 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
"husky": "^9.0.11",
"linkinator": "^6.0.4",
"markdownlint-cli": "^0.39.0",
"postcss-cli": "^11.0.0"
"postcss-cli": "^11.0.0",
"prettier": "^3.2.5",
"prettier-plugin-go-template": "^0.0.15"
}
}

0 comments on commit 56add62

Please sign in to comment.