Skip to content

Commit

Permalink
Merge pull request #32 from noriyotcp/refactor-20241006
Browse files Browse the repository at this point in the history
refactor 20241006
  • Loading branch information
noriyotcp authored Oct 6, 2024
2 parents e94ac6a + c98d935 commit b8271b7
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
7 changes: 0 additions & 7 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,6 @@ incremental: false #set incremental to true to speed things up. if changes arent
paginate: 5
paginate_path: /page:num/

exclude:
- Gemfile
- Gemfile.lock
- vendor
- projects

atom_feed:
hide: true

Expand Down Expand Up @@ -95,4 +89,3 @@ footer:
- label: "GitHub"
icon: "fab fa-fw fa-github"
url: "https://github.com/noriyotcp"

17 changes: 14 additions & 3 deletions _includes/hotkeys_popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h4 class="nav__title"><i class="fa-solid fa-sitemap"></i> Side-wide</h4>
</li>
</ul>
<header>
<h4 class="nav__title"><i class="fas fa-file-alt"></i> Posts</h4>
<h4 class="nav__title"><i class="fas fa-file-alt"></i> Posts page</h4>
</header>
<ul class="toc__menu">
<li>
Expand All @@ -37,14 +37,25 @@ <h4 class="nav__title"><i class="fa-solid fa-rectangle-xmark"></i> This popover<
<pre class="unset">Close - <code class="language-plaintext highlighter-rouge">esc</code></pre>
</li>
</ul>
<header>
<h4 class="nav__title"><i class="fa-solid fa-arrow-up"></i> Back To...</h4>
</header>
<ul class="toc__menu">
<li>
<pre class="unset">Back Top - <code class="language-plaintext highlighter-rouge">b t</code></pre>
</li>
<li>
<pre class="unset">Back to YYYY-mm - <code class="language-plaintext highlighter-rouge">b YYYYmm</code></pre>
</li>
</ul>
</nav>
</div>

<!-- Right Column -->
<div class="right-column">
<nav class="toc">
<header>
<h4 class="nav__title"><i class="fa-solid fa-keyboard"></i> Key-sequence hotkey</h4>
<h4 class="nav__title"><i class="fa-solid fa-arrow-right"></i> Go to Posts</h4>
</header>
<ul class="toc__menu">
<li class="archive__item-excerpt">
Expand All @@ -61,7 +72,7 @@ <h4 class="nav__title"><i class="fa-solid fa-keyboard"></i> Key-sequence hotkey<
</li>
</ul>
<header>
<h4 class="nav__title"><i class="fa-solid fa-keyboard"></i> Pagination</h4>
<h4 class="nav__title"><i class="fa-solid fa-arrows-left-right"></i> Pagination</h4>
</header>
<ul class="toc__menu">
<li class="archive__item-excerpt">
Expand Down
3 changes: 2 additions & 1 deletion _posts/2024-06/2024-06-11-2024-06-11.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
date: "2024-06-11 02:41:31 +0900"
last_modified_at: "2024-10-06 00:56:06 +0900"
last_modified_at: "2024-10-06 02:55:45 +0900"
title: "2024-06-11"
tags:
- Ruby
Expand All @@ -18,6 +18,7 @@ https://x.com/coolprobn/status/1799054952859660605
```

## https://x.com/andycroll/status/1797535812621652147
https://x.com/andycroll/status/1797535812621652147

```rb
> def only_evens(numbers) = numbers.select(&:even?).sort
Expand Down
1 change: 0 additions & 1 deletion assets/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ div#hotkeys-popover {
background-color: #252a34;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
position: relative;
color: #eaeaea;
padding: 0;

Expand Down
2 changes: 1 addition & 1 deletion assets/js/focusNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const focusListItem = (listItemLinks) => {
return false;
}

listItemLinks[focusedItemIndex].focus();
listItemLinks[focusedItemIndex]?.focus();
console.log(focusedItemIndex);

return false;
Expand Down
4 changes: 3 additions & 1 deletion assets/js/hotkeys.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { setupFocusHotkeys } from "./setupFocusHotkeys.js";
import { setupSearchHotkeys } from "./setupSearchHotkeys.js";
import { setupHotkeysPopoverHotkeys } from "./setupHotkeysPopoverHotKeys.js";
import { setupBackToHotkeys } from "./setupBackToHotkeys.js";

document.addEventListener("DOMContentLoaded", function () {
const userAgent = navigator.userAgent;
Expand All @@ -19,8 +20,9 @@ document.addEventListener("DOMContentLoaded", function () {
}
// Register focus hotkeys
setupFocusHotkeys();

// Setup hotkeys popover hotkeys
setupHotkeysPopoverHotkeys();
// Setup back to hotkeys
setupBackToHotkeys();
}
});
27 changes: 27 additions & 0 deletions assets/js/setupBackToHotkeys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export const setupBackToHotkeys = () => {
// Get all <a> elements with the class .back-to-top
const backToTopLinks = document.querySelectorAll("a.back-to-top");

backToTopLinks.forEach((link) => {
const href = link.getAttribute("href");

// Regular expression to get everything after #
const match = href.match(/#(.+)/);

if (match && match[1]) {
const content = match[1];

let hotkeyValue;
if (/^\d/.test(content)) {
// If it starts with a number, extract only the numbers and process them
const numbers = content.replace(/-/g, "");
hotkeyValue = "b " + numbers.split("").join(" ");
} else if (content === "page-title") {
// If it is page-title, assign `b t` as the hotkey
hotkeyValue = "b t";
}

link.setAttribute("data-hotkey", hotkeyValue);
}
});
}

0 comments on commit b8271b7

Please sign in to comment.