Skip to content

Commit ceeef51

Browse files
authored
Merge pull request #1712 from redis/generic-api-reference
Make apireference layout generic
2 parents 6eb6795 + 2a5f248 commit ceeef51

File tree

4 files changed

+49
-86
lines changed

4 files changed

+49
-86
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
Title: RDI API Reference
3-
layout: rdiapireference
2+
linkTitle: RDI API Reference
3+
Title: Redis Data Integration API
4+
layout: apireference
45
type: page
56
---
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
Title: API Reference
2+
Title: Redis Cloud API
3+
linkTitle: API reference
34
layout: apireference
45
type: page
56
---

layouts/_default/apireference.html

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,52 @@
11
<!DOCTYPE html>
22
<html>
3+
<!--
4+
This layout can be used to generate API docs from an OpenAPI specification.
5+
6+
When creating a new API reference page, you can specify these optional params in the front matter:
7+
- sourcefile: The path to the OpenAPI specification file (YAML or JSON) relative to the page. Default: ./openapi.json
8+
- backLink: The path to the page to link to in the top left corner. Default: Parent page
9+
10+
Here's what the file structure should look like to use this template:
11+
<containing-folder>/
12+
├---------api-reference/
13+
| └------<spec-file-name> (default openapi.json)
14+
|
15+
├---------api-reference.md
16+
|
17+
└---------<other files>
18+
19+
Here's what the api-reference.md front matter should look like:
20+
---
21+
Title: <API Name>
22+
linkTitle: API reference
23+
layout: apireference
24+
type: page
25+
params:
26+
sourcefile: ./<spec-file-name> (optional - only specify if not using ./openapi.json)
27+
backLink: <path-to-page> (optional - only specify if not using the parent page)
28+
---
29+
30+
Example usage for the Redis Cloud API with all params set:
31+
---
32+
Title: Redis Cloud API
33+
linkTitle: API reference
34+
layout: apireference
35+
type: page
36+
params:
37+
sourcefile: ./openapi.json
38+
backLink: operate/rc/api
39+
---
40+
-->
341

442
<head>
5-
<title>Redis Cloud API</title>
43+
<title>{{ .Title }}</title>
644
{{ partial "scss.html" (dict "path" "scss/style.scss") }}
745
{{ partial "css.html" (dict "path" "css/index.css") }}
8-
{{ $relref := printf "%s%s" .Site.BaseURL "operate/rc/api/" }}
46+
{{ $relref := .Parent.Permalink }}
47+
{{ if .Params.backLink}}
48+
{{ $relref = printf "%s%s" .Site.BaseURL .Params.backLink }}
49+
{{ end }}
950
<!-- needed for adaptive design -->
1051
<!-- <link rel="preload" href="/public/scss/style.min.65324e4de191c292ee8b6f4f0ebf01320e8c4bc8623b04e9dfad322ebb490b31.css" as="style">
1152
<link href="/public/scss/style.min.65324e4de191c292ee8b6f4f0ebf01320e8c4bc8623b04e9dfad322ebb490b31.css" rel="stylesheet" integrity="">
@@ -62,7 +103,7 @@
62103
<body>
63104
<div>
64105
<redoc
65-
spec-url='./openapi.json'
106+
spec-url='{{ .Params.sourcefile | default "./openapi.json" }}'
66107
scroll-y-offset='#apiReferenceHeader'
67108
json-sample-expand-level=all
68109
sort-operations-alphabetically="true"

layouts/_default/rdiapireference.html

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

0 commit comments

Comments
 (0)