Skip to content

Commit 94947c6

Browse files
committed
fix: use the default Docusaurus CodeBlock for the /api and /sdk pages
1 parent 50857d0 commit 94947c6

File tree

3 files changed

+25
-23
lines changed

3 files changed

+25
-23
lines changed

apify-docs-theme/src/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const themeConfig = ({
152152
defaultLanguage: 'typescript',
153153
theme: require('prism-react-renderer').themes.github,
154154
darkTheme: require('prism-react-renderer').themes.dracula,
155-
additionalLanguages: ['docker', 'log', 'php', 'json5'],
155+
additionalLanguages: ['docker', 'log', 'php', 'json5', 'bash'],
156156
},
157157
// this needs to be absolute link otherwise it gets resolved wrongly in project docs
158158
image: 'https://apify.com/og-image/docs-article',

src/components/SdkSection/SdkSection.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { ActionLink, Button, CodeBlock, theme } from '@apify-packages/ui-library';
1+
import { ActionLink, Button, theme } from '@apify-packages/ui-library';
22
import { useColorMode } from '@docusaurus/theme-common';
33
import useBaseUrl from '@docusaurus/useBaseUrl';
4+
import CodeBlock from '@theme/CodeBlock';
45
import ThemedImage from '@theme/ThemedImage';
56
import React from 'react';
67
import GitHubButton from 'react-github-btn';
@@ -111,8 +112,12 @@ export default function SdkSection({
111112
</div>
112113
</div>
113114
<div className="SdkSectionCodeExamples">
114-
<CodeBlock language="bash" content={installCodeSnippet} fullHeight />
115-
<CodeBlock language={lowerCaseLanguage} hideLineNumbers content={exampleCodeSnippet} />
115+
<CodeBlock language="bash">
116+
{installCodeSnippet}
117+
</CodeBlock>
118+
<CodeBlock language={lowerCaseLanguage}>
119+
{exampleCodeSnippet}
120+
</CodeBlock>
116121
</div>
117122
</StyledSdkSection>
118123
);

src/pages/api/index.tsx

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import {
22
ActionLink,
33
BlogArticle,
44
Button,
5-
CodeBlock,
65
theme,
76
} from '@apify-packages/ui-library';
87
import Link from '@docusaurus/Link';
98
import useBaseUrl from '@docusaurus/useBaseUrl';
9+
import CodeBlock from '@theme/CodeBlock';
1010
import Layout from '@theme/Layout';
1111
import ThemedImage from '@theme/ThemedImage';
1212
import React from 'react';
@@ -135,9 +135,8 @@ export default function Api() {
135135
</div>
136136
</div>}
137137
>
138-
<ClientCodeWrapper>
139-
<CodeBlock content={[{ key: 'cURL', label: 'cURL', language: 'bash', code: `
140-
# Prepare Actor input
138+
<CodeBlock title="cURL" language='bash'>
139+
{`# Prepare Actor input
141140
cat > input.json <<'EOF'
142141
{
143142
// Define the input in JSON here
@@ -151,8 +150,9 @@ curl "https://api.apify.com/v2/acts/username~actorname/runs?token=<YOUR_API_TOKE
151150
-H 'Content-Type: application/json'
152151
153152
# Use the defaultDatasetId from response and pass it instead of <DATASET_ID>
154-
curl "https://api.apify.com/v2/datasets/<DATASET_ID>/items?token=<YOUR_API_TOKEN>"` }]} hideBashPromptPrefixes hideLineNumbers defaultTabKey="cURL" />
155-
</ClientCodeWrapper>
153+
curl "https://api.apify.com/v2/datasets/<DATASET_ID>/items?token=<YOUR_API_TOKEN>"`
154+
}
155+
</CodeBlock>
156156
</SectionWrapper>
157157
<Section
158158
headingClassName={styles.ApiSectionHeading}
@@ -184,12 +184,13 @@ curl "https://api.apify.com/v2/datasets/<DATASET_ID>/items?token=<YOUR_API_TOKEN
184184
</div>}
185185
>
186186
<ClientCodeWrapper>
187-
<CodeBlock content='npm install apify-client' language="bash"/>
187+
<CodeBlock language="bash">
188+
npm install apify-client
189+
</CodeBlock>
188190
<CodeBlock
189191
language='javascript'
190-
hideLineNumbers
191-
content={`
192-
// Easily run Actors, await them to finish using the convenient .call() method, and retrieve results from the resulting dataset.
192+
// eslint-disable-next-line max-len
193+
>{`// Easily run Actors, await them to finish using the convenient .call() method, and retrieve results from the resulting dataset.
193194
const { ApifyClient } = require('apify-client');
194195
195196
const client = new ApifyClient({
@@ -200,8 +201,8 @@ const client = new ApifyClient({
200201
const { defaultDatasetId } = await client.actor('john-doe/my-cool-actor').call();
201202
202203
// Fetches results from the actor's dataset.
203-
const { items } = await client.dataset(defaultDatasetId).listItems();
204-
`}/>
204+
const { items } = await client.dataset(defaultDatasetId).listItems();`}
205+
</CodeBlock>
205206
</ClientCodeWrapper>
206207
</SectionWrapper>
207208
),
@@ -228,22 +229,18 @@ const { items } = await client.dataset(defaultDatasetId).listItems();
228229
</div>}
229230
>
230231
<ClientCodeWrapper>
231-
<CodeBlock content='pip install apify-client' language="bash"/>
232+
<CodeBlock language="bash">pip install apify-client</CodeBlock>
232233
<CodeBlock
233-
className="codeBlock"
234234
language='python'
235-
hideLineNumbers
236-
content={`
237-
from apify_client import ApifyClient
235+
>{`from apify_client import ApifyClient
238236
239237
apify_client = ApifyClient('MY-APIFY-TOKEN')
240238
241239
# Start an actor and wait for it to finish
242240
actor_call = apify_client.actor('john-doe/my-cool-actor').call()
243241
244242
# Fetch results from the actor run's default dataset
245-
dataset_items = apify_client.dataset(actor_call['defaultDatasetId']).list_items().items
246-
`}/></ClientCodeWrapper>
243+
dataset_items = apify_client.dataset(actor_call['defaultDatasetId']).list_items().items`}</CodeBlock></ClientCodeWrapper>
247244
</SectionWrapper>
248245
),
249246
},

0 commit comments

Comments
 (0)