Skip to content

Commit c5fea0f

Browse files
authored
Add Google custom Search (#16)
1 parent 2075feb commit c5fea0f

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/_layouts/default.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
<body>
2424
<nav class="navbar navbar-dark fixed-top bg-dark flex-md-nowrap p-0 shadow">
2525
<a class="navbar-brand col-sm-3 col-md-2 mr-0" href="/">{{ site.title }}</a>
26-
<!-- <input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search"> -->
26+
<form class="search-form" action="/search" method="get">
27+
<input class="form-control form-control-dark w-100" type="text" placeholder="Search" aria-label="Search" name="q">
28+
</form>
29+
<ul class="navbar-nav px-3">
30+
<li class="nav-item text-nowrap">
31+
<a class="nav-link" href="https://github.com/railsdoc/railsdoc.github.io">GitHub</a>
32+
</li>
33+
</ul>
2734
</nav>
2835

2936
<div class="container-fluid">

src/_sass/railsdoc.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ $red: #cc0000;
44
$dark-red: #990000;
55

66
// global
7-
87
a {
98
color: $red;
109

@@ -17,6 +16,11 @@ code {
1716
color: #333;
1817
}
1918

19+
// Header
20+
.search-form {
21+
width: 100%;
22+
}
23+
2024
// Sidebar
2125
.sidebar {
2226
position: fixed;

src/search.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: RDOC_MAIN.rdoc
3+
layout: default
4+
---
5+
6+
<script>
7+
(function () {
8+
var cx = '011796726412992573594:6ifdgquoma4';
9+
var gcse = document.createElement('script');
10+
gcse.type = 'text/javascript';
11+
gcse.async = true;
12+
gcse.src = 'https://cse.google.com/cse.js?cx=' + cx;
13+
var s = document.getElementsByTagName('script')[0];
14+
s.parentNode.insertBefore(gcse, s);
15+
})();
16+
</script>
17+
<gcse:searchresults-only linktarget="_self"></gcse:searchresults-only>

0 commit comments

Comments
 (0)