From cef6cb98fffd234808affe0b213ecd650c8167ea Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Mon, 16 Nov 2026 18:20:37 -0800 Subject: [PATCH] Link the previous and next topic at the end of each docs topic Signed-off-by: Madelyn Olson --- sass/_valkey.scss | 54 +++++++++++++++++++++++++++++++++++++++ templates/docs-page.html | 1 + templates/macros/nav.html | 43 +++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+) diff --git a/sass/_valkey.scss b/sass/_valkey.scss index d0f2248c..505fc362 100644 --- a/sass/_valkey.scss +++ b/sass/_valkey.scss @@ -2410,6 +2410,60 @@ blockquote { margin: 1.5rem 0 2.5rem; } +// Previous and next topic links at the end of a topic (nav_pager in +// templates/macros/nav.html). The links look like the docs menu's. "Next" +// stays on the right when there's no "Previous". +.docs-pager { + display: flex; + justify-content: space-between; + gap: 1rem; + margin-top: 4rem; + padding-top: 1.5rem; + border-top: 1px solid #d5d9ec; + + a { + display: flex; + flex-direction: column; + max-width: 50%; + padding: 0.6rem 1rem; + border-radius: 4px; + line-height: 1.35; + + &:hover { + background-color: #d1d9ff; + } + + &:focus-visible { + outline: 2px solid #2054B2; + outline-offset: 1px; + } + } + + .docs-pager-next { + margin-left: auto; + align-items: flex-end; + text-align: right; + } + + .docs-pager-label { + font-size: 1.3rem; + color: #444; + } + + .docs-pager-title { + font-weight: 600; + } + + @media (max-width: 768px) { + flex-direction: column; + gap: 0.5rem; + + a { + max-width: none; + } + } +} + // Homepage blog cards: text-only cards stacked vertically, matching the release // cards in the other column. .homepage-blog-section { diff --git a/templates/docs-page.html b/templates/docs-page.html index 748c0c16..b6ce9d68 100644 --- a/templates/docs-page.html +++ b/templates/docs-page.html @@ -60,6 +60,7 @@

{{ frontmatter_title }}

{% endif %} {%- set content_with_fixed_links %}{{< fix_links_docs content={page_contents} />}}{% endset -%} {{ content_with_fixed_links | markdown | safe }} +{{< nav_pager nav={nav_data} slug={page.slug} extra={config.extra} />}} {% endblock main_content %} {% block related_content %} diff --git a/templates/macros/nav.html b/templates/macros/nav.html index ac397aad..2b84d367 100644 --- a/templates/macros/nav.html +++ b/templates/macros/nav.html @@ -227,6 +227,49 @@ {{ found | json_encode | safe }} {% endcomponent nav_topic_location %} +{#- + Links to the previous and next topic in menu order: each section's landing + page, then its topics, crossing into the next section at the end of one. + The command reference isn't a topic, so it's skipped. A topic that isn't in + the menu gets no links. Titles are the topics' own, not the shorter menu + titles, which only make sense under their section. +-#} +{% component nav_pager(nav, slug, extra) %} +{%- set order = [] -%} +{%- for section in nav -%} + {%- if section.landing -%}{%- set_global order = [...order, section.landing] -%}{%- endif -%} + {%- set_global order = [...order, ...[t.topic for t in section.topics]] -%} +{%- endfor -%} +{%- set found = false -%} +{%- set last = "" -%} +{%- set prev = "" -%} +{%- set next = "" -%} +{%- for topic in order -%} + {%- if found and not next -%}{%- set_global next = topic -%}{%- endif -%} + {%- if topic == slug and not found -%} + {%- set_global found = true -%} + {%- set_global prev = last -%} + {%- endif -%} + {%- set_global last = topic -%} +{%- endfor -%} +{%- if prev or next %} + +{%- endif %} +{% endcomponent nav_pager %} + {#- A topic's title: `title` if set, otherwise the title in the topic's front matter. -#} {% component nav_topic_title(slug, extra, title="") %} {%- if title -%}{{ title }}{%- else -%}