mirror of
https://github.com/matrix-org/matrix-spec
synced 2025-12-27 11:28:38 +01:00
Add an endpoints table of contents
A simple list of endpoints that one can ctrl-f through.
This commit is contained in:
parent
82a67a1fab
commit
56d48eb3a8
|
|
@ -257,6 +257,45 @@ Custom SCSS for the Matrix spec
|
|||
|
||||
}
|
||||
|
||||
.endpoints-toc {
|
||||
summary {
|
||||
cursor: pointer;
|
||||
font-weight: $font-weight-bold;
|
||||
font-size: 1.05rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.endpoint-list {
|
||||
list-style: none;
|
||||
padding-left: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.endpoint-list li {
|
||||
margin: 0.2rem 0;
|
||||
}
|
||||
|
||||
.endpoint-list a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.endpoint-list .http-api-method {
|
||||
font-weight: $font-weight-bold;
|
||||
margin-right: 0.35rem;
|
||||
}
|
||||
|
||||
.endpoint-path {
|
||||
font-family: $font-family-monospace;
|
||||
color: $secondary;
|
||||
}
|
||||
}
|
||||
|
||||
.page-description {
|
||||
margin-bottom: 1rem;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/* Styles for alert boxes */
|
||||
.alert {
|
||||
&.note {
|
||||
|
|
@ -581,4 +620,4 @@ dd {
|
|||
.breadcrumb {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
28
layouts/_partials/endpoints-toc.html
Normal file
28
layouts/_partials/endpoints-toc.html
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{{/* Minimal list of API endpoints for the current page. */}}
|
||||
{{ $raw := .Scratch.Get "api_endpoints" }}
|
||||
{{/* Normalize to a slice */}}
|
||||
{{ $endpoints := slice }}
|
||||
{{ if reflect.IsSlice $raw }}
|
||||
{{ $endpoints = $raw }}
|
||||
{{ else if reflect.IsMap $raw }}
|
||||
{{ range $raw }}
|
||||
{{ $endpoints = append $endpoints . }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ if gt (len $endpoints) 0 }}
|
||||
<div class="endpoints-toc mb-4">
|
||||
<details>
|
||||
<summary>List of Endpoints</summary>
|
||||
<ul class="endpoint-list">
|
||||
{{ range $endpoints }}
|
||||
<li>
|
||||
<a href="#{{ .anchor }}">
|
||||
<span class="http-api-method">{{ .method }}</span>
|
||||
<span class="endpoint-path">{{ .endpoint }}</span>
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</details>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
{{ define "main" }}
|
||||
<div class="td-content">
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
|
||||
{{ with .Params.description }}<p class="page-description">{{ . | markdownify }}</p>{{ end }}
|
||||
{{ partial "endpoints-toc.html" . }}
|
||||
{{ .Content }}
|
||||
</div>
|
||||
{{ end }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue