mirror of
https://git.sr.ht/~seirdy/seirdy.one
synced 2024-12-24 01:42:10 +00:00
Display search results on my own site
Use the SearchMySite API to gather results and render them in HTML on my own site. I'll open-source the Go program that generates the results soon.
This commit is contained in:
parent
b42212f158
commit
5f48ca7bbe
5 changed files with 47 additions and 4 deletions
7
content/search.md
Normal file
7
content/search.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
outputs:
|
||||
- html
|
||||
title: Search
|
||||
description: "Search seirdy.one."
|
||||
layout: "search"
|
||||
---
|
1
dynamic/README.txt
Normal file
1
dynamic/README.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Files in this directory represent dynamic pages, containing raw templates to be populated on the server side
|
28
dynamic/search-results.html
Normal file
28
dynamic/search-results.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<p>
|
||||
{{ .TotalResults }} results
|
||||
</p>
|
||||
<ol>
|
||||
{{- range .Results }}
|
||||
<li>
|
||||
<a href="{{ .URL }}">
|
||||
<h2>
|
||||
{{ if .Title -}}
|
||||
{{- .Title }}
|
||||
{{ else -}}
|
||||
{{- .URL }}
|
||||
{{- end }}
|
||||
</h2>
|
||||
</a>
|
||||
<p>{{ printf "%.200s" .Desc }}</p>
|
||||
<p>
|
||||
{{ $isMatch := false }}
|
||||
{{ range .Frag }}
|
||||
{{ if $isMatch }}<strong>{{ end -}}
|
||||
{{ printf . }}
|
||||
{{- if $isMatch }}</strong>{{ end }}
|
||||
{{ $isMatch = (not $isMatch) }}
|
||||
{{ end }}
|
||||
</p>
|
||||
</li>
|
||||
{{- end }}
|
||||
</ol>
|
8
layouts/_default/search.html
Normal file
8
layouts/_default/search.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{ define "main" -}}
|
||||
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
|
||||
<main itemprop="mainEntity" itemscope="" itemtype="https://schema.org/SearchResultsPage" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
|
||||
{{ partial "search.html" . }}
|
||||
<hr />
|
||||
{{ readFile "/dynamic/search-results.html" | safeHTML }}
|
||||
</main>
|
||||
{{ end }}
|
|
@ -1,12 +1,11 @@
|
|||
<form
|
||||
itemprop="potentialAction" itemscope="" itemtype="https://schema.org/SearchAction"
|
||||
action="https://searchmysite.net/search/" method="get" role="search">
|
||||
action="https://seirdy.one/search/" method="get" role="search">
|
||||
<label for="search">
|
||||
Search this site (powered by <a rel="nofollow" href="https://searchmysite.net/">Search My Site</a>):
|
||||
Search this site (powered by the <a rel="nofollow" href="https://searchmysite.net/">Search My Site</a> API):
|
||||
</label>
|
||||
<div><!--We need the extra divs to serve as pseudo-table-cells.-->
|
||||
<input id="search" type="search" itemprop="query"
|
||||
value="domain:seirdy.one " name="q" spellcheck="true" />
|
||||
<input id="search" type="search" itemprop="query" name="q" spellcheck="true" />
|
||||
<div><input type="submit" value="search" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
Loading…
Reference in a new issue