From 2c86307f68964aab1ee715009575a2c8934d829f Mon Sep 17 00:00:00 2001 From: Robert Fekete Date: Fri, 1 Jul 2022 00:36:32 +0200 Subject: [PATCH] Redoc shortcode (#1052) * Adds redoc shortcode * Documents redoc shortcode * Change example to URL instead of local file * Fix html and redoc options Co-authored-by: LisaFC --- layouts/shortcodes/redoc.html | 91 +++++++++++++++++++ .../docs/Adding content/Shortcodes/index.md | 15 +++ 2 files changed, 106 insertions(+) create mode 100644 layouts/shortcodes/redoc.html diff --git a/layouts/shortcodes/redoc.html b/layouts/shortcodes/redoc.html new file mode 100644 index 0000000000..0d4cf09d86 --- /dev/null +++ b/layouts/shortcodes/redoc.html @@ -0,0 +1,91 @@ +{{- $file := .Get 0 -}} +{{- $url := "" -}} +{{- $otheroptions := .Get 1 -}} + +{{ if hasPrefix $file "http"}} + {{- $url = $file -}} +{{ else }} + {{ if (fileExists (print .Page.File.Dir $file)) -}} + + {{- $url = (print .Page.Site.BaseURL .Page.File.Dir $file) -}} + {{ else }} + + {{- $url = (print .Page.Site.BaseURL $file) -}} + {{- end }} +{{- end -}} + + + + + + + + + + + + + + +
+ +
+ + diff --git a/userguide/content/en/docs/Adding content/Shortcodes/index.md b/userguide/content/en/docs/Adding content/Shortcodes/index.md index 08192b3366..627a3a00d7 100644 --- a/userguide/content/en/docs/Adding content/Shortcodes/index.md +++ b/userguide/content/en/docs/Adding content/Shortcodes/index.md @@ -288,6 +288,21 @@ description: Reference for the Pet Store API You can customize Swagger UI's look and feel by overriding Swagger's CSS or by editing and compiling a [Swagger UI dist](https://github.com/swagger-api/swagger-ui) yourself and replace `themes/docsy/static/css/swagger-ui.css`. +### redoc + +The `redoc` shortcode uses the open-source [Redoc](https://github.com/Redocly/redoc) tool to render reference API documentation from an OpenAPI YAML or JSON file. This can be hosted anywhere you like, for example in your site's root [`/static` folder](/docs/adding-content/content/#adding-static-content), but you can use a URL as well, for example: + +```yaml +--- +title: "Pet Store API" +type: docs +weight: 1 +description: Reference for the Pet Store API +--- + +{{}} +``` + ### iframe With this shortcode you can embed external content into a Docsy page as an inline frame (`iframe`) - see: https://www.w3schools.com/tags/tag_iframe.asp