feat: extend code snippet to support method
This commit is contained in:
@@ -120,4 +120,24 @@
|
||||
border-left: 1px solid #e3e8ee;
|
||||
opacity: .2;
|
||||
margin-right: -1px;
|
||||
}
|
||||
|
||||
.get {
|
||||
color: #61affe;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.post {
|
||||
color: #49cc90;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.put {
|
||||
color: #fca130;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.delete {
|
||||
color: #f93e3e;
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -105,13 +105,22 @@ function SnippetLanguageDropdown({
|
||||
|
||||
export default function CodeSnippet({
|
||||
children,
|
||||
method,
|
||||
heading,
|
||||
defaultLanguage,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
method?: string;
|
||||
heading: string;
|
||||
defaultLanguage: string;
|
||||
}) {
|
||||
const methodStyles: { [key: string]: string } = {
|
||||
GET: styles.get,
|
||||
POST: styles.post,
|
||||
PUT: styles.put,
|
||||
DELETE: styles.delete,
|
||||
};
|
||||
|
||||
const [selectedLanguage, setSelectedLanguage] =
|
||||
useState<string>(defaultLanguage);
|
||||
|
||||
@@ -137,7 +146,14 @@ export default function CodeSnippet({
|
||||
return (
|
||||
<div className={styles.snippetContainer}>
|
||||
<div className={styles.snippetHeader}>
|
||||
<div>{heading}</div>
|
||||
<div>
|
||||
{method ? (
|
||||
<span className={methodStyles[method]}>
|
||||
{method}
|
||||
</span>
|
||||
) : null}{' '}
|
||||
{heading}
|
||||
</div>
|
||||
<div className={styles.controlsContainer}>
|
||||
{snippetLanguages.length > 1 ? (
|
||||
<>
|
||||
|
||||
@@ -61,6 +61,9 @@ const markDocConfig = {
|
||||
defaultLanguage: {
|
||||
type: 'string',
|
||||
},
|
||||
method: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Retrieving a record from an app
|
||||
|
||||
{% code heading="GET /Records/appId/{appID}/recordId/{recordID}" defaultLanguage="bash" %}
|
||||
{% code method="GET" heading="/Records/appId/{appID}/recordId/{recordID}" defaultLanguage="bash" %}
|
||||
|
||||
```bash
|
||||
curl --location 'https://api.onspring.com/Records/appId/195/recordId/1' \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Retrieving records for an app
|
||||
|
||||
{% code heading="GET /Records/appId/{appID}" defaultLanguage="bash" %}
|
||||
{% code method="GET" heading="/Records/appId/{appID}" defaultLanguage="bash" %}
|
||||
|
||||
```bash
|
||||
curl --location 'https://api.onspring.com/Records/appId/195' \
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Retrieving a batch of records
|
||||
|
||||
{% code heading="POST /Records/batch-get" defaultLanguage="bash" %}
|
||||
{% code method="POST" heading="/Records/batch-get" defaultLanguage="bash" %}
|
||||
|
||||
```bash
|
||||
curl --location 'https://api.onspring.com/Records/batch-get' \
|
||||
|
||||
Reference in New Issue
Block a user