Skip to content

Commit 92ffd7a

Browse files
committed
Set up Formideploy for docs
1 parent adaefa5 commit 92ffd7a

File tree

5 files changed

+937
-37
lines changed

5 files changed

+937
-37
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Deploy Docs Site
2+
3+
on:
4+
push:
5+
paths:
6+
- 'docs/**'
7+
- 'website/**'
8+
pull_request:
9+
branches:
10+
- 'master'
11+
paths:
12+
- 'docs/**'
13+
- 'website/**'
14+
15+
jobs:
16+
deploy-website:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: 16
24+
cache: 'yarn'
25+
26+
- name: AWS CLI version
27+
run: "aws --version"
28+
29+
- name: Install Dependencies
30+
run: yarn install --frozen-lockfile
31+
working-directory: ./website
32+
33+
- name: Build the website
34+
run: yarn build
35+
working-directory: ./website
36+
37+
# Use `gh` tool to infer more information about the pull request.
38+
# The underlying issue here is pushes to a non-mergeable/main target branch
39+
# don't have the PR number easily available.
40+
# https://stackoverflow.com/a/70102700
41+
- name: Get pull request info
42+
id: pr_info
43+
run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")"
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Deploy docs (production)
48+
if: github.ref == 'refs/heads/main'
49+
run: yarn deploy:prod
50+
working-directory: ./website
51+
env:
52+
GITHUB_DEPLOYMENT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
54+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

docs/introduction.mdx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { DemoLiveEditor } from "../website/src/components/live-edit";
77

88
# Introduction
99

10+
[![React Live — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/react-live/master/react-live-Hero.png)](https://formidable.com/open-source/)
11+
1012
**React Live** brings you the ability to render React components with editable source code and live preview. React Live is structured modularly and lets you style and compose its components freely. The following demos show typical use cases including the editor, preview, and error pane components.
1113

1214
To see React Live in action, make changes to the following editor panes:
@@ -33,9 +35,12 @@ export const jsxExample = `
3335
To render a series of components or render components beyond just JSX, React Live also provides a `render` function to pass JSX into when the `noInline` prop is present. This lets you render multiple or functional components with hooks. This example shows a functional component with a `useState` hook.
3436

3537
export const noInlineExample = `
36-
const Counter = () => {
38+
type Props = {
39+
label: string;
40+
}
41+
const Counter = (props: Props) => {
3742
const [count, setCount] =
38-
React.useState(0)
43+
React.useState<number>(0)
3944
return (
4045
<div>
4146
<h3 style={{
@@ -44,7 +49,7 @@ const Counter = () => {
4449
padding: 8,
4550
borderRadius: 4
4651
}}>
47-
Counter: {count} 🧮
52+
{props.label}: {count} 🧮
4853
</h3>
4954
<button
5055
onClick={() =>
@@ -55,7 +60,7 @@ const Counter = () => {
5560
</div>
5661
)
5762
}
58-
render(<Counter />)
63+
render(<Counter label="Counter" />)
5964
`.trim();
6065

6166
<DemoLiveEditor code={noInlineExample} noInline />

website/formideploy.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
lander: {
3+
name: "react-live",
4+
},
5+
build: {
6+
// Build output directory.
7+
// Docusaurus defaults to `build`.
8+
// We use `docusaurus build --out-dir build/open-source/docusaurus` to build intermediate real dirs.
9+
dir: "build",
10+
},
11+
};

website/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"serve": "docusaurus serve",
1313
"write-translations": "docusaurus write-translations",
1414
"write-heading-ids": "docusaurus write-heading-ids",
15-
"typecheck": "tsc"
15+
"typecheck": "tsc",
16+
"deploy:prod": "formideploy deploy --production"
1617
},
1718
"dependencies": {
1819
"@docusaurus/core": "2.4.0",
@@ -24,12 +25,13 @@
2425
"prism-react-renderer": "^1.3.5",
2526
"react": "^17.0.2",
2627
"react-dom": "^17.0.2",
27-
"react-live": "^3.2.0",
28+
"react-live": "^4.0.0",
2829
"tailwindcss": "^3.2.7"
2930
},
3031
"devDependencies": {
3132
"@docusaurus/module-type-aliases": "2.4.0",
3233
"@tsconfig/docusaurus": "^1.0.5",
34+
"formideploy": "^0.4.2",
3335
"typescript": "^4.7.4"
3436
},
3537
"browserslist": {

0 commit comments

Comments
 (0)