Skip to content

Commit 6c6a018

Browse files
authored
Refactor/commands page sidebar breadcrumbs (#299)
Refactor/commands page sidebar breadcrumbs - Implement sidebar search functionality for commands - Add no results message for sidebar search <img width="1728" alt="Screenshot 2025-07-07 at 5 53 00 PM" src="https://github.com/user-attachments/assets/255a62da-dd77-40d1-b6c7-a6d30bb9932e" /> <img width="1728" alt="Screenshot 2025-07-07 at 5 53 11 PM" src="https://github.com/user-attachments/assets/e9969b29-f981-47b2-a706-6f569dbbb206" /> <img width="1728" alt="Screenshot 2025-07-07 at 5 53 21 PM" src="https://github.com/user-attachments/assets/d19d5f5c-fe89-46e1-b468-fe8cd2733d96" /> (EDIT: Is this what you're doing with #293 ?) --------- Signed-off-by: Daniel Phillips <[email protected]>
1 parent ab5cb41 commit 6c6a018

File tree

3 files changed

+149
-6
lines changed

3 files changed

+149
-6
lines changed

sass/_valkey.scss

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,30 @@ p {
643643
}
644644
}
645645

646+
.sb-search-container {
647+
display: flex;
648+
align-items: center;
649+
margin: 0 -2rem 2rem;
650+
padding: 0 2rem 2rem;
651+
border-bottom: 1px solid rgb(104, 147, 238);
652+
653+
input {
654+
flex: 1;
655+
width: 100%;
656+
min-width: 0px;
657+
outline: none;
658+
padding: 1.15rem;
659+
border: 1px solid #ccc;
660+
background: #fff;
661+
border-radius: 50px;
662+
font-size: 16px;
663+
664+
&:focus {
665+
border-color: #6983ff;;
666+
}
667+
}
668+
}
669+
646670
.no-results-message {
647671
color: #30176e;
648672
padding: 5rem 2rem 7rem;
@@ -1924,3 +1948,31 @@ pre table {
19241948
height: 18px;
19251949
margin-right: 0.3rem;
19261950
}
1951+
1952+
.breadcrumbs {
1953+
border-radius: 20px;
1954+
background: #fff;
1955+
margin-bottom: 2rem;
1956+
1957+
.breadcrumb-list {
1958+
display: flex;
1959+
align-self: center;
1960+
padding: 1rem 2rem;
1961+
list-style: none;
1962+
margin: 0;
1963+
gap: 5px;
1964+
1965+
.breadcrumb-item {
1966+
align-items: center;
1967+
display: flex;
1968+
1969+
img {
1970+
margin-right: 5px;
1971+
}
1972+
1973+
.breadcrumb-link {
1974+
color: #2054B2;
1975+
}
1976+
}
1977+
}
1978+
}

templates/command-page.html

Lines changed: 96 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "right-aside.html" %}
1+
{% extends "left-aside.html" %}
22

33
{% import "macros/command.html" as commands %}
44

@@ -34,9 +34,28 @@
3434
{%- endblock -%}
3535

3636
{% block subhead_content%}
37-
{% if command_title%}<h1 class="page-title">{{ command_title }} {% if deprecated %}<small> {{ deprecated }}</small>{% endif %}</h1>{% endif %}
37+
{% if command_title%}
38+
<div class="styled-title">
39+
<h1 class="page-title">{{ command_title }} {% if deprecated %}<small> {{ deprecated }}</small>{% endif %}</h1>
40+
</div>
41+
{% endif %}
3842
{% endblock subhead_content%}
3943

44+
{% block breadcrumbs %}
45+
{# Breadcrumbs section #}
46+
<nav class="breadcrumbs">
47+
<ul class="breadcrumb-list">
48+
<li class="breadcrumb-item">
49+
<a href="/commands/" class="breadcrumb-link">Commands</a>
50+
</li>
51+
<li class="breadcrumb-item breadcrumb-current" aria-current="page">
52+
<img src="/img/caret-right.svg" alt="Caret Right Icon" width="8" height="10"/>
53+
{% if command_title %}{{ command_title }}{% else %}{{ page.slug | upper }}{% endif %}
54+
</li>
55+
</ul>
56+
</nav>
57+
{% endblock breadcrumbs %}
58+
4059
{% block main_content %}
4160
{% if command_data_obj %}
4261
<dl>
@@ -205,8 +224,80 @@ <h3>History</h3>
205224
{% endblock main_content %}
206225

207226
{% block related_content %}
208-
<div class="edit_box">
209-
See an error?
210-
<a href="https://github.com/valkey-io/valkey-doc/edit/main/commands/{{ page.slug }}.md">Update this Page on GitHub!</a>
227+
{# Set up variables for sidebar, similar to commands.html #}
228+
{% set_global group_descriptions = load_data(path= "../_data/groups.json", required= false) %}
229+
{% set commands_entries = [] %}
230+
{% set commands_section = get_section(path="commands/_index.md") %}
231+
{% for page in commands_section.pages %}
232+
{% for json_path in [
233+
commands::command_json_path(slug=page.slug),
234+
commands::command_bloom_json_path(slug=page.slug),
235+
commands::command_json_json_path(slug=page.slug),
236+
commands::command_search_json_path(slug=page.slug)
237+
] %}
238+
{% set command_data = load_data(path= json_path, required= false) %}
239+
{% if command_data %}
240+
{% set command_obj_name = commands::command_obj_name(command_data= command_data) %}
241+
{% set command_data_obj = command_data[command_obj_name] %}
242+
{% set command_display = command_obj_name %}
243+
{% if command_data_obj.container %}
244+
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
245+
{% endif %}
246+
{% set command_entry = [
247+
command_display,
248+
page.permalink | safe,
249+
command_data_obj.summary,
250+
command_data_obj.group
251+
] %}
252+
{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}
253+
{% endif %}
254+
{% endfor %}
255+
{% endfor %}
256+
{% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %}
257+
258+
<div class="sb-search-container">
259+
<input type="text" id="sidebar-search-box" placeholder="Search within documents" onkeyup="searchSidebarCommands()" />
211260
</div>
261+
262+
<!-- No results message for sidebar search -->
263+
<div id="sidebar-no-results-message" class="no-results-message" style="display: none;">
264+
<span>&lt;/&gt;</span>
265+
<h4>No commands found</h4>
266+
<p>Check your spelling or try different keywords</p>
267+
</div>
268+
269+
<h2 id="command-list-title">Alphabetical Command List</h2>
270+
<ul id="command-list">
271+
{% set alpha_entries = commands_entries | sort(attribute="0") %}
272+
{% for entry in alpha_entries %}
273+
<li class="command-list-item"><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code></li>
274+
{% endfor %}
275+
</ul>
276+
277+
<script>
278+
function searchSidebarCommands() {
279+
var input = document.getElementById("sidebar-search-box").value.toLowerCase();
280+
var commandList = document.getElementById("command-list");
281+
var commandListTitle = document.getElementById("command-list-title");
282+
var items = commandList.querySelectorAll(".command-list-item");
283+
var noResultsMessage = document.getElementById("sidebar-no-results-message");
284+
var totalVisible = 0;
285+
286+
items.forEach(function (item) {
287+
var text = item.querySelector("a").innerText.toLowerCase();
288+
if (text.includes(input)) {
289+
item.style.display = "";
290+
totalVisible++;
291+
} else {
292+
item.style.display = "none";
293+
}
294+
});
295+
296+
// Show/hide no results message and title based on search results
297+
var hasResults = totalVisible > 0;
298+
noResultsMessage.style.display = hasResults ? "none" : "block";
299+
commandListTitle.style.display = hasResults ? "" : "none";
300+
commandList.style.display = hasResults ? "" : "none";
301+
}
302+
</script>
212303
{% endblock related_content %}

templates/left-aside.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
</aside>
1515
</div>
1616
</div>
17-
{% endblock content %}
17+
{% endblock content %}

0 commit comments

Comments
 (0)