Skip to content

Commit

Permalink
Merge pull request #153 from valkey-io/main
Browse files Browse the repository at this point in the history
Move to Prod: Categorized Commands
  • Loading branch information
stockholmux authored Oct 11, 2024
2 parents 9a7716a + 24e66a3 commit 0880f71
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ content/commands/*
!content/commands/_index.md
content/topics/*
!content/topics/_index.md
_site
_site
_data/groups.json
7 changes: 6 additions & 1 deletion build/init-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ EOF
fi
done

echo "Command stub files created."
echo "Command stub files created."

grouppath="../${1}/../groups.json"
ln -s $grouppath ./_data/groups.json

echo "Created link to groups.json"
23 changes: 17 additions & 6 deletions sass/_valkey.scss
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,25 @@ pre table {
border-collapse: collapse;
}

.command-entry {
border-bottom: 1px dotted $line;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
padding-top: 1rem;
padding-bottom: 1rem;
.command-group {
.command-entry {
border-bottom: 1px dotted $line;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
padding-top: 1rem;
padding-bottom: 1rem;

}
.command-entry,
.command-group-meta {
margin-left: 1em;
}

}




.author-container {
display: flex;
align-items: center;
Expand Down
56 changes: 46 additions & 10 deletions templates/commands.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{% extends "fullwidth.html" %}
{% extends "right-aside.html" %}

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

{% block main_content %}
{% if section.pages | length == 0 %}
<strong>No command pages found.</strong> You likely need to build the command pages. See "Building additional content" in README.md file.
{% endif %}

{% set_global group_descriptions = load_data(path= "../_data/groups.json", required= false) %}

{% set commands_entries = [] %}
{% for page in section.pages %}
{% set command_data = load_data(path= commands::command_json_path(slug= page.slug), required= false) %}
Expand All @@ -16,21 +19,54 @@
{% if command_data_obj.container %}
{% set command_display = command_data_obj.container ~ " " ~ command_display %}
{% endif %}

{% set command_entry = [
command_display,
page.permalink | safe,
command_data_obj.summary

command_data_obj.summary,
command_data_obj.group
] %}

{% set_global commands_entries = commands_entries | concat(with= [ command_entry ]) %}

{# <div class="command-entry"><code><a href="{{ page.permalink | safe }}">{{ command_display }}</a></code> {{command_data_obj.summary}}</div> #}
{% endif %}
{% endfor %}
{% for entry in commands_entries | sort(attribute="0") %}
<div class="command-entry"><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code> {{entry[2]}}</div>
{% set_global grouped = commands_entries | sort(attribute="3") | group_by(attribute="3") %}


{% for command_group_name, command_group in grouped %}
<div class="command-group">
{% set command_group_description_name = command_group_name | replace(from="_", to="-") %}
<h2 id="{{command_group_description_name}}">{{ group_descriptions[command_group_description_name].display }}</h2>
<div class="command-group-meta">
<p><small>{{ group_descriptions[command_group_description_name].description }}</small></p>
<hr />
</div>
{% for entry in command_group | sort(attribute="0") %}
<div class="command-entry"><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code> {{entry[2]}}</div>
{% endfor %}
<div class="command-group-meta">
<small><a href="#top">Back to top</a></small>
</div>
</div>
{% endfor %}

{% endblock main_content %}

{% block related_content %}
<h2 id="top">Command Categories</h2>
<ul>
{% if group_descriptions %}
{% for command_group_name, group_description in group_descriptions %}
{% set replaced_group_id = command_group_name | replace(from="-", to="_") %}
{% if grouped[replaced_group_id] %}<li> <a href="#{{ command_group_name }}">{{ group_description.display }}</a></li>{% endif %}
{% endfor %}
{% endif %}
</ul>

<h2>Alphabetical Command List</h2>
<ul>
{% set alpha_entries = commands_entries | sort(attribute="0") %}
{% for entry in alpha_entries %}
<li><code><a href="{{ entry[1] }}">{{ entry[0] }}</a></code></li>
{% endfor %}
{% endblock main_content %}
</ul>
{% endblock related_content %}

0 comments on commit 0880f71

Please sign in to comment.