Skip to content

Commit

Permalink
Merge pull request #235 from 1712n/fix-menus
Browse files Browse the repository at this point in the history
simple-fixes
  • Loading branch information
marina-chibizova authored Sep 7, 2023
2 parents ab7cf70 + 3fcfe83 commit 7415a05
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 124 deletions.
10 changes: 9 additions & 1 deletion README-DEV.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@

## Navigation

Use page params `navShowPages`, `navShowTaxonomies` and `navShowTerms` to configure how sections should appear on the navigation menu. Set `true` to show and `false` to hide.
Use the optional page parameters bellow to configure how pages and sections should appear on the navigation menu.

- `navHide`: removes the page/section from navigation
- `navHideLink`: display the item as `<span>` instead of `<a>`
- `navShowPages`: show list of pages that are direct children of the section
- `navShowTaxonomies`: show list of taxonomies that belongs to the section
- `navShowTerms`: show list of terms that belongs to each taxonomy

Use `true` or `false` as values.

## See also

Expand Down
12 changes: 6 additions & 6 deletions config/_default/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ markup:
startLevel: 1

menu:
external:
- name: "Github"
url: "https://github.com/1712n/dni-website"
weight: 10
params:
icon: ""
# external:
# - name: "Github"
# url: "https://github.com/1712n/dni-website"
# weight: 10
# params:
# icon: ""

taxonomies:
# global
Expand Down
4 changes: 2 additions & 2 deletions content/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ As part of our documentation efforts, we maintain a [crowdsourced knowledge base
### Improving Oracles
Oracles are one of the pillars of modern distributed networks, allowing smart contracts to interact with the external world. We focus on [building models](https://github.com/1712n/yachay-public) capable of answering what, when, and where questions.

### MVT API
### Market Health

[Market Venue Transparency API]({{% ref "mvt" %}}) is our effort to bring accountability and transparency to the crypto market venues.
To improve the integrity and accountability of cryptocurrency trading venues, we are working on a set of standards designed to detect potential threats posed by market participants. Specifically, we are creating a set of health metrics aimed to identify fraudulent activity in market venues, including wash trading and front running. Additionally, we regularly release analytical articles that showcase real-world applications of these metrics. We also provide investigative tools for public use, enabling community to detect fraudulent activities within the crypto realm.
6 changes: 4 additions & 2 deletions content/attacks/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: Crypto Attacks
hide: true
title: Infrastructure Resilience
navHideLink: true
navShowPages: true
bookCollapseSection: true
weight: 20
---
2 changes: 1 addition & 1 deletion content/attacks/docs/_index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Wiki"
hide: true
navHideLink: true
navShowPages: true
---
6 changes: 6 additions & 0 deletions content/education/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Education
navShowPages: true
weight: 30
draft: true
---
2 changes: 1 addition & 1 deletion content/market-health/_index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Market Health
navShowTaxonomies: false
draft: true
weight: 10
---

## Market Health: Anomalies & Integrity Studies
Expand Down
1 change: 1 addition & 0 deletions content/mvt/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: "MVT API"
bookToc: true
navHide: true
---

In order to promote transparency and accountability at crypto trading venues, we are publishing a set of API specifications called Market Venue Transparency API (MVT API). Its goal is to facilitate the collection and analysis of the order-level data enriched with Anonymized Trader IDs.
Expand Down
1 change: 1 addition & 0 deletions content/oracles/_index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
title: Oracles
draft: true
navHide: true
---
23 changes: 0 additions & 23 deletions layouts/partials/docs/inject/footer.html

This file was deleted.

2 changes: 1 addition & 1 deletion layouts/partials/docs/menu-anchor.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ $isCurrent := hasPrefix .page.RelPermalink .item.RelPermalink | default false }}

{{ if .item.Page.Params.hide }}
{{ if .item.Page.Params.navHideLink }}
<span
class="anchor"
{{ if $isCurrent }}aria-current="page"{{ end }}
Expand Down
112 changes: 112 additions & 0 deletions layouts/partials/docs/menu-filetree.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{{ define "taxonomies" }}
{{ $page := .page }}
{{ $section := .item }}
{{ $path := .path }}
{{ $level := add .level 1 }}

{{ range $taxonomy, $terms := site.Taxonomies }}
{{ with site.GetPage $taxonomy }}
{{ if (hasPrefix .RelPermalink $section.RelPermalink) }}
{{ $showTerms := .Params.navShowTerms | default false }}

<li class="taxonomy {{ if $showTerms }}collapsible{{ end }}">
<h{{ $level }}>{{ partial "docs/menu-anchor" (dict "page" $page "item" . "showControls" $showTerms) }}</h{{ $level }}>

{{ if $showTerms }}
{{ with $terms }}
{{ $name := .LinkTitle | urlize | lower }}
{{ $path = printf "%s-%s" $path $name }}
{{ $id := printf "ul%d-%s" $level $path }}

<ul class="terms collapsible-target" id="{{ $id }}">
{{ range . }}
<li>{{ partial "docs/menu-anchor" (dict "page" $page "item" .Page) }}</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ define "menu" }}
{{ $page := .page }}
{{ $path := .path }}
{{ $level := add .level 1 }}

{{ $name := "" }}
{{ $id := "" }}
{{ $expand := "" }}

{{ $name = .LinkTitle | urlize | lower }}

{{ if $path }}
{{ $path = printf "%s-%s" $path $name }}
{{ else }}
{{ $path = $name }}
{{ end }}

{{ $id = printf "ul%d-%s" $level $path }}

{{ $showPages := (and (.item.Param "navShowPages") (gt (.item.Pages | len) 0)) | default false }}
{{ $showTaxonomies := .item.Param "navShowTaxonomies" | default false }}
{{ $expand = (or $showPages $showTaxonomies) | default false }}

<li class="li-h{{ $level }} {{ if $expand }}collapsible{{ end }}">
<h{{ $level }}>{{ partial "docs/menu-anchor" (dict "page" $page "item" .item "showControls" $expand) }}</h{{ $level }}>

{{ if $showTaxonomies }}
<ul class="taxonomies collapsible-target" id="{{ $id }}">
{{ template "taxonomies" (dict "page" $page "item" .item "level" $level "path" $path) }}
</ul>
{{ end }}

{{ if $showPages }}
<ul class="pages collapsible-target" id="{{ $id }}">
{{ range .item.Pages }}
{{ template "menu" (dict "page" $page "item" . "level" $level "path" $path) }}
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}

<ul class="book-tree">
{{ range site.Home.Pages }}
{{ if not (.Param "navHide") }}
{{ template "menu" (dict "page" . "item" . "level" 1 "path" "") }}
{{ end }}
{{ end }}

{{ with site.Menus.external }}
<li class="li-h2 external-links">
<h2>External</h2>
{{ partial "docs/menu-hugo" . }}
</li>
{{ end }}
</ul>

<script type="module">
import Collapsible from "/js/collapsible.js"

const sections = document.querySelectorAll(".collapsible")

sections.forEach((item) => {
const control = item.querySelector(".collapsible-control")
const target = item.querySelector(".collapsible-target")

new Collapsible({
control: control,
target: {
element: target,
},
aria: {
expanded: true,
controls: true
},
debug: false
})
})
</script>
88 changes: 1 addition & 87 deletions layouts/partials/docs/menu.html
Original file line number Diff line number Diff line change
@@ -1,78 +1,3 @@
{{ define "taxonomies" }}
{{ $page := .page }}
{{ $section := .item }}
{{ $path := .path }}
{{ $level := add .level 1 }}

{{ range $taxonomy, $terms := site.Taxonomies }}
{{ with site.GetPage $taxonomy }}
{{ if (hasPrefix .RelPermalink $section.RelPermalink) }}
{{ $showTerms := .Params.navShowTerms | default false }}

<li class="taxonomy {{ if $showTerms }}collapsible{{ end }}">
<h{{ $level }}>{{ partial "docs/menu-anchor" (dict "page" $page "item" . "showControls" $showTerms) }}</h{{ $level }}>

{{ if $showTerms }}
{{ with $terms }}
{{ $name := .LinkTitle | urlize | lower }}
{{ $path = printf "%s-%s" $path $name }}
{{ $id := printf "ul%d-%s" $level $path }}

<ul class="terms collapsible-target" id="{{ $id }}">
{{ range . }}
<li>{{ partial "docs/menu-anchor" (dict "page" $page "item" .Page) }}</li>
{{ end }}
</ul>
{{ end }}
{{ end }}
</li>
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ define "menu" }}
{{ $page := .page }}
{{ $path := .path }}
{{ $level := add .level 1 }}

{{ $name := "" }}
{{ $id := "" }}
{{ $expand := "" }}

{{ $name = .LinkTitle | urlize | lower }}

{{ if $path }}
{{ $path = printf "%s-%s" $path $name }}
{{ else }}
{{ $path = $name }}
{{ end }}

{{ $id = printf "ul%d-%s" $level $path }}

{{ $showPages := (and (.item.Param "navShowPages") (gt (.item.Pages | len) 0)) | default false }}
{{ $showTaxonomies := .item.Param "navShowTaxonomies" | default false }}
{{ $expand = (or $showPages $showTaxonomies) | default false }}

<li class="li-h{{ $level }} {{ if $expand }}collapsible{{ end }}">
<h{{ $level }}>{{ partial "docs/menu-anchor" (dict "page" $page "item" .item "showControls" $expand) }}</h{{ $level }}>

{{ if $showTaxonomies }}
<ul class="taxonomies collapsible-target" id="{{ $id }}">
{{ template "taxonomies" (dict "page" $page "item" .item "level" $level "path" $path) }}
</ul>
{{ end }}

{{ if $showPages }}
<ul class="pages collapsible-target" id="{{ $id }}">
{{ range .item.Pages }}
{{ template "menu" (dict "page" $page "item" . "level" $level "path" $path) }}
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}

<nav>
{{ partial "docs/brand" . }}
{{ partial "docs/search" . }}
Expand All @@ -81,18 +6,7 @@
{{ end }}

{{ partial "docs/inject/menu-before" . }}

<ul class="book-tree">
{{ range site.Home.Pages }}
{{ template "menu" (dict "page" . "item" . "level" 1 "path" "") }}
{{ end }}

<li class="li-h2 external-links">
<h2>External</h2>
{{ partial "docs/menu-hugo" site.Menus.external }}
</li>
</ul>

{{ partial "docs/menu-filetree" . }}
{{ partial "docs/inject/menu-after" . }}
</nav>

Expand Down

0 comments on commit 7415a05

Please sign in to comment.