Skip to content

Commit

Permalink
Merge pull request #7 from pulsate-dev/add-api-reference
Browse files Browse the repository at this point in the history
feat: Add API Reference
  • Loading branch information
m1sk9 authored Aug 18, 2024
2 parents c7d2e6d + 567884e commit f164aee
Show file tree
Hide file tree
Showing 7 changed files with 2,824 additions and 4 deletions.
30 changes: 30 additions & 0 deletions components/ScalarAPIReference.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { ApiReferenceReact } from '@scalar/api-reference-react';
import '@scalar/api-reference-react/style.css';

/**
* This is a React component that renders the Pulsate API reference.
* It uses the `ApiReferenceReact` component from the `@scalar/api-reference-react` package.
*
* Nextra cannot properly read TSX files configured as pages, so what should be used as pages are component and imported into MDX.
* A warning message by autoprefixer is displayed, but since it is not an error, it is ignored here.
*
* @return The API reference component.
*/
export default function ScalarAPIReference() {
// https://github.com/scalar/scalar/blob/main/documentation/configuration.md
return (
<ApiReferenceReact
configuration={{
isEditable: false,
darkMode: true,
hideDarkModeToggle: true,
searchHotKey: 's',
theme: 'bluePlanet',
// TODO: Support testing the API reference with a staring server
spec: {
url: 'https://raw.githubusercontent.com/pulsate-dev/pulsate/main/resources/schema.json',
},
}}
/>
);
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"postinstall": "lefthook install"
},
"dependencies": {
"@scalar/api-reference-react": "^0.3.79",
"@scalar/nextjs-api-reference": "^0.4.79",
"next": "^14.2.5",
"nextra": "^2.13.4",
"nextra-theme-docs": "^2.13.4",
Expand Down
8 changes: 8 additions & 0 deletions pages/_meta.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,13 @@
"title": "Roadmap",
"type": "page",
"display": "hidden"
},
"api": {
"title": "API Reference",
"type": "page",
"display": "hidden",
"theme": {
"layout": "raw"
}
}
}
18 changes: 18 additions & 0 deletions pages/_meta.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,23 @@
"title": "ロードマップ",
"type": "page",
"display": "hidden"
},
"api": {
"title": "API リファレンス",
"type": "page",
"display": "hidden",
"theme": {
"layout": "raw"
}
},
"other": {
"title": "その他",
"type": "menu",
"items": {
"api-reference": {
"title": "Pulsate API Document",
"href": "/api"
}
}
}
}
3 changes: 3 additions & 0 deletions pages/api.ja.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ScalarAPIReference from "../components/ScalarAPIReference";

<ScalarAPIReference />
Loading

0 comments on commit f164aee

Please sign in to comment.