<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>JavaScript on Unigiri</title>
    <link>https://unigiri.gitlab.io/tags/javascript/</link>
    <description>Recent content in JavaScript on Unigiri</description>
    <image>
      <title>Unigiri</title>
      <url>https://unigiri.gitlab.io/images/unigiri.png</url>
      <link>https://unigiri.gitlab.io/images/unigiri.png</link>
    </image>
    <generator>Hugo</generator>
    <language>ja-JP</language>
    <lastBuildDate>Sun, 04 Nov 2018 23:54:29 +0900</lastBuildDate>
    <atom:link href="https://unigiri.gitlab.io/tags/javascript/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Hugo &#43; Lunrによる日本語全文検索</title>
      <link>https://unigiri.gitlab.io/posts/full-text-japanese-search-with-hugo-plus-lunr/</link>
      <pubDate>Sun, 04 Nov 2018 23:54:29 +0900</pubDate>
      <guid>https://unigiri.gitlab.io/posts/full-text-japanese-search-with-hugo-plus-lunr/</guid>
      <description>&lt;h2 id=&#34;hugoとは&#34;&gt;Hugoとは&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://gohugo.io/&#34;&gt;Hugo&lt;/a&gt;とは静的ページを生成するGo製のフレームワークである。&lt;/p&gt;
&lt;h2 id=&#34;lunrとは&#34;&gt;Lunrとは&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://lunrjs.com/&#34;&gt;Lunr&lt;/a&gt;とはJavaScript製のテキスト検索エンジンである。日本語検索に対応している。&lt;sup id=&#34;fnref:1&#34;&gt;&lt;a href=&#34;#fn:1&#34; class=&#34;footnote-ref&#34; role=&#34;doc-noteref&#34;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;h2 id=&#34;検索機能設置方法&#34;&gt;検索機能設置方法&lt;/h2&gt;
&lt;p&gt;以降の内容は &lt;a href=&#34;https://gist.github.com/sebz/efddfc8fdcb6b480f567&#34;&gt;https://gist.github.com/sebz/efddfc8fdcb6b480f567&lt;/a&gt; 及び &lt;a href=&#34;https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae&#34;&gt;https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae&lt;/a&gt; を参考にしている。&lt;/p&gt;
&lt;h3 id=&#34;ファイル構成&#34;&gt;ファイル構成&lt;/h3&gt;
&lt;p&gt;導入後のファイル構成は以下の通り。検索機能に関わる部分のみ記載している。&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;BLOG_DIR
├── layouts
│   ├── _default
│   │   └── index.json
│   └── index.html
└── static
    └── js
        ├── lunr.jp.js
        ├── lunr.js
        ├── lunr.multi.js
        ├── lunr.stemmer.support.js
        ├── search.js
        └── tinyseg.js
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;1-検索用データ設置&#34;&gt;1. 検索用データ設置&lt;/h3&gt;
&lt;p&gt;Lunrが検索対象として読み込むデータを設置する。ここでは全記事のタイトル, タグ, カテゴリ, 本文, hrefをJSON形式で書き出す。&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;layouts/_default/index.json&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;{{- $.Scratch.Add &amp;#34;index&amp;#34; slice -}}
{{- range .Site.RegularPages -}}
    {{- $.Scratch.Add &amp;#34;index&amp;#34; (dict &amp;#34;title&amp;#34; (or .Title (.Date.Format &amp;#34;2006/01/02&amp;#34;)) &amp;#34;tags&amp;#34; .Params.tags &amp;#34;categories&amp;#34; .Params.categories &amp;#34;contents&amp;#34; .Plain &amp;#34;href&amp;#34; .URL ) -}}
{{- end -}}
{{- $.Scratch.Get &amp;#34;index&amp;#34; | jsonify -}}
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;3行目の&lt;code&gt;&amp;quot;title&amp;quot; (or .Title (.Date.Format &amp;quot;2006/01/02&amp;quot;))&lt;/code&gt;は弊サイト独自の仕様であり、通常は&lt;code&gt;&amp;quot;title&amp;quot; .Title&lt;/code&gt;でよい。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
