@@ -71,3 +71,64 @@ Syntax highlighted code block
7171```
7272
7373For more details see [ GitHub Flavored Markdown] ( https://guides.github.com/features/mastering-markdown/ ) .
74+
75+ ### Add new type of filter to search
76+
77+ Once you have added a new filter type using jekyll in default.html with ` meta ` , you can add it to the search engine.
78+ For example:
79+ Pass data directly from the metadata to search.
80+ ``` html
81+ <meta data-pagefind-filter =" author:{{author_name.name}}"
82+ property =" article:authors" content =" {{author}}" />
83+ ```
84+ Pass data from a html meta tag content parameter to search.
85+ ``` html
86+ <meta data-pagefind-filter =" mediatype[content]"
87+ property =" article:mediatypes" content =" {{mediatype}}" />
88+ ```
89+
90+ After that, you need to add the new filter type to search.html.
91+
92+ 1 . In div id="filters" in div class="row" add a new tag. Every new filter should be ended with ` _filter ` .
93+ ``` html
94+ <div id =" filters" class =" col-4" >
95+ <div class =" row" >
96+ <div class =" col-6" >
97+ <div id =" layouts_filter" ></div >
98+ <div id =" mediatypes_filter" ></div >
99+ </div >
100+ <div class =" col-6" >
101+ <div id =" authors_filter" ></div >
102+ <div id =" tags_filter" ></div >
103+ </div >
104+ <!-- here goes a new filter type -->
105+ <div class =" col-6" >
106+ <div id =" new_type_filter" ></div >
107+ </div >
108+ </div >
109+ </div >
110+ ```
111+
112+ 2 . In function ` display_filters() ` in javascript section
113+ ``` js
114+ ...
115+ document .getElementById (" authors_filter" ).innerHTML = " " ;
116+ document .getElementById (" tags_filter" ).innerHTML = " " ;
117+ // add here
118+ document .getElementById (" new_type_filter" ).innerHTML = " " ;
119+ ...
120+ ```
121+
122+ 3 . In function ` display_filters() ` in javascript section, add new case to ` switch `
123+ ``` js
124+ ...
125+ case " author" :
126+ document .getElementById (" authors_filter" ).innerHTML += new_filter;
127+ break ;
128+ case " new_type" :
129+ document .getElementById (" new_type_filter" ).innerHTML += new_filter;
130+ break ;
131+ ...
132+ ```
133+
134+ Finally recompile the docker and let pagefind create index.
0 commit comments