Skip to content

Commit d5d9746

Browse files
committed
feat: add topics sidebar and breadcrumbs navigation
- Add topics list page and sidebar navigation - Implement search functionality for topics in sidebar - Add breadcrumbs navigation Signed-off-by: Daniel Phillips <phiro56@gmail.com>
1 parent cf44182 commit d5d9746

File tree

6 files changed

+115
-4
lines changed

6 files changed

+115
-4
lines changed

content/topics-list/_index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
+++
2+
title = "Topics List"
3+
template = "topics-list.html"
4+
+++

sass/_valkey.scss

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ p {
575575
overflow-x: auto;
576576
background-size: cover;
577577
background-position: center bottom;
578-
position: stiky;
578+
position: sticky;
579579
top: 0px;
580580

581581
@media (max-width: 1100px) {
@@ -1986,13 +1986,16 @@ html.banner-hidden .banner {
19861986
.breadcrumb-item {
19871987
align-items: center;
19881988
display: flex;
1989-
1989+
font-size: 14px;
1990+
19901991
img {
19911992
margin-right: 5px;
19921993
}
19931994

19941995
.breadcrumb-link {
19951996
color: #2054B2;
1997+
text-decoration: underline;
1998+
font-weight: 600;
19961999
}
19972000
}
19982001
}

static/img/caret-right.svg

Lines changed: 3 additions & 0 deletions
Loading

templates/docs-page.html

Lines changed: 68 additions & 2 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/docs.html" as docs %}
44

@@ -21,10 +21,26 @@
2121

2222
{% block subhead_content %}
2323
{% if has_frontmatter and frontmatter_title %}
24-
<h1 class="page-title">Documentation: {{ frontmatter_title }}</h1>
24+
<div class="styled-title">
25+
<h1 class="page-title">Documentation: {{ frontmatter_title }}</h1>
26+
</div>
2527
{% endif %}
2628
{% endblock subhead_content %}
2729

30+
{% block breadcrumbs %}
31+
{# Breadcrumbs section #}
32+
<nav class="breadcrumbs">
33+
<ul class="breadcrumb-list">
34+
<li class="breadcrumb-item">
35+
<a href="/topics/" class="breadcrumb-link">Topics</a>
36+
</li>
37+
<li class="breadcrumb-item breadcrumb-current" aria-current="page">
38+
<img src="/img/caret-right.svg" alt="Caret Right Icon" width="8" height="10"/>
39+
{% if frontmatter_title %}{{ frontmatter_title }}{% else %}{{ page.slug | upper }}{% endif %}
40+
</li>
41+
</ul>
42+
</nav>
43+
{% endblock breadcrumbs %}
2844

2945
{% block main_content %}
3046
{% if config.extra.review_list is containing(page.path) %}
@@ -41,6 +57,56 @@ <h1 class="page-title">Documentation: {{ frontmatter_title }}</h1>
4157
{% endblock main_content %}
4258

4359
{% block related_content %}
60+
<div class="sb-search-container">
61+
<input type="text" id="sidebar-search-box" placeholder="Search within topics" onkeyup="searchSidebarTopics()" />
62+
</div>
63+
64+
<!-- No results message for sidebar search -->
65+
<div id="sidebar-no-results-message" class="no-results-message" style="display: none;">
66+
<span>&lt;/&gt;</span>
67+
<h4>No topics found</h4>
68+
<p>Check your spelling or try different keywords</p>
69+
</div>
70+
71+
<h2 id="topic-list-title">Alphabetical Index</h2>
72+
<ul id="topic-list"></ul>
73+
74+
<script>
75+
document.addEventListener("DOMContentLoaded", function() {
76+
var
77+
topicListEl = document.getElementById('topic-list'),
78+
f = fetch("/topics-list/");
79+
80+
f.then((r) => r.text()).then((v) => { topicListEl.innerHTML = v; })
81+
f.catch((error) => { topicListEl.innerHTML = "Could not load topic list."; });
82+
});
83+
84+
function searchSidebarTopics() {
85+
var input = document.getElementById("sidebar-search-box").value.toLowerCase();
86+
var topicList = document.getElementById("topic-list");
87+
var topicListTitle = document.getElementById("topic-list-title");
88+
var items = topicList.querySelectorAll(".topic-list-item");
89+
var noResultsMessage = document.getElementById("sidebar-no-results-message");
90+
var totalVisible = 0;
91+
92+
items.forEach(function (item) {
93+
var text = item.querySelector("a").innerText.toLowerCase();
94+
if (text.includes(input)) {
95+
item.style.display = "";
96+
totalVisible++;
97+
} else {
98+
item.style.display = "none";
99+
}
100+
});
101+
102+
// Show/hide no results message and title based on search results
103+
var hasResults = totalVisible > 0;
104+
noResultsMessage.style.display = hasResults ? "none" : "block";
105+
topicListTitle.style.display = hasResults ? "" : "none";
106+
topicList.style.display = hasResults ? "" : "none";
107+
}
108+
</script>
109+
44110
<div class="edit_box">
45111
See an error?
46112
<a href="https://github.com/valkey-io/valkey-doc/edit/main/topics/{{ page.slug }}.md">Update this Page on GitHub!</a>

templates/left-aside.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<div class="left-aside-bg">
66
<div class="left-aside">
77
<main>
8+
{% block breadcrumbs %}{% endblock breadcrumbs %}
89
<div class="main-inner">
910
{% block main_content %}{% endblock main_content %}
1011
</div>

templates/topics-list.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{% import "macros/docs.html" as docs %}
2+
3+
{% set topics_entries = [] %}
4+
{% set topics_section = get_section(path="topics/_index.md") %}
5+
6+
{% for topic_page in topics_section.pages %}
7+
{% set docs_file_contents = docs::load(slug= topic_page.slug) %}
8+
{% set frontmatter = docs::extract_frontmatter(content= docs_file_contents) %}
9+
{% set frontmatter_length = frontmatter | length() %}
10+
11+
{% if frontmatter_length > 0 %}
12+
{% set frontmatter_data = load_data(literal= frontmatter, format="yaml") %}
13+
{% if frontmatter_data.title %}
14+
{% set topic_entry = [
15+
frontmatter_data.title,
16+
topic_page.permalink | safe,
17+
frontmatter_data.description | default(value="")
18+
] %}
19+
{% set_global topics_entries = topics_entries | concat(with= [ topic_entry ]) %}
20+
{% endif %}
21+
{% endif %}
22+
{% endfor %}
23+
24+
{% set alpha_entries = topics_entries | sort(attribute="0") %}
25+
{% for entry in alpha_entries %}
26+
<li class="topic-list-item">
27+
<a href="{{ entry[1] }}">
28+
{{ entry[0] }}
29+
{% if entry[2] %}
30+
<span class="topic-description">{{ entry[2] | safe }}</span>
31+
{% endif %}
32+
</a>
33+
</li>
34+
{% endfor %}

0 commit comments

Comments
 (0)