Skip to content

Commit

Permalink
Fix js
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesrussell committed Jul 13, 2024
1 parent da98143 commit 8ac9b24
Show file tree
Hide file tree
Showing 6 changed files with 555 additions and 35 deletions.
8 changes: 5 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ GEM
commonmarker (0.23.10)
concurrent-ruby (1.3.3)
connection_pool (2.4.1)
csv (3.2.8)
dnsruby (1.72.1)
csv (3.3.0)
dnsruby (1.72.2)
simpleidn (~> 0.2.1)
drb (2.2.1)
em-websocket (0.5.3)
Expand All @@ -34,8 +34,9 @@ GEM
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.9.1)
faraday (2.9.2)
faraday (2.10.0)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-net_http (3.1.0)
net-http
faraday-retry (2.2.1)
Expand Down Expand Up @@ -226,6 +227,7 @@ GEM
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.0)
mercenary (0.3.6)
mini_portile2 (2.8.7)
minima (2.5.1)
Expand Down
44 changes: 12 additions & 32 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,56 +58,36 @@ remote_theme: JakeSteam/[email protected]
# Basic site setup
description: In-depth ad-free articles about software development, Android, and the internet
accent_colour: "#2a7ae2"
url: https://blog.jakelee.co.uk
url: https://jonesrussell.github.io

# Optional native feature customisation (delete to turn off)
table_of_contents_header: "Jump to:"
post_end_promo: <i><b>Enjoyed this article? You'll like "<a href="https://jakeweeklee.substack.com">Jake Week Lee</a>", a newsletter of articles & online things!</b></i>
google_analytics: G-99X0QYL39T

network:
- { name: Programming, url: "https://blog.jakelee.co.uk", colour: "#2a7ae2" }
- {
name: Internet History,
url: "https://history.jakelee.co.uk",
colour: "#075e78",
}
- { name: Theme, url: "https://minima.jakelee.co.uk", colour: "#951A00" }
- {
name: Fragments,
url: "https://fragments.jakelee.co.uk",
colour: "#ad33a9",
}
- { name: Everything Else, url: "https://jakelee.co.uk", colour: "#acacac" }
google_analytics: G-9999999

# Social / dark mode settings
minima:
skin: auto
social_links:
- { platform: github, user_url: "https://github.com/JakeSteam" }
- { platform: linkedin, user_url: "https://www.linkedin.com/in/Jake-Lee" }
- { platform: github, user_url: "https://github.com/jonesrussell" }
- { platform: linkedin, user_url: "https://www.linkedin.com/in/jonesrussell42" }
- {
platform: stackoverflow,
user_url: "https://stackoverflow.com/users/608312/Jake-Lee",
user_url: "https://stackoverflow.com/users/437654/russell",
}
- { platform: x, user_url: "https://www.twitter.com/JakeLeeUK" }
- { platform: x, user_url: "https://www.x.com/jonesrussell" }
- {
platform: email,
user_url: "mailto:[email protected]",
user_title: "[email protected]",
user_url: "mailto:[email protected]",
user_title: "[email protected]",
}
- {
platform: code,
user_url: "https://github.com/JakeSteam/blog-programming",
user_url: "https://github.com/jonesrussell/blog",
user_title: "JakeSteam/blog-programming",
}
- { platform: rss, user_url: "/feed.xml", user_title: "RSS Feed" }
- {
platform: substack,
user_url: "https://jakeweeklee.substack.com/",
user_title: "Jake Week Lee",
}
# - { platform: devto, user_url: "https://dev.to/jekyll" }
- { platform: rss, user_url: "/feed.xml", user_title: "RSS Feed" }
- { platform: devto, user_url: "https://dev.to/jonesrussell" }
# - { platform: dribbble, user_url: "https://dribbble.com/jekyll" }
# - { platform: facebook, user_url: "https://www.facebook.com/jekyll" }
# - { platform: flickr, user_url: "https://www.flickr.com/photos/jekyll" }
Expand All @@ -117,7 +97,7 @@ minima:
# - { platform: microdotblog, user_url: "https://micro.blog/jekyll" }
# - { platform: pinterest, user_url: "https://www.pinterest.com/jekyll" }
# - { platform: telegram, user_url: "https://t.me/jekyll" }
# - { platform: youtube, user_url: "https://www.youtube.com/jekyll" }
- { platform: youtube, user_url: "https://www.youtube.com/@fullstackdev42" }

###
# Below here probably doesn't need changing #
Expand Down
77 changes: 77 additions & 0 deletions _includes/custom/search.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<form id="searchform">
<p>
<input
type="search"
id="search-input"
class="form-control"
name="q"
value=""
autofocus
/>
</p>
</form>
<ul id="searchresults" class="post-list"></ul>

<script src="{{site.baseurl}}/assets/js/search.js" type="text/javascript"></script>

<script>
var sjs = SimpleJekyllSearch({
searchInput: document.getElementById("searchform"),
resultsContainer: document.getElementById("searchresults"),
json: "{{site.baseurl}}/assets/js/posts.json",
templateMiddleware: function (prop, value, template) {
if (prop === "title" || prop === "excerpt") {
value = value.replace(/&amp;/g, "&");
}
if (prop === "url") {
return value;
}
return value.replace(
new RegExp(document.getElementById("search-input").value, "gi"),
'<span class="highlight">$&</span>'
);
},
sortMiddleware: function (a, b) {
aPrio = matchPriority(a.matchedField);
bPrio = matchPriority(b.matchedField);
return bPrio - aPrio;
},
searchResultTemplate:
"<li class='card'>" +
"<div class='content'>" +
"<a class='post-link' href='{url}'>{title}</a>" +
"<span class='post-meta'>{date} • {tags}</span>" +
"<p>{excerpt}</p>" +
"</div>" +
"</li>",
});

function matchPriority(fieldMatched) {
switch (fieldMatched) {
case "tags":
return 5;
case "title":
return 4;
case "excerpt":
return 3;
default:
return 0;
}
}

window.addEventListener(
"load",
function () {
var searchParam = new URLSearchParams(window.location.search).get("q");
if (searchParam != null) {
document.getElementById("search-input").value = searchParam;
setTimeout(() => {
sjs.search(searchParam);
}, 100);
}
document.getElementById("search-input").placeholder =
"Type your search here...";
},
false
);
</script>
8 changes: 8 additions & 0 deletions assets/js/new_window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
window.onload = function() {
var links = document.links;
for(var i = 0; i < links.length; i++) {
if (links[i].hostname != window.location.hostname || links[i].href.includes("/images/")) {
links[i].target = '_blank';
}
}
};
15 changes: 15 additions & 0 deletions assets/js/posts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
layout: none
---
[
{% for post in site.posts %}
{
"tags" : "{{ post.tags | join: ', ' }}",
"title" : {{ post.title | jsonify | strip_html }},
"excerpt" : {{ post.excerpt | jsonify | strip_html }},
"url" : "{{ post.url }}",
"date" : "{{ post.date | date: "%b %-d, %Y" }}",
"content" : {{ post.content | jsonify | strip_html }}
} {% unless forloop.last %},{% endunless %}
{% endfor %}
]
Loading

0 comments on commit 8ac9b24

Please sign in to comment.