Skip to content

Commit e6ee135

Browse files
committed
Add TS playgrounds to docusaurus.new + Playground page
1 parent fabf053 commit e6ee135

4 files changed

Lines changed: 39 additions & 4 deletions

File tree

admin/new.docusaurus.io/functionUtils/playgroundUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ const CookieName = 'DocusaurusPlaygroundName';
1212
const PlaygroundConfigs = {
1313
codesandbox:
1414
'https://codesandbox.io/p/sandbox/github/facebook/docusaurus/tree/main/examples/classic?file=%2FREADME.md',
15+
'codesandbox-ts':
16+
'https://codesandbox.io/p/sandbox/github/facebook/docusaurus/tree/main/examples/classic-typescript?file=%2FREADME.md',
1517

16-
// Not updated
17-
// stackblitz: 'https://stackblitz.com/fork/docusaurus',
1818
// Slow to load
1919
// stackblitz: 'https://stackblitz.com/github/facebook/docusaurus/tree/main/examples/classic',
2020
// Dedicated branch: faster load
2121
stackblitz: 'https://stackblitz.com/github/facebook/docusaurus/tree/starter',
22+
'stackblitz-ts':
23+
'https://stackblitz.com/github/facebook/docusaurus/tree/main/examples/classic-typescript',
2224
};
2325

2426
const PlaygroundDocumentationUrl = 'https://docusaurus.io/docs/playground';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';
9+
import type {Handler} from '@netlify/functions';
10+
11+
export const handler: Handler = () =>
12+
Promise.resolve(createPlaygroundResponse('codesandbox-ts'));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
import {createPlaygroundResponse} from '../functionUtils/playgroundUtils';
9+
import type {Handler} from '@netlify/functions';
10+
11+
export const handler: Handler = () =>
12+
Promise.resolve(createPlaygroundResponse('stackblitz-ts'));

website/src/components/Playground/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const Playgrounds = [
1919
name: '📦 CodeSandbox',
2020
image: require('@site/static/img/playgrounds/codesandbox.png'),
2121
url: 'https://docusaurus.new/codesandbox',
22+
urlTS: 'https://docusaurus.new/codesandbox-ts',
2223
description: (
2324
<Translate id="playground.codesandbox.description">
2425
CodeSandbox is an online code editor and development environment that
@@ -31,6 +32,7 @@ const Playgrounds = [
3132
name: '⚡ StackBlitz 🆕',
3233
image: require('@site/static/img/playgrounds/stackblitz.png'),
3334
url: 'https://docusaurus.new/stackblitz',
35+
urlTS: 'https://docusaurus.new/stackblitz-ts',
3436
description: (
3537
<Translate
3638
id="playground.stackblitz.description"
@@ -53,10 +55,11 @@ interface Props {
5355
name: string;
5456
image: string;
5557
url: string;
58+
urlTS: string;
5659
description: JSX.Element;
5760
}
5861

59-
function PlaygroundCard({name, image, url, description}: Props) {
62+
function PlaygroundCard({name, image, url, urlTS, description}: Props) {
6063
return (
6164
<div className="col col--6 margin-bottom--lg">
6265
<div className={clsx('card')}>
@@ -70,9 +73,15 @@ function PlaygroundCard({name, image, url, description}: Props) {
7073
<p>{description}</p>
7174
</div>
7275
<div className="card__footer">
76+
<b>
77+
<Translate id="playground.tryItButton">Try it now!</Translate>
78+
</b>
7379
<div className="button-group button-group--block">
7480
<Link className="button button--secondary" to={url}>
75-
<Translate id="playground.tryItButton">Try it now!</Translate>
81+
JavaScript
82+
</Link>
83+
<Link className="button button--secondary" to={urlTS}>
84+
TypeScript
7685
</Link>
7786
</div>
7887
</div>

0 commit comments

Comments
 (0)