From f624da69858705e282b35f76d53a46fd75592eea Mon Sep 17 00:00:00 2001 From: Wolfgang Werner Date: Thu, 5 Sep 2024 18:06:46 +0200 Subject: [PATCH] chore: Make linter happy --- .prettierignore | 1 + README.md | 12 +++++------- .../discourse-rapidoc-theme-component.js | 12 +++++------- 3 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3bd05df --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +rapidoc-9.3.4.min.js \ No newline at end of file diff --git a/README.md b/README.md index 8d12592..8b39958 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,15 @@ Based off the nice official [Discourse mermaid component](https://github.com/dis To use it ... -* [install it](https://meta.discourse.org/t/install-a-theme-or-theme-component/63682) into your Discourse instance -* in a topic, create a code block and use `apidoc` as language tag and the URL of an OpenAPI specification url as the block's content. +- [install it](https://meta.discourse.org/t/install-a-theme-or-theme-component/63682) into your Discourse instance +- in a topic, create a code block and use `apidoc` as language tag and the URL of an OpenAPI specification url as the block's content. -``` +```` ```apidoc https://petstore.swagger.io/v2/swagger.json -``` - +```` If specification is not publicly accessible, you can attach the specification file to your post and copy the URL after the file has been uploaded. - Here's how it could look like -![rapidoc in discourse](image.png) \ No newline at end of file +![rapidoc in discourse](image.png) diff --git a/javascripts/discourse/api-initializers/discourse-rapidoc-theme-component.js b/javascripts/discourse/api-initializers/discourse-rapidoc-theme-component.js index edf0eaa..154328d 100644 --- a/javascripts/discourse/api-initializers/discourse-rapidoc-theme-component.js +++ b/javascripts/discourse/api-initializers/discourse-rapidoc-theme-component.js @@ -1,6 +1,5 @@ import { apiInitializer } from "discourse/lib/api"; import loadScript from "discourse/lib/load-script"; -import discourseDebounce from "discourse-common/lib/debounce"; async function applyRapidoc(element) { const apidocs = element.querySelectorAll("pre[data-code-wrap=apidoc]"); @@ -12,11 +11,10 @@ async function applyRapidoc(element) { await loadScript(settings.theme_uploads_local.rapidoc_js); const theme = - getComputedStyle(document.body) - .getPropertyValue("--scheme-type") - .trim() === "dark" + getComputedStyle(document.body).getPropertyValue("--scheme-type").trim() === + "dark" ? "dark" - : "default" + : "default"; apidocs.forEach((apidoc) => { if (apidoc.dataset.processed) { @@ -31,7 +29,7 @@ async function applyRapidoc(element) { return; } - const promise = new Promise(resolve => resolve(codeBlock.textContent)) + const promise = new Promise((resolve) => resolve(codeBlock.textContent)); promise .then((spec) => { apidoc.outerHTML = ` @@ -45,7 +43,7 @@ async function applyRapidoc(element) { allow-api-list-style-selection="false" allow-spec-file-download="true" allow-authentication="true" - theme="${theme==='dark' ? 'dark' : 'light'}" + theme="${theme === "dark" ? "dark" : "light"}" >