Skip to content

Commit 2ae558c

Browse files
committed
Redocly: Add support for content on redocly pages
1 parent 2907963 commit 2ae558c

File tree

7 files changed

+63
-33
lines changed

7 files changed

+63
-33
lines changed

assets/css/v2/style.css

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,26 @@ nav {
881881
[data-grid="half"] {
882882
grid-column: span 6;
883883
}
884+
885+
[data-grid="breakout"] {
886+
grid-column: 1 / -1;
887+
width: calc(100vw - var(--sidebar-width) - 4rem);
888+
position: relative;
889+
left: 50%;
890+
right: 50%;
891+
margin-left: calc(-1 * (50vw - var(--sidebar-width) / 2 - 2rem));
892+
margin-right: calc(-1 * (50vw - var(--sidebar-width) / 2 - 2rem));
893+
max-width: calc(100vw - var(--sidebar-width) - 4rem);
894+
}
895+
896+
@media (max-width: 68rem) {
897+
[data-grid="breakout"] {
898+
width: 100vw;
899+
margin-left: -50vw;
900+
margin-right: -50vw;
901+
max-width: 100vw;
902+
}
903+
}
884904
}
885905

886906
.content {
@@ -921,19 +941,16 @@ nav {
921941
}
922942
}
923943
}
924-
925-
/* Allow redocly to fill the entire container */
926-
&.content__redocly {
927-
min-width: 100%;
928-
margin: 0;
929-
930-
#api-component {
931-
z-index: 0;
932-
position: relative;
933-
display: block;
934-
max-width: 100%;
935-
margin-block-start: 1rem;
936-
}
944+
}
945+
/* Allow redocly to fill the entire container */
946+
.content .content__redocly {
947+
border-top: 1px solid oklch(var(--color-divider));
948+
border-bottom: 1px solid oklch(var(--color-divider));
949+
#api-component {
950+
z-index: 0;
951+
position: relative;
952+
display: block;
953+
max-width: 100%;
937954
}
938955
}
939956

exampleSite/content/test-product/redoc/api-reference.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@ tags:
77
- api
88
doctypes:
99
- reference
10+
nd-api-reference: "./api/example.json"
1011
---
11-
{{< openapi spec="./api/example.json" >}}
12+
13+
## Introduction
14+
15+
Welcome to the API Reference documentation for the example book API. This documentation provides detailed information about the API endpoints, request/response formats, and other relevant details.
16+
17+
## API Specification

exampleSite/content/test-product/redoc/live-example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ tags:
77
- api
88
doctypes:
99
- reference
10+
nd-api-reference: "./api/one.json"
1011
---
11-
{{< openapi spec="./api/one.json" >}}

layouts/_default/single.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ <h1>{{ .Title }}</h1>
2020
{{ if eq .Page.Draft true }}{{ partial "draft-badge.html" . }}{{ end }}
2121
{{ if in .Params.doctypes "beta" }}{{ partial "beta-badge" . }}{{ end }}
2222

23+
{{ with (index .Page.Params "nd-api-reference") }}
24+
<div class="content__redocly" data-grid="breakout">
25+
{{ partial "openapi.html" . }}
26+
</div>
27+
{{ end }}
28+
2329
{{ if .Page.Lastmod }}
2430
<div class="last-modified">
2531
{{ partial "page-meta-links" . }}
@@ -28,13 +34,13 @@ <h1>{{ .Title }}</h1>
2834

2935
{{ partial "version-list" . }}
3036
{{ partial "qualtrics-feedback.html" }}
31-
32-
</section>
33-
</section>
37+
</article>
3438
</main>
3539

3640

3741

42+
43+
3844
<!-- If there is a script defined in the page metadata, load it -->
3945
{{if .Params.script}}
4046
{{ $script := (delimit (slice "scripts" .Params.script) "/")}}

layouts/partials/openapi.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div>
2+
<div id="api-component">
3+
<api-container>
4+
<redoc
5+
spec-url='{{ . | relURL }}'
6+
menu-toggle
7+
path-in-middle-panel
8+
required-props-first
9+
hide-hostname="true"
10+
show-extensions="x-f5-experimental"
11+
nativeScrollbars
12+
>
13+
</redoc>
14+
</api-container>
15+
</div>
16+
</div>

layouts/redoc/single.html

Lines changed: 0 additions & 11 deletions
This file was deleted.

layouts/shortcodes/openapi.html

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)