Skip to content

Commit fbb9f33

Browse files
committed
feat: add tipuesearch-검색기능.mdx
1 parent b825b9a commit fbb9f33

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
---
2+
title: "Tipue Search로 블로그 검색 기능 추가하기"
3+
date: "2020-05-12"
4+
tags: ["Etc"]
5+
summary: "Add the ability to search for content in your blog with Tipue Search"
6+
description: "Tipue Search로 블로그 내의 컨텐츠를 검색하는 기능 추가하기"
7+
---
8+
9+
:::info
10+
jekyll theme 를 이용했던 시절, 문득 많은 컨텐츠가 있으면, 검색을 어떻게 할까? 라는 생각이 들었던 시절이 있다.
11+
tistory 나 네이버 블로그 등을 이용했을 때에는 개별적인 검색 기능이 내장되어 있어서 큰 고민을 하진 않았는데,
12+
jekyll theme 를 이용해서 git hub page 를 사용했을 때 고민이 되기 시작했었다.
13+
그래서 찾아보았더니 [TipueSearch](https://tipue.com/search/) 라는 jQuery plugin 이 있었는데,
14+
TipueSearch 를 적용하는 방법에 대해서 알아보고, 실제로 적용 시켜보자.
15+
:::
16+
17+
18+
### Step 1) [jekyll-tipue-search git](https://github.com/jekylltools/jekyll-tipue-search)에서 해당 소스를 내려받는다.
19+
20+
---
21+
22+
### Step 2) `search.html` 파일을 자신의 블로그 프로젝트의 최상위 디렉토리로 복사한다.
23+
24+
----
25+
```
26+
eottabom.github.io
27+
├── _includes
28+
├── _layouts
29+
...
30+
├── `search.html`
31+
...
32+
```
33+
34+
35+
### Step 3) search.html 파일을 수정한다.
36+
37+
----
38+
39+
```html
40+
$(document).ready(function() {
41+
$('#tipue_search_input').tipuesearch({
42+
'wholeWords': false,
43+
'showTime': false,
44+
'minimumLength': 1
45+
});
46+
});
47+
```
48+
옵션 중에서 본인이 원하는 것을 찾아서 적용 해주면 된다.
49+
+ contextBuffer: true
50+
- 컨텍스트에서 검색어 앞에 표시 되는 문자수(기본 값 60)
51+
+ contextLength: true
52+
- 최소 문자수(기본 값 60)
53+
+ contextStart: true
54+
- 검색어 앞에 설명 텍스트의 시작 위치가 컨텍스로 표시(기본 값 90)
55+
+ debug: true
56+
- 검색 결과 표시(기본 값 false)
57+
+ descriptiveWords
58+
- 검색에서 설명 텍스트에 표시되는 단어 수(기본 값 25)
59+
+ footerPages
60+
- 페이지 바닥 글에 표시 되는 최대 페이지 선택 수(기본 값 3)
61+
+ highlightTerms: true
62+
- 검색어가 강조 표시(기본 값 true)
63+
+ imageZoom: true
64+
- true : 이미지 클릭시 이미지 미리보기 표시
65+
- false : 이미지 클릭시 결과로 이동
66+
+ minimumLength
67+
- 검색 쿼리의 최소 문자 길이(기본 값은 3)
68+
+ newWindow: true
69+
- 검색 결과가 새 브라우저 탭에서 열림.(기본 값은 false)
70+
+ show
71+
- 표시 되는 결과 수(기본 값은 10)
72+
+ showContext: true
73+
- 검색어가 설명 텍스트에 컨텍스트로 표시(기본 값은 true)
74+
+ showRelated: true
75+
- 관련 검색이 표시(기본 값은 true)
76+
+ showTime
77+
- 검색 완료시 걸린 시간 표시(기본 값은 true)
78+
+ showTitleCount
79+
- 문서 제목에 검색 결과 수가 표시(기본 값은 true)
80+
+ showURL: true
81+
- 각 검색 결과에 URL이 표시(기본 값은 true)
82+
+ wholeWords: true
83+
- 영어만 검색(기본 값은 true)
84+
- 영어 이외의 언어를 사용하는 경우 false로 설정
85+
86+
87+
### Step 4) /assets/ 안에 있는 tipuesearch 폴더 역시 자신의 블로그 프로젝트의 최상위 디렉토리로 복사한다.
88+
89+
----
90+
91+
```
92+
eottabom.github.io
93+
├── _includes
94+
├── _layouts
95+
├── `assets`
96+
└── tipuesearch
97+
├── css
98+
│ ├── normalize.css
99+
│ └── tipuesearch.css
100+
├── search.png
101+
├── tipuesearch.min.js
102+
├── tipuesearch_content.js
103+
└── tipuesearch_set.js
104+
├── search.html
105+
...
106+
```
107+
108+
109+
### Step 5) _config.yml 파일을 수정한다.
110+
111+
----
112+
113+
```yaml
114+
tipue_search:
115+
include:
116+
pages: false
117+
collections: []
118+
exclude:
119+
files: [search.html, index.html, tags.html]
120+
categories: []
121+
tags: []
122+
```
123+
124+
### Step 6) head.html 에서 tipuesearch jQuery plugin 과 css를 추가해준다.
125+
126+
----
127+
```html
128+
<!-- tipuesearch -->
129+
<link rel="stylesheet" href="/assets/tipuesearch/css/tipuesearch.css">
130+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
131+
<script src="/assets/tipuesearch/tipuesearch_content.js"></script>
132+
<script src="/assets/tipuesearch/tipuesearch_set.js"></script>
133+
<script src="/assets/tipuesearch/tipuesearch.min.js"></script>
134+
```
135+
136+
### Step 7) 적용하고 싶은 html 파일에 tags 추가
137+
138+
----
139+
적절히 원하는 대로 커스터마이징 하면 될 것 같다.
140+
141+
```html
142+
<form action="/search">
143+
<div class="tipue_search_left">
144+
<img src="/assets/tipuesearch/search.png" class="tipue_search_icon">
145+
</div>
146+
<div class="tipue_search_right">
147+
<input type="text" name="q" id="tipue_search_input" pattern=".{1,}" title="At least 1 characters" required></div>
148+
<div style="clear: both;"></div>
149+
</form>
150+
```
151+

0 commit comments

Comments
 (0)