add pagefind search feature!
This commit is contained in:
parent
fec46cad31
commit
709670a774
|
@ -0,0 +1,13 @@
|
|||
:root {
|
||||
--pagefind-ui-scale: 1;
|
||||
--pagefind-ui-primary: #034ad8;
|
||||
--pagefind-ui-text: #ebdbb2;
|
||||
--pagefind-ui-background: #3c3836;
|
||||
--pagefind-ui-border: #eeeeee;
|
||||
--pagefind-ui-tag: #eeeeee;
|
||||
--pagefind-ui-border-width: 2px;
|
||||
--pagefind-ui-border-radius: 8px;
|
||||
----pagefind-ui-image-border-radius: 8px;
|
||||
--pagefind-ui-image-box-ratio: 3 / 2;
|
||||
--pagefind-ui-font: inherit;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
main {
|
||||
-webkit-font-feature-settings: "liga" on, "calt" on;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
font-family: 'JetBrains Mono', 'Input Mono', monospace;
|
||||
max-width: 38rem;
|
||||
padding: 2rem;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
@media only screen and (max-device-width: 736px) {
|
||||
main {
|
||||
padding: 0.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
::selection {
|
||||
background: #9c0018;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #282828;
|
||||
color: #ebdbb2;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #3c3836;
|
||||
padding: 1em;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
a, a:active, a:visited {
|
||||
color: #e491b6;
|
||||
background-color: #1d2021;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5 {
|
||||
margin-bottom: .1rem;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border-left: 1px solid #bdae93;
|
||||
margin: 0.5em 10px;
|
||||
padding: 0.5em 10px;
|
||||
}
|
||||
|
||||
footer {
|
||||
align: center;
|
||||
}
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
}
|
|
@ -1,17 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="{{ .Site.LanguageCode }}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="https://tilde.team/~ben/gruvbox/gruvbox.min.css">
|
||||
<title>{{- block "title" . }}{{ .Site.Title }}{{ end -}}</title>
|
||||
</head>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" type="text/css" href="/gruvbox.css">
|
||||
<link href="/_pagefind/pagefind-ui.css" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="/blog.css">
|
||||
<script src="/_pagefind/pagefind-ui.js" type="text/javascript"></script>
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', (event) => { new PagefindUI({ element: "#search" }); });
|
||||
</script>
|
||||
<title>{{- block "title" . }}{{ .Site.Title }}{{ end -}}</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
{{- partial "header.html" . -}}
|
||||
{{- block "main" . }}{{ end -}}
|
||||
{{- partial "footer.html" . -}}
|
||||
<div id="search"></div>
|
||||
{{- partial "header.html" . -}}
|
||||
{{- block "main" . }}{{ end -}}
|
||||
{{- partial "footer.html" . -}}
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{{ define "title" }}{{ .Title | lower }} – {{ .Site.Title }}{{ end }}
|
||||
|
||||
{{ define "main" }}
|
||||
<div data-pagefind-ignore>
|
||||
<h1>{{ .Title | lower }}</h1>
|
||||
|
||||
{{ .Content }}
|
||||
|
@ -13,5 +14,6 @@
|
|||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
{{- $pctx := . -}}
|
||||
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
|
||||
{{- $pages := slice -}}
|
||||
{{- if or $.IsHome $.IsSection -}}
|
||||
{{- $pages = $pctx.RegularPages -}}
|
||||
{{- else -}}
|
||||
{{- $pages = $pctx.Pages -}}
|
||||
{{- end -}}
|
||||
{{- $limit := .Site.Config.Services.RSS.Limit -}}
|
||||
{{- if ge $limit 1 -}}
|
||||
{{- $pages = $pages | first $limit -}}
|
||||
{{- end -}}
|
||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
|
||||
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
|
||||
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
|
||||
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
|
||||
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
|
||||
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
|
||||
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
|
||||
{{- with .OutputFormats.Get "RSS" -}}
|
||||
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
|
||||
{{- end -}}
|
||||
{{ range $pages }}
|
||||
<item>
|
||||
<title>{{ .Title }}</title>
|
||||
<link>{{ .Permalink }}</link>
|
||||
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
|
||||
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
|
||||
<guid>{{ .Permalink }}</guid>
|
||||
<description>{{ .Content | html }}</description>
|
||||
</item>
|
||||
{{ end }}
|
||||
</channel>
|
||||
</rss>
|
|
@ -1,6 +1,7 @@
|
|||
{{ define "title" }}{{ .Title }}{{ end }}
|
||||
|
||||
{{ define "main" }}
|
||||
<div data-pagefind-body>
|
||||
<h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
|
||||
|
||||
<time>{{ .Date.Format "Mon, 02 Jan 2006 15:04 MST" }}</time>
|
||||
|
@ -9,6 +10,7 @@
|
|||
<hr>
|
||||
|
||||
{{ .Content }}
|
||||
</div>
|
||||
|
||||
<script src="https://utteranc.es/client.js"
|
||||
repo="benharri/blog"
|
||||
|
|
Loading…
Reference in New Issue