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