Skip to content

Commit

Permalink
ok, google programmable search instead
Browse files Browse the repository at this point in the history
  • Loading branch information
noahp committed Oct 24, 2024
1 parent ea8ae5b commit bfb861c
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.7
3.2.2
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ruby:3.0-slim-bullseye
FROM ruby:3.2.2-slim-bullseye

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ gem 'jekyll-seo-tag', "~> 2.7.1"

group :jekyll_plugins do
gem 'jekyll-diagrams'
gem 'jekyll-lunr-js-search', :git => 'https://github.com/memfault/jekyll-lunr-js-search.git', :ref => '7d6a1509a0360db652626b4a1db38823d8ec24c0'
end

gem "jekyll-target-blank", "~> 2.0"
Expand Down
13 changes: 0 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
GIT
remote: https://github.com/memfault/jekyll-lunr-js-search.git
revision: 7d6a1509a0360db652626b4a1db38823d8ec24c0
ref: 7d6a1509a0360db652626b4a1db38823d8ec24c0
specs:
jekyll-lunr-js-search (3.3.0)
execjs (~> 2.7)
json (~> 2.0)
nokogiri (~> 1.7)

GEM
remote: https://rubygems.org/
specs:
Expand All @@ -20,7 +10,6 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
execjs (2.10.0)
ffi (1.17.0)
forwardable-extended (2.6.0)
http_parser.rb (0.8.0)
Expand Down Expand Up @@ -60,7 +49,6 @@ GEM
nokogiri (~> 1.10)
jekyll-watch (2.2.1)
listen (~> 3.0)
json (2.7.3)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
Expand Down Expand Up @@ -99,7 +87,6 @@ DEPENDENCIES
jekyll-diagrams
jekyll-feed (~> 0.15.1)
jekyll-get-json (~> 1.0)
jekyll-lunr-js-search!
jekyll-paginate (~> 1.1)
jekyll-seo-tag (~> 2.7.1)
jekyll-sitemap (~> 1.4)
Expand Down
17 changes: 0 additions & 17 deletions _includes/script.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,3 @@
<!-- Start of HubSpot Embed Code -->
<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/8551838.js"></script>
<!-- End of HubSpot Embed Code -->

{% if jekyll.environment == "production" %}
<!-- This is installed from the https://github.com/slashdotdash/jekyll-lunr-js-search Gem -->
<script src="/js/search.min.js" type="text/javascript" charset="utf-8"></script>
{% endif %}

<script type="text/javascript">
$(function() {
$('#search-input').lunrSearch({
indexUrl : '/js/index.json', // url for the .json file containing search index data
results : '#search-results', // selector for containing search results element
template : '#search-results-template', // selector for Mustache.js template
titleMsg : '', //<h1>Search results<h1>', // message attached in front of results (can be empty)
emptyMsg : '<p>Nothing found.</p>' // shown message if search returns no results
});
});
</script>
39 changes: 5 additions & 34 deletions _includes/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,9 @@
<label for="search-input">
<h3>Search</h3>
</label>
<input autocomplete="off" type="text" id="search-input" name="q" placeholder="Search posts...">
<script
async
src="https://cse.google.com/cse.js?cx=8478db8b25997435c"
></script>
<div class="gcse-search"></div>
</form>

<section id="search-results" style="display: none;"> </section>

{% raw %}
<script id="search-results-template" type="text/mustache">
{{#entries}}
<article class="search-result">
<h1><a href="{{url}}">{{title}}</a></h1>
<small>
{{#date}}<time datetime="{{pubdate}}" pubdate>{{displaydate}}</time>{{/date}}
{{#is_post}}
{{#tags}} #{{.}}{{/tags}}
{{/is_post}}
</small>
</article>
{{/entries}}
</script>
{% endraw %}

<style>
#search-results {
padding-top: 1.3em;
}

.search-result {
padding-bottom: 0.5em;
}

.search-result h1 {
font-size: 1rem;
line-height: 1.5;
}
</style>
2 changes: 1 addition & 1 deletion _sass/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ footer {
right: 15px;
width: 18px;
height: 18px;
background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='iso-8859-1'%3F%3E%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cpath d='M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z'/%3E%3Cpath d='M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z'/%3E%3C/svg%3E%0A");
// background-image: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='iso-8859-1'%3F%3E%3Csvg version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 512 512' style='enable-background:new 0 0 512 512;' xml:space='preserve'%3E%3Cpath d='M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z'/%3E%3Cpath d='M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z'/%3E%3C/svg%3E%0A");
background-repeat: no-repeat;
background-size: contain;
}
Expand Down
16 changes: 0 additions & 16 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@ function darkModeSetup() {
})
}

// Ensures backward compatibility with IE old versions
function searchScroll() {
const scrollBox = document.getElementById('search-results');
const SCROLLED_CLASSNAME = 'scrolled-down';

if (document.addEventListener && scrollBox) {
scrollBox.addEventListener('scroll', () => {
if (scrollBox.scrollTop > 50) {
scrollBox.classList.add(SCROLLED_CLASSNAME);
} else {
scrollBox.classList.remove(SCROLLED_CLASSNAME);
}
});
}
}

// Function to set a cookie
function setCookie(name, value, days) {
const expires = new Date();
Expand Down

0 comments on commit bfb861c

Please sign in to comment.