Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pagefind as search provider #81

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion content/search_and_more.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ third already?) blog: [notes.rmhogervorst.nl](https://notes.rmhogervorst.nl/)

## Search

{{<search>}}
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
<script src="/pagefind/pagefind-ui.js"></script>
<div id="search"></div>
<script>
window.addEventListener('DOMContentLoaded', (event) => {
new PagefindUI({ element: "#search", showSubResults: true });
});
</script>
10 changes: 5 additions & 5 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
<div class="container" role="main">
<div class="row">
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<article role="main" class="blog-post h-entry">
<article role="main" class="blog-post h-entry" data-pagefind-body>
<div class="e-content">
{{ .Content }}
</div>
<hr>
<a class="u-url" href="{{ .Permalink }}"><div class="p-name">{{ .Title }} </div></a>
<a class="u-url" href="{{ .Permalink }}"><div class="p-name" data-pagefind-meta="title">{{ .Title }} </div></a>
<time datetime="{{ .Date |time.Format "2006-01-02T15:04:05-07:00" }}" class="dt-published">{{ $datestr | i18n "postedOnDate"}} </time>
by {{ if not .Site.Params.hideAuthor }}
{{ if .Params.author }}
Expand All @@ -21,23 +21,23 @@
{{ if .Params.tags }}
<div class="blog-tags p-category">
{{ range .Params.tags }}
<a href="{{ $.Site.LanguagePrefix | absURL }}tags/{{ . | urlize }}/">{{ . }}</a>&nbsp;
<a href="{{ $.Site.LanguagePrefix | absURL }}tags/{{ . | urlize }}/" data-pagefind-filter="tag">{{ . }}</a>&nbsp;
{{ end }}
</div>
{{ end }}
{{ if .Params.difficulty }}
<div>
More posts of level:
{{ range .Params.difficulty }}
<a href="{{ $.Site.LanguagePrefix | absURL }}/difficulty/{{ . | urlize }}/">{{ . }}</a>&nbsp;
<a href="{{ $.Site.LanguagePrefix | absURL }}/difficulty/{{ . | urlize }}/" data-pagefind-filter="difficulty">{{ . }}</a>&nbsp;
{{ end }}
</div>
{{ end }}
{{ if .Params.post_type }}
<div>
More :
{{ range .Params.post_type }}
<a href="{{ $.Site.LanguagePrefix | absURL }}/post-type/{{ . | urlize }}/">{{ . }}</a>&nbsp;
<a href="{{ $.Site.LanguagePrefix | absURL }}/post-type/{{ . | urlize }}/" data-pagefind-filter="post type">{{ . }}</a>&nbsp;
{{ end }}
posts.
</div>
Expand Down
2 changes: 1 addition & 1 deletion netlify.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build]
publish = "public"
command = "hugo --minify"
command = "hugo --minify && ./pagefind --site public"

[context.production.environment]
HUGO_VERSION = "0.82.0"
Expand Down
Binary file added pagefind
Binary file not shown.
5 changes: 4 additions & 1 deletion useful_commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ find . -name "*.jpg" -exec jpegoptim --all-progressive --strip-all '{}' \;

# go to content/ folder and execute
find . -name "*.png" -exec optipng '{}' \;
find . -name "*.jpg" -exec jpegoptim --all-progressive --strip-all '{}' \;
find . -name "*.jpg" -exec jpegoptim --all-progressive --strip-all '{}' \;


/home/roel/.local/share/Hugo/0.82.0/hugo --minify --buildFuture && ./pagefind --site public