Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions content/authors/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ title = "Authors"
template = "authors.html"
page_template = "author-page.html"
sort_by = "title"

[extra]
breadcrumb = "Blog › Authors"
+++
3 changes: 3 additions & 0 deletions content/blog/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ description = "Stay up to date with the latest news, tutorials, and updates from
sort_by = "date"
template = "blog.html"
page_template = "blog-page.html"

[extra]
breadcrumb = "Blog"
+++
1 change: 1 addition & 0 deletions content/clients/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ template = "libraries.html"
render = true

[extra]
breadcrumb = "Documentation › Clients"
kind = "clients"
+++
3 changes: 3 additions & 0 deletions content/commands/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ page_template = "command-page.html"
aliases= [
"/docs/topics/commands/"
]

[extra]
breadcrumb = "Commands"
+++
1 change: 1 addition & 0 deletions content/community/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description = "Join the Valkey community: contribute code, docs, and content, sp
template = "community-home.html"
page_template = "community.html"
[extra]
breadcrumb = "Community"
hero = { title = "Built by the community. For the community.", subtitle = "Every contributor started somewhere: a bug report, a talk, a line of code. This community is built one key at a time. Yours starts here.", image = "/img/community/hero-community.jpg" }

connect = { title = "Connect with us", description = "Ask questions, share ideas, and meet the Valkey community.", links = [
Expand Down
1 change: 1 addition & 0 deletions content/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title = "Documentation"
template = "block-menu.html"
page_template = "docs-page.html"
[extra]
breadcrumb = "Documentation"
body_class= "blocks-page"
+++

Expand Down
3 changes: 3 additions & 0 deletions content/download/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
+++
template = "download.html"
title = "Download"

[extra]
breadcrumb = "Download"
+++

For installation instructions, supported package managers, and how to configure Valkey, see the
Expand Down
3 changes: 3 additions & 0 deletions content/download/releases/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ title = "Releases"
page_template= "release-page.html"
template= "release-section.html"
sort_by= "title"

[extra]
breadcrumb = "Download"
+++
3 changes: 3 additions & 0 deletions content/download/versions/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
render = false
page_template = "release-line.html"
sort_by = "title"

[extra]
breadcrumb = "Download"
+++
3 changes: 3 additions & 0 deletions content/events/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ template = "events.html"
page_template = "event-page.html"
sort_by = "date"
generate_feeds = true

[extra]
breadcrumb = "Community"
+++
1 change: 1 addition & 0 deletions content/integrations/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ template = "libraries.html"
render = true

[extra]
breadcrumb = "Documentation › Integrations"
kind = "integrations"
+++
2 changes: 2 additions & 0 deletions content/participants.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
template: participants.html
title: Participate with Valkey
extra:
breadcrumb: Participants
---

# Valkey Participants
Expand Down
3 changes: 3 additions & 0 deletions content/topics/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ title = "Topics"
template = "docs.html"
page_template = "docs-page.html"
aliases = ["/docs/topics/"]

[extra]
breadcrumb = "Topics"
+++
73 changes: 32 additions & 41 deletions static/assets/js/search.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
document.addEventListener('DOMContentLoaded', function() {
const slot = document.getElementById('site-search');
const modalContents = document.getElementById('search-modal-contents');
// Without a search index, such as under zola serve, there is no search button.
if (!window.PagefindComponents || !slot) return;
if (!window.PagefindComponents || !slot || !modalContents) return;

// Configure before creating the elements: the first element to connect creates the
// instance with default settings, and configuration after that is ignored.
Expand All @@ -16,9 +17,11 @@ document.addEventListener('DOMContentLoaded', function() {

const trigger = document.createElement('pagefind-modal-trigger');
trigger.setAttribute('compact', '');
keepScrollPositionOnClose(trigger);
slot.append(trigger);
// The modal goes on <body>, inside the nav it would be hidden while the mobile menu is closed.
document.body.append(createModal());
// The <template> it's built from is never shown, so it can be anywhere.
document.body.append(createModal(modalContents));
});

// Each page's breadcrumb is a filter rather than metadata, since Pagefind searches metadata and
Expand Down Expand Up @@ -74,45 +77,33 @@ function putExactTitleMatchesFirst(instance) {
};
}

// Pagefind's default modal contents, written out so the results can use RESULT_TEMPLATE.
function createModal() {
// When the modal closes, Pagefind focuses the search button, which scrolls it into view. The header
// isn't sticky, so closing search from further down a page jumped back to the top. This makes that
// focus not scroll, as the browser does when it returns focus from a closed dialog.
//
// The Component UI has no option for this, so this wraps the button's private close handler,
// handleModalClose in pagefind-modal-trigger.ts, and changes only the focus it does.
function keepScrollPositionOnClose(trigger) {
const handleModalClose = trigger.handleModalClose;
if (typeof handleModalClose !== 'function') return;
trigger.handleModalClose = function() {
const button = this.buttonEl;
if (!button) return handleModalClose.call(this);
button.focus = function(options) {
HTMLElement.prototype.focus.call(this, { ...options, preventScroll: true });
};
try {
return handleModalClose.call(this);
} finally {
delete button.focus;
}
};
}

// The modal's contents are in templates/includes/search-modal.html, in a <template> so the Pagefind
// elements stay inactive until the modal has moved them into its dialog.
function createModal(contents) {
const modal = document.createElement('pagefind-modal');
// Parse the contents in an inert <template> so the Pagefind elements stay un-upgraded until the
// modal has moved them into its dialog; otherwise each one initializes twice.
const template = document.createElement('template');
template.innerHTML = `
<pagefind-modal-header><pagefind-input></pagefind-input></pagefind-modal-header>
<pagefind-modal-body>
<pagefind-summary></pagefind-summary>
<pagefind-results>${RESULT_TEMPLATE}</pagefind-results>
</pagefind-modal-body>
<pagefind-modal-footer><pagefind-keyboard-hints></pagefind-keyboard-hints></pagefind-modal-footer>`;
modal.append(template.content);
modal.append(contents.content.cloneNode(true));
return modal;
}

// Pagefind's built-in result template (https://pagefind.app/docs/components/results/), plus customizations.
// We add a site breadcrumb to help the user understand where the page is in the context of the site.
const RESULT_TEMPLATE = `<script type="text/pagefind-template">
<li class="pf-result">
<div class="pf-result-card">
<div class="pf-result-content">
{{#if meta.breadcrumb}}<p class="search-result-breadcrumb">{{ meta.breadcrumb }}</p>{{/if}}
<p class="pf-result-title">
<a class="pf-result-link" href="{{ meta.url | default(url) | safeUrl }}">{{ meta.title }}</a>
</p>
{{#if excerpt}}<p class="pf-result-excerpt">{{+ excerpt +}}</p>{{/if}}
</div>
</div>
{{#if sub_results}}
<ul class="pf-heading-chips">
{{#each sub_results as sub}}
<li class="pf-heading-chip">
<a class="pf-heading-link" href="{{ sub.url | safeUrl }}">{{ sub.title }}</a>
<p class="pf-heading-excerpt">{{+ sub.excerpt +}}</p>
</li>
{{/each}}
</ul>
{{/if}}
</li>
<\/script>`;
17 changes: 11 additions & 6 deletions templates/command-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
{% set command_title = command_obj_name %}
{% endif %}
{% set command_title = command_title | upper %}
{#- The command's group, for its breadcrumb in search results. #}
{% set command_groups = load_data(path="../_data/groups.json", required=false) %}
{% set command_group_key = command_data_obj.group | default(value="") | replace(from="_", to="-") %}
{% if command_groups and command_group_key in command_groups %}
{% set command_group = command_groups[command_group_key].display %}
{% endif %}
{% if command_data_obj.deprecated_since and (command_title == "SLAVEOF" or command_title == "CLUSTER SLAVES") %}
{% set deprecated = "Deprecated" %}
{% endif %}
Expand All @@ -46,6 +40,17 @@
{% set nav_location_json %}{{< nav_command_location nav={nav_data} name={command_title} container={command_container} group={command_data_obj.group} />}}{% endset %}
{% set nav_location = load_data(literal=nav_location_json, format="json") %}
{% endif %}

{#- The breadcrumbs below without the command itself, for search results. #}
{% if nav_location and nav_location.section %}
{% set search_breadcrumb = "Topics › " ~ nav_location.title %}
{% if nav_location.topic and nav_location.topic != nav_location.landing %}
{% set nav_topic %}{{< nav_topic_title slug={nav_location.topic} extra={config.extra} />}}{% endset %}
{% set search_breadcrumb = search_breadcrumb ~ " › " ~ (nav_topic | trim) %}
{% endif %}
{% else %}
{% set search_breadcrumb = "Commands" %}
{% endif %}
{%- endblock -%}

{% block breadcrumbs %}
Expand Down
49 changes: 33 additions & 16 deletions templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,38 @@
{%- elif page is defined and page.title %}{% set page_name = page.title %}
{%- elif section is defined and section.title %}{% set page_name = section.title %}
{%- else %}{% set page_name = "" %}{% endif -%}
{#- Where the page sits in the site's navigation. #}
{%- set path_segments = current_path | default(value="/") | split(pat="/") %}
{%- set path_section = path_segments[1] | default(value="") %}
{%- if command_title is defined and command_title %}{% set breadcrumb = "Documentation › Command Reference" %}{% if command_group is defined and command_group %}{% set breadcrumb = breadcrumb ~ " › " ~ command_group %}{% endif %}
{%- elif path_section == "commands" %}{% set breadcrumb = "Documentation › Command Reference" %}
{%- elif path_section == "topics" %}{% set breadcrumb = "Documentation › Documentation by Topic" %}
{%- elif path_section == "clients" %}{% set breadcrumb = "Documentation › Clients" %}
{%- elif path_section == "integrations" %}{% set breadcrumb = "Documentation › Integrations" %}
{%- elif path_section == "docs" %}{% set breadcrumb = "Documentation" %}
{%- elif path_section == "blog" %}{% set breadcrumb = "Blog" %}
{%- elif path_section == "authors" %}{% set breadcrumb = "Blog › Authors" %}
{%- elif path_section == "download" %}{% set breadcrumb = "Download" %}
{%- elif path_section in ["community", "events"] %}{% set breadcrumb = "Community" %}
{%- elif path_section == "participants" %}{% set breadcrumb = "Participants" %}
{%- elif path_section == "try-valkey" %}{% set breadcrumb = "Try Valkey" %}
{%- else %}{% set breadcrumb = "" %}{% endif -%}
{#- Where the page sits in the site, shown with its search results. Topic and command pages set
search_breadcrumb from the documentation menu in their head block, the same as their own
breadcrumbs. Other pages use `breadcrumb` in the [extra] front matter of the page, or else of
its nearest section that sets one. Failing that, they use the title of their nearest section
other than the site's root, for sections whose _index.md is rewritten by tools that drop extra
keys, such as the release automation's rewrite of content/try-valkey/_index.md. #}
{%- set breadcrumb = "" %}
{%- if search_breadcrumb is defined and search_breadcrumb %}{% set breadcrumb = search_breadcrumb %}
{%- else %}
{%- if page is defined %}{% set current = page %}{% elif section is defined %}{% set current = section %}{% else %}{% set current = {} %}{% endif %}
{%- if current %}
{%- set breadcrumb = current.extra?.breadcrumb | default(value="") %}
{%- for ancestor_path in current.ancestors | reverse %}
{%- if not breadcrumb %}
{%- set ancestor = get_section(path=ancestor_path, metadata_only=true) %}
{%- set_global breadcrumb = ancestor.extra?.breadcrumb | default(value="") %}
{%- endif %}
{%- endfor %}
{%- if not breadcrumb %}
{%- if page is not defined and current.relative_path != "_index.md" %}
{%- set breadcrumb = current.title | default(value="") %}
{%- else %}
{%- for ancestor_path in current.ancestors | reverse %}
{%- if not breadcrumb and ancestor_path != "_index.md" %}
{%- set ancestor = get_section(path=ancestor_path, metadata_only=true) %}
{%- set_global breadcrumb = ancestor.title | default(value="") %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- endif %}
{%- endif %}
{%- endif -%}
<!DOCTYPE html>
<html lang="{{ page?.lang | default(value=config.default_language) }}">
{% include "includes/head.html" %}
Expand Down Expand Up @@ -103,6 +119,7 @@
<!-- Star count will be injected here by JS -->
</a>
<div id="site-search"></div>
{% include "includes/search-modal.html" %}

</nav>
</div>
Expand Down
6 changes: 6 additions & 0 deletions templates/docs-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
{% set nav_data = load_data(literal=nav_json, format="json") %}
{% set nav_location_json %}{{< nav_topic_location nav={nav_data} slug={page.slug} />}}{% endset %}
{% set nav_location = load_data(literal=nav_location_json, format="json") %}

{#- The breadcrumbs below without the page itself, for search results. #}
{% set search_breadcrumb = "Topics" %}
{% if nav_location.section and nav_location.landing != page.slug %}
{% set search_breadcrumb = search_breadcrumb ~ " › " ~ nav_location.title %}
{% endif %}
{%- endblock head -%}

{% block breadcrumbs %}
Expand Down
44 changes: 44 additions & 0 deletions templates/includes/search-modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{#- Contents of the site search modal, which static/assets/js/search.js copies into a <pagefind-modal>.

They're in a <template> so the Pagefind elements stay inactive until the modal has moved them
into its dialog; otherwise each one initializes twice. This is Pagefind's default modal, written
out so the results can use the result template below. It must stay outside .body, the part of
the page Pagefind indexes (root_selector in pagefind.yml).

The result template is Pagefind's built-in one (https://pagefind.app/docs/components/results/),
plus each result's breadcrumb, so the user can see where the page is in the site. It uses
Pagefind's {{ }} syntax, so it's in a raw block to keep Zola from rendering it. #}
<template id="search-modal-contents">
<pagefind-modal-header><pagefind-input></pagefind-input></pagefind-modal-header>
<pagefind-modal-body>
<pagefind-summary></pagefind-summary>
<pagefind-results>
<script type="text/pagefind-template">
{%- raw %}
<li class="pf-result">
<div class="pf-result-card">
<div class="pf-result-content">
{{#if meta.breadcrumb}}<p class="search-result-breadcrumb">{{ meta.breadcrumb }}</p>{{/if}}
<p class="pf-result-title">
<a class="pf-result-link" href="{{ meta.url | default(url) | safeUrl }}">{{ meta.title }}</a>
</p>
{{#if excerpt}}<p class="pf-result-excerpt">{{+ excerpt +}}</p>{{/if}}
</div>
</div>
{{#if sub_results}}
<ul class="pf-heading-chips">
{{#each sub_results as sub}}
<li class="pf-heading-chip">
<a class="pf-heading-link" href="{{ sub.url | safeUrl }}">{{ sub.title }}</a>
<p class="pf-heading-excerpt">{{+ sub.excerpt +}}</p>
</li>
{{/each}}
</ul>
{{/if}}
</li>
{% endraw -%}
</script>
</pagefind-results>
</pagefind-modal-body>
<pagefind-modal-footer><pagefind-keyboard-hints></pagefind-keyboard-hints></pagefind-modal-footer>
</template>
Loading