Code samples: sort intro things first

This commit is contained in:
mDuo13
2022-05-13 13:22:02 -07:00
parent e38318abb0
commit b62b81ac1f
3 changed files with 14 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
# Require Destination Tags
Require incoming payments to your account to specify a [Destination Tag](https://xrpl.org/source-and-destination-tags.html) so you know whom to credit.
Require incoming payments to specify a [Destination Tag](https://xrpl.org/source-and-destination-tags.html) so you know whom to credit.
Examples from the [Require Destination Tags tutorial](https://xrpl.org/require-destination-tags.html).

View File

@@ -23,7 +23,6 @@
<section class="container-new py-26">
<div class="d-flex flex-column col-sm-8 p-0">
<h6 class="eyebrow mb-3">{% trans %}Explore Code Samples{% endtrans %}</h6>
<h3 class="h4 h2-sm">{% trans %}Browse sample code for building common use cases on the XRP Ledger{% endtrans %}</h3>
</div>

View File

@@ -36,6 +36,14 @@ def to_title_case(s):
# def all_langs():
langs = []
def sortfunc(cs):
"""
Sort code samples alphabetically by title except with "Intro" fields first
"""
if "Intro" in cs["title"] or "Quickstart" in cs["title"]:
return " "+cs["title"]
else:
return cs["title"]
def all_code_samples():
cses = []
@@ -84,8 +92,7 @@ def all_code_samples():
cs["href"] = dirpath
cses.append(cs)
# Current sort value: alphabetical by title.
return sorted(cses, key=lambda x: x["title"])
return sorted(cses, key=sortfunc)
export = {
"all_code_samples": all_code_samples,