Skip to content

Commit 2e60a03

Browse files
committed
implement search
1 parent 88dc2bf commit 2e60a03

File tree

12 files changed

+175
-60
lines changed

12 files changed

+175
-60
lines changed

_config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,5 @@ defaults:
8282

8383
algolia:
8484
index_name: wurstscript
85-
application_id: 'A2BO3OY80G'
85+
application_id: 'A2BO3OY80G'
86+
search_only_api_key: 'dab955d0d2f46d0fa72e845eb9ea0ff2'

_includes/algolia.html

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- Including InstantSearch.js library and styling -->
2+
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.6.0/dist/instantsearch.min.js"></script>
3+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.6.0/dist/instantsearch.min.css">
4+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.6.0/dist/instantsearch-theme-algolia.min.css">
5+
6+
<script>
7+
console.log("algolia", '{{ site.algolia.application_id }}', '{{ site.algolia.index_name }}', '{{ site.algolia.search_only_api_key }}');
8+
// Instanciating InstantSearch.js with Algolia credentials
9+
const search = instantsearch({
10+
appId: '{{ site.algolia.application_id }}',
11+
indexName: '{{ site.algolia.index_name }}',
12+
apiKey: '{{ site.algolia.search_only_api_key }}'
13+
});
14+
console.log('search', search)
15+
// Adding searchbar and results widgets
16+
search.addWidget(
17+
instantsearch.widgets.searchBox({
18+
container: '#search-searchbar',
19+
placeholder: 'Search into posts...',
20+
poweredBy: true // This is required if you're on the free Community plan
21+
})
22+
);
23+
search.addWidget(
24+
instantsearch.widgets.hits({
25+
container: '#search-hits'
26+
})
27+
);
28+
29+
// Starting the search
30+
search.start();
31+
</script>

_includes/footer.html

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,7 @@
33
<div class="container">
44
<!--/* This template is released under the Creative Commons Attribution 3.0 License. Please keep the attribution link below when using for your own project. Thank you for your support. :) If you'd like to use the template without the attribution, you can check out other license options via our website: themes.3rdwavemedia.com */-->
55
<small class="copyright">
6-
{% if site.owner.copyright %}
7-
{{ site.owner.copyright.notice | markdownify | remove: '<p>' | remove: '</p>' }}
8-
&copy;
9-
{{ site.time | date: '%Y' }}
10-
{{ site.owner.copyright.author | markdownify | remove: '<p>' | remove: '</p>' }}
11-
<br>
12-
{% endif %}
13-
Theme <a href="http://themes.3rdwavemedia.com/website-templates/prettydocs-free-bootstrap-theme-developers-and-startups/" target="_blank" rel="nofollow">PrettyDocs</a>
14-
by <a href="{{}}" target="_blank" rel="nofollow">Xiaoying Riley</a> and <a href="https://guillermo.in/" target="_blank" rel="nofollow">Guillermo Calvo</a>
15-
- <a href="{{site.url}}/privacy.html" target="_blank" rel="nofollow">Privacy Policy</a>
6+
<a href="{{site.url}}/privacy.html" target="_blank" rel="nofollow">Privacy Policy</a>
167
</small>
178
</div>
189
</footer>

_includes/head.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<link rel="stylesheet" type="text/css" href="{{ '/assets/css/highlight.css' | prepend: site.baseurl }}">
2222
<link rel="stylesheet" type="text/css" href="{{ '/assets/css/styles.css' | prepend: site.baseurl }}"
2323
id="theme-style">
24+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.6.0/dist/instantsearch.min.css">
25+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.6.0/dist/instantsearch-theme-algolia.min.css">
2426

2527
{% include meta_properties.html %} {% include google_analytics.html %} {% seo title=false %}
2628
</head>

_includes/header.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@
88
<a class="nav-link" href="/docs/">Docs</a>
99
<a class="nav-link" href="/community/">Community</a>
1010
</nav>
11-
</header>
11+
<div style="flex:1"></div>
12+
<div id="search-searchbar"></div>
13+
</header>
14+
15+
<div class="post-list" id="search-hits"></div>

_layouts/doc.html

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,60 +5,39 @@
55
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
66
<!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->
77
<!--[if !IE]><!-->
8-
<html lang="en">
8+
<html lang="en" class="doc-body">
99
<!--<![endif]-->
1010

11-
<head>
12-
13-
14-
<title>{{ site.title }} &bull; {{ page.title }}</title>
15-
<!-- Meta -->
16-
<meta charset="utf-8">
17-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
18-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
19-
<meta name="description" content="{{ site.description }}">
20-
<meta name="author" content="{{ site.owner.name }}">
21-
<link rel="shortcut icon" href="{{ '/favicon.ico' | prepend: site.baseurl }}">
22-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800">
23-
<!-- Global CSS -->
24-
<link rel="stylesheet" type="text/css" href="{{ '/assets/plugins/bootstrap/css/bootstrap.min.css' | prepend: site.baseurl }}">
25-
<!-- Plugins CSS -->
26-
<link rel="stylesheet" type="text/css" href="{{ '/assets/plugins/font-awesome/css/font-awesome.css' | prepend: site.baseurl }}">
27-
<link rel="stylesheet" type="text/css" href="{{ '/assets/plugins/lightbox/dist/ekko-lightbox.min.css' | prepend: site.baseurl }}">
28-
<link rel="stylesheet" type="text/css" href="{{ '/assets/plugins/elegant_font/css/style.css' | prepend: site.baseurl }}">
29-
<link rel="stylesheet" type="text/css" href="{{ '/assets/plugins/prism/prism.css' | prepend: site.baseurl }}">
30-
<!-- Theme CSS -->
31-
<link rel="stylesheet" type="text/css" href="{{ '/assets/css/styles.css' | prepend: site.baseurl }}"
32-
id="theme-style">
33-
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
34-
<!--[if lt IE 9]>
35-
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
36-
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
37-
<![endif]-->
38-
{% include meta_properties.html %} {% include google_analytics.html %} {% seo %}
39-
</head>
11+
{% include head.html %}
4012

4113
<body class="body-{{ page.color }} doc-body">
4214

4315
<div class="page-wrapper">
4416

4517
<!-- HEADER -->
4618
<header id="header" class="header">
47-
<div class="container">
48-
49-
{% include branding.html home=false %}
50-
51-
<!-- BREADCRUMB -->
52-
<ol class="breadcrumb">
53-
<li>
54-
<a href="{{ '/' | prepend: site.baseurl }}">Home</a>
55-
</li>
56-
<li class="active">{{ page.title }}</li>
57-
</ol>
19+
<div class="container doc-header-container">
20+
21+
<div>
22+
{% include branding.html home=false %}
23+
24+
<!-- BREADCRUMB -->
25+
<ol class="breadcrumb">
26+
<li>
27+
<a href="{{ '/' | prepend: site.baseurl }}">Home</a>
28+
</li>
29+
<li class="active">{{ page.title }}</li>
30+
</ol>
31+
</div>
5832

33+
<div style="flex:1"></div>
34+
<div id="search-searchbar"></div>
5935
</div>
36+
6037
</header>
6138

39+
<div class="post-list" id="search-hits"></div>
40+
6241
<div class="doc-wrapper">
6342
{% include sidebar.html sections=page.sections %}
6443

@@ -127,6 +106,7 @@ <h2 class="section-title">{{ section.title }}</h2>
127106
<script type="text/javascript" src="{{ '/assets/plugins/lightbox/dist/ekko-lightbox.min.js' | prepend: site.baseurl }}"></script>
128107
<script type="text/javascript" src="{{ '/assets/plugins/jquery-match-height/jquery.matchHeight-min.js' | prepend: site.baseurl }}"></script>
129108
<script type="text/javascript" src="{{ '/assets/plugins/prism/prism.min.js' | prepend: site.baseurl }}"></script>
109+
<script type="text/javascript" src="{{ '/assets/js/instantsearch.min.js' | prepend: site.baseurl }}"></script>
130110
<script type="text/javascript" src="{{ '/assets/js/wurst.js' | prepend: site.baseurl }}"></script>
131111
<script type="text/javascript" src="{{ '/assets/js/main.js' | prepend: site.baseurl }}"></script>
132112

_layouts/home.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@
2424
<div class="tagline">Efficient. Innovative. Delicious.</div>
2525
<a class="btn btn-primary">Get Started</a>
2626
</div>
27-
<img src="/assets/images/wurst-scroll.png">
27+
<div class="img-container">
28+
<img src="/assets/images/wurst-scroll.png">
29+
<!-- Place this tag where you want the button to render. -->
30+
<a class="github-button" href="https://github.com/wurstscript/wurstscript" data-color-scheme="no-preference: dark; light: light; dark: dark;" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star wurstscript/wurstscript on GitHub">Star</a>
31+
</div>
2832
</div>
2933

3034
<div class="news">
@@ -72,8 +76,7 @@ <h2 class="title">{{ page.heading }}</h2>
7276
<img src="https://dl.circleci.com/status-badge/img/gh/wurstscript/WurstScript/tree/master.svg?style=svg" alt="Build Status" />
7377
</a>
7478
<a class="tag" href='https://coveralls.io/github/wurstscript/WurstScript?branch=master'><img src='https://coveralls.io/repos/github/wurstscript/WurstScript/badge.svg?branch=master' alt='Coverage Status' /></a>
75-
<!-- Place this tag where you want the button to render. -->
76-
<a class="github-button" href="https://github.com/wurstscript/wurstscript" data-color-scheme="no-preference: dark; light: light; dark: dark;" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star wurstscript/wurstscript on GitHub">Star</a>
79+
7780
</div>
7881
<div class="alert alert-info" style="display:inline-flex;">
7982
Please report any bugs, issues or requests on our&nbsp;<a href="https://github.com/{{ site.share.github.repo }}/wurstscript/issues/new"
@@ -83,12 +86,14 @@ <h2 class="title">{{ page.heading }}</h2>
8386

8487
</div>
8588

89+
8690
{% include footer.html %}
87-
91+
8892
<!-- Main Javascript -->
8993
<script type="text/javascript" src="{{ '/assets/plugins/jquery-1.12.3.min.js' | prepend: site.baseurl }}"></script>
9094
<script type="text/javascript" src="{{ '/assets/plugins/bootstrap/js/bootstrap.min.js' | prepend: site.baseurl }}"></script>
9195
<script type="text/javascript" src="{{ '/assets/plugins/jquery-match-height/jquery.matchHeight-min.js' | prepend: site.baseurl }}"></script>
96+
<script type="text/javascript" src="{{ '/assets/js/instantsearch.min.js' | prepend: site.baseurl }}"></script>
9297
<script type="text/javascript" src="{{ '/assets/js/main.js' | prepend: site.baseurl }}"></script>
9398
<script type="text/javascript" src="{{ '/assets/js/buttons.js' | prepend: site.baseurl }}"></script>
9499
<script type="application/ld+json">

_layouts/tutorialdoc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{% include meta_properties.html %} {% include google_analytics.html %} {% seo %}
3939
</head>
4040

41-
<body class="body-{{ page.color }}">
41+
<body class="body-{{ page.color }} doc-body">
4242

4343
<div class="page-wrapper">
4444

_sass/base.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,31 @@ nav {
423423
}
424424
}
425425

426+
.post-list {
427+
max-width: 600px;
428+
position: absolute;
429+
right: 32px;
430+
background-color: var(--divider);
431+
padding: 12px;
432+
border-radius: 6px;
433+
z-index: 10;
434+
max-height: 100%;
435+
overflow: scroll;
436+
}
437+
438+
.doc-header-container {
439+
display: flex;
440+
}
441+
442+
.ais-search-box {
443+
color: var(--text-color-secondary);
444+
}
445+
446+
.ais-search-box--powered-by {
447+
top: 42px !important;
448+
position: absolute !important;
449+
}
450+
426451
.breadcrumb {
427452
background: none;
428453
margin-bottom: 0;

_sass/landing.scss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@
9595
justify-content: space-between;
9696
margin-bottom: 48px;
9797

98+
.img-container {
99+
display: flex;
100+
flex-direction: column;
101+
align-items: center;
102+
}
103+
98104
img {
99105
margin-right: 32px;
100106
}
@@ -139,8 +145,8 @@
139145

140146
.card {
141147
padding: 0;
142-
width: 224px;
143-
height: 232px;
148+
width: 254px;
149+
height: 254px;
144150
border-radius: 6px;
145151

146152
&:hover {

0 commit comments

Comments
 (0)