1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-12-24 01:42:10 +00:00

Add structured data for SearchAction

Should support a sitelinks searchbox now.
This commit is contained in:
Rohan Kumar 2022-06-09 11:13:25 -07:00
parent b9ee2b3e20
commit 6042b0bdaf
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
6 changed files with 31 additions and 6 deletions

View file

@ -8,7 +8,9 @@ description: "Seirdy's Home: personal website and blog for Rohan Kumar, A.K.A. S
sitemap:
- ChangeFreq: weekly
- Priority: 0.9
stype: "WebSite"
---
<meta itemprop="url" content="https://seirdy.one" />
<div itemprop="author" itemscope="" itemtype="https://schema.org/Person" itemid="https://seirdy.one/#seirdy" class="p-author author h-card vcard" id="seirdy">
Seirdys Home

View file

@ -1,9 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{- default "" .Site.LanguageCode }}" xml:lang="{{- default "" .Site.LanguageCode }}" prefix="og: https://ogp.me/ns# article: https://ogp.me/ns/article# cc: http://creativecommons.org/ns#">
{{ partial "head.html" . -}}
<body itemscope="" itemtype="https://schema.org/WebPage">
{{- $stype := "WebPage" -}}
{{- with .Params.stype -}}
{{- $stype = . -}}
{{- end -}}
<body itemscope="" itemtype="https://schema.org/{{ $stype }}">
{{ partial "header.html" . -}}
{{- block "main" . }}{{- end -}}
{{ partialCached "footer.html" . }}
{{ partial "footer.html" . }}
</body>
</html>

View file

@ -1,10 +1,12 @@
{{ define "main" -}}
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" }}
<main itemprop="mainEntity" itemscope="" itemtype="https://schema.org/SearchResultsPage" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
<main >
<h1>Search</h1>
<p role="note">This page is an unfinished work-in-progress.</p>
{{ partial "search.html" . }}
<hr />
<div itemprop="mainEntity" itemscope="" itemtype="https://schema.org/SearchResultsPage" itemid="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">
{{ readFile "/dynamic/search-results.html" | safeHTML }}
</div>
</main>
{{ end }}

View file

@ -3,7 +3,9 @@
<p>
Copyright <time itemprop="copyrightYear" datetime="{{now.Year}}">{{now.Year}}</time> {{ partial "indieweb-author.html" -}}
</p>
{{ partial "search.html" }}
{{ if ne .Title "Search" -}}
{{- partial "search.html" -}}
{{- end -}}
<nav aria-label="site info">
<ul>
<li itemprop="license" itemscope="" itemtype="https://schema.org/CreativeWork">

View file

@ -1,11 +1,12 @@
<form
itemprop="potentialAction" itemscope="" itemtype="https://schema.org/SearchAction"
action="https://seirdy.one/search/" method="get" role="search">
<label for="search">
<label for="search" itemscope="" itemprop="target" itemtype="https://schema.org/EntryPoint">
Search this site (powered by the <a rel="nofollow" href="https://searchmysite.net/">Search My Site</a> API):
<meta itemprop="urlTemplate" content="http://seirdy.one/search?q={q}" />
</label>
<div><!--We need the extra divs to serve as pseudo-table-cells.-->
<input id="search" type="search" itemprop="query" name="q" spellcheck="true" />
<input itemprop="query-input" id="search" type="search" required="" name="q" />
<div><input type="submit" value="search" /></div>
</div>
</form>

View file

@ -13,6 +13,20 @@
.message == "Attribute “media” not allowed on element “meta” at this point."
and (.extract | test(" name=\"theme-color\""))
)
or
( # Allow raw templates
(.url | test ("/search/index."))
and (
(.message == "Text not allowed in element “ol” in this context.")
or
(.message == "Bad value “{{ .URL }}” for attribute “href” on element “a”: Illegal character in path segment: “{” is not allowed.")
)
and (
(.extract | test("{{"))
or
(.extract | test("}}"))
)
)
) | not
)
) | del(..|select(. == [])) | del(..|select(. == {})) | select(. != null)