@scalar/docusaurus 0.4.13 → 0.4.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +4 -3
- package/dist/ScalarDocusaurus.js +9 -7
- package/dist/ScalarDocusaurusCommonJS.js +20 -9
- package/dist/index.js +0 -8
- package/dist/theme.css +387 -395
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @scalar/docusaurus
|
|
2
2
|
|
|
3
|
+
## 0.4.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5812c2f: feat: allow custom headers
|
|
8
|
+
- b11d4a9: feat: add support for relative URLs
|
|
9
|
+
- @scalar/api-reference-react@0.3.14
|
|
10
|
+
|
|
11
|
+
## 0.4.15
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 40d7c3d: fix: remove layers in docusaurus and fix precedence issue
|
|
16
|
+
- @scalar/api-reference-react@0.3.13
|
|
17
|
+
|
|
18
|
+
## 0.4.14
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- @scalar/api-reference-react@0.3.12
|
|
23
|
+
|
|
3
24
|
## 0.4.13
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -15,8 +15,7 @@ npm install @scalar/docusaurus
|
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
typescript you can import the type options type as well
|
|
18
|
+
Simply add to the plugins section of your Docusaurus config. If you are using Typescript you can import the type options type as well.
|
|
20
19
|
|
|
21
20
|
```ts
|
|
22
21
|
import type { ScalarOptions } from '@scalar/docusaurus'
|
|
@@ -37,9 +36,11 @@ plugins: [
|
|
|
37
36
|
],
|
|
38
37
|
```
|
|
39
38
|
|
|
39
|
+
We wrote a [detailed integration guide for Docusaurus](https://github.com/scalar/scalar/tree/main/documentation/docusaurus.md).
|
|
40
|
+
|
|
40
41
|
### Multiple API descriptions
|
|
41
42
|
|
|
42
|
-
Is it possible to
|
|
43
|
+
Is it possible to show multiple API descriptions? Yes, it is! :)
|
|
43
44
|
|
|
44
45
|
```ts
|
|
45
46
|
import type { ScalarOptions } from '@scalar/docusaurus'
|
package/dist/ScalarDocusaurus.js
CHANGED
|
@@ -9,12 +9,14 @@ require("@scalar/api-reference-react/style.css");
|
|
|
9
9
|
const Layout_1 = __importDefault(require("@theme/Layout"));
|
|
10
10
|
const react_1 = __importDefault(require("react"));
|
|
11
11
|
require("./theme.css");
|
|
12
|
-
const ScalarDocusaurus = ({ route }) =>
|
|
13
|
-
react_1.default.createElement(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
const ScalarDocusaurus = ({ route }) => {
|
|
13
|
+
return (react_1.default.createElement(Layout_1.default, null,
|
|
14
|
+
react_1.default.createElement(BrowserOnly_1.default, null, () => {
|
|
15
|
+
const ApiReferenceReact =
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
|
+
require('@scalar/api-reference-react').ApiReferenceReact;
|
|
18
|
+
return react_1.default.createElement(ApiReferenceReact, { configuration: route.configuration });
|
|
19
|
+
})));
|
|
20
|
+
};
|
|
19
21
|
exports.ScalarDocusaurus = ScalarDocusaurus;
|
|
20
22
|
exports.default = exports.ScalarDocusaurus;
|
|
@@ -51,20 +51,31 @@ class ScalarDocusaurusCommonJS extends react_1.Component {
|
|
|
51
51
|
if (container &&
|
|
52
52
|
this.props.route.configuration &&
|
|
53
53
|
!document.getElementById('api-reference')) {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const config = this.props.route.configuration;
|
|
55
|
+
// Execute content function if it exists
|
|
56
|
+
if (typeof config.spec?.content === 'function') {
|
|
57
|
+
config.spec.content = config.spec.content();
|
|
58
|
+
}
|
|
59
|
+
// Convert the document to a string
|
|
60
|
+
const documentString = config?.spec?.content
|
|
61
|
+
? typeof config?.spec?.content === 'string'
|
|
62
|
+
? config.spec.content
|
|
63
|
+
: JSON.stringify(config.spec.content)
|
|
62
64
|
: '';
|
|
65
|
+
// Delete content from configuration
|
|
66
|
+
if (config?.spec?.content) {
|
|
67
|
+
delete config.spec.content;
|
|
68
|
+
}
|
|
69
|
+
// Convert the configuration to a string
|
|
63
70
|
const configString = JSON.stringify(config ?? {})
|
|
64
71
|
.split('"')
|
|
65
72
|
.join('"');
|
|
73
|
+
// Create and append a script element with the configuration and the content
|
|
74
|
+
const apiReferenceScript = document.createElement('script');
|
|
75
|
+
apiReferenceScript.id = 'api-reference';
|
|
76
|
+
apiReferenceScript.type = 'application/json';
|
|
66
77
|
apiReferenceScript.dataset.configuration = configString;
|
|
67
|
-
apiReferenceScript.innerHTML =
|
|
78
|
+
apiReferenceScript.innerHTML = documentString;
|
|
68
79
|
container.appendChild(apiReferenceScript);
|
|
69
80
|
// Creating and appending the script element
|
|
70
81
|
const script = document.createElement('script');
|
package/dist/index.js
CHANGED
|
@@ -11,14 +11,6 @@ const ScalarDocusaurus = (context, options) => {
|
|
|
11
11
|
return {
|
|
12
12
|
name: '@scalar/docusaurus',
|
|
13
13
|
async loadContent() {
|
|
14
|
-
// Check if we need to download a spec
|
|
15
|
-
if (options.configuration?.spec?.url) {
|
|
16
|
-
const resp = await fetch(options.configuration.spec.url);
|
|
17
|
-
const content = await resp.text();
|
|
18
|
-
return {
|
|
19
|
-
configuration: { ...options.configuration, spec: { content } },
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
14
|
return options;
|
|
23
15
|
},
|
|
24
16
|
async contentLoaded({ content, actions }) {
|