Skip to content

Commit

Permalink
use algolia search
Browse files Browse the repository at this point in the history
  • Loading branch information
hitsumabushi committed Dec 14, 2024
1 parent 2c6738f commit f65abc0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
- name: upload to algolia index
uses: wangchucheng/algolia-uploader@master
with:
app_id: ${{ secrets.ALGOLIA_APP_ID }}
# You can store token in your project's 'Setting > Secrets' and reference the name here. Such as ${{ secrets.ALGOLIA_ADMIN_KEY }}
admin_key: ${{ secrets.ALGOLIA_WRITE_API_KEY }}
index_name: blog
index_file_path: public/algolia.json
# ビルドの実行結果を Slack に投稿する
- name: Send notification to slack channel
uses: rtCamp/action-slack-notify@v2
Expand Down
23 changes: 11 additions & 12 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ enableInlineShortcodes = true # inline short code

# algolia site search
algolia_search = true
algolia_appId = ""
algolia_indexName = ""
algolia_apiKey = ""
algolia_appId = "QDYUDRXVCE"
algolia_indexName = "blog"
algolia_apiKey = "cbbbe16271381182bbac5e643c50d1d3"

# Sidebar settings
sidebar_about_description = "SRE Engineering Manager in Tokyo, Japan"
Expand Down Expand Up @@ -111,13 +111,12 @@ enableInlineShortcodes = true # inline short code
# title = "ABOUT"
# href = "/about/"

[outputFormats.Algolia]
baseName = "algolia"
isPlainText = true
mediaType = "application/json"
notAlternative = true

# [outputFormats.Algolia]
# baseName = "algolia"
# isPlainText = true
# mediaType = "application/json"
# notAlternative = true

# [params.algolia]
# vars = ["title", "summary", "date", "publishdate", "expirydate", "permalink"]
# params = ["categories", "tags"]
[params.algolia]
vars = ["title", "summary", "date", "publishdate", "expirydate", "permalink"]
params = ["categories", "tags", "keywords"]
11 changes: 11 additions & 0 deletions layouts/_default/list.algolia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{/* Generates a valid Algolia search index */}}
{{- $.Scratch.Add "index" slice -}}
{{- $section := $.Site.GetPage "section" .Section }}
{{- range .Site.AllPages -}}
{{- if and (and (.IsDescendant $section) (and (not .Draft) (not .Params.private))) $section.IsHome -}}
{{- if (and (eq .Section "post") (ne .Permalink "/post/") (.File) ) -}}
{{- $.Scratch.Add "index" (dict "objectID" .File.UniqueID "date" .Date.UTC.Unix "description" .Description "dir" .File.Dir "expirydate" .ExpiryDate.UTC.Unix "fuzzywordcount" .FuzzyWordCount "keywords" .Keywords "kind" .Kind "lang" .Lang "lastmod" .Lastmod.UTC.Unix "permalink" .Permalink "publishdate" .PublishDate "readingtime" .ReadingTime "relpermalink" .RelPermalink "html" .Params.Description "title" .Title "type" .Type "url" .RelPermalink "weight" .Weight "wordcount" .WordCount "section" .Section "tags" .Params.Tags "categories" .Params.Categories "author" .Params.authors "content" .Params.Description "excerpt_html" .Params.Description "excerpt_text" .Params.Description "summary" .Summary)}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}

0 comments on commit f65abc0

Please sign in to comment.