Skip to content

Commit

Permalink
feat: search page with multilingual and search all language pages
Browse files Browse the repository at this point in the history
close #26
  • Loading branch information
tomowang committed Mar 12, 2024
1 parent ae1fe40 commit c180809
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 5 deletions.
5 changes: 5 additions & 0 deletions content/search/_index.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.es.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.fr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.hi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.jp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.pl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
5 changes: 5 additions & 0 deletions content/search/_index.zh-cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
+++
layout = "search"
outputs = ["html", "json"]
sitemap.priority = 0.1
+++
2 changes: 1 addition & 1 deletion layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="flex-none mx-1"></div>
{{ end }}
<div class="flex-none md:hidden">
<a href="/search/" class="inline-flex items-center p-2 text-sm text-slate-800 dark:text-slate-200 rounded-lg" aria-controls="navbar-menu" aria-expanded="false">
<a href={{ relLangURL "/search/" }} class="inline-flex items-center p-2 text-sm text-slate-800 dark:text-slate-200 rounded-lg" aria-controls="navbar-menu" aria-expanded="false">
<span class="sr-only">{{ T "search.title" }}</span>
<i class="w-8 h-8">
{{ partial "icon.html" "search" }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<section class="pl-6 mt-6 w-full max-w-4xl lg:max-w-5xl">
<form class="" action="/search/" method="get">
<form class="" action={{ relLangURL "/search/" }} method="get">
<div class="flex">
<input type="text" name="search" id="search-input" required placeholder="{{ T "search.placeholder" }}" class="rounded-none rounded-s-lg border border-gray-300 text-slate-800 focus:outline-none focus:ring-blue-500 focus:border-blue-500 block flex-1 min-w-0 w-full text-sm p-3 dark:bg-slate-700 dark:border-slate-600 dark:placeholder-slate-400 dark:text-slate-200 dark:focus:ring-blue-500 dark:focus:border-blue-500">
<button class="inline-flex items-center px-3 text-sm text-slate-900 bg-slate-200 border border-e-0 border-gray-300 rounded-e-lg dark:bg-slate-600 dark:text-slate-400 dark:border-slate-600">
Expand Down
8 changes: 5 additions & 3 deletions layouts/search/search.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{- $.Scratch.Add "index" slice -}}
{{- $pages := where .Site.RegularPages "Params.hidden" "!=" true -}}
{{- range $pages -}}
{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "categories" .Params.categories "content" .Plain "permalink" .Permalink) -}}
{{- range .Site.Sites -}}
{{- $pages := where .RegularPages "Params.hidden" "!=" true -}}
{{- range $pages -}}
{{- $.Scratch.Add "index" (dict "title" .Title "tags" .Params.tags "categories" .Params.categories "content" .Plain "permalink" .Permalink) -}}
{{- end -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}

0 comments on commit c180809

Please sign in to comment.