Skip to content

Commit

Permalink
chore: Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
wwerner committed Sep 5, 2024
1 parent 09ab77b commit f624da6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rapidoc-9.3.4.min.js
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
![rapidoc in discourse](image.png)
Original file line number Diff line number Diff line change
@@ -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]");
Expand All @@ -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) {
Expand All @@ -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 = `
Expand All @@ -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"}"
>
</rapi-doc>
<br/>
Expand Down

0 comments on commit f624da6

Please sign in to comment.