Skip to content

Commit 1165162

Browse files
authored
Merge pull request #275 from blueshift-gg/dynamic-mdx-loading
feat: dynamic mdx loading
2 parents 8fc66db + 63ab6be commit 1165162

File tree

40 files changed

+24286
-28740
lines changed

40 files changed

+24286
-28740
lines changed

.github/workflows/deploy.yaml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- master
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
deployments: write
11+
12+
jobs:
13+
deploy:
14+
runs-on: ubuntu-latest
15+
timeout-minutes: 15
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 2
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v4
24+
with:
25+
version: 10
26+
run_install: false
27+
28+
- name: Install Node.js
29+
uses: actions/setup-node@v6
30+
with:
31+
node-version: 24
32+
cache: 'pnpm'
33+
34+
- name: Cache Next.js
35+
uses: actions/cache@v4
36+
with:
37+
path: ${{ github.workspace }}/.next/cache
38+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
39+
restore-keys: |
40+
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
41+
42+
- name: Cache Compiled MDX
43+
uses: actions/cache@v4
44+
with:
45+
path: ${{ github.workspace }}/.compiled-mdx
46+
key: ${{ runner.os }}-compiled-mdx-${{ hashFiles('src/app/content/**/*.mdx', 'src/lib/shiki/*.json') }}
47+
restore-keys: |
48+
${{ runner.os }}-compiled-mdx-
49+
50+
- name: Install dependencies
51+
run: pnpm install --frozen-lockfile
52+
53+
- name: Precompile MDX
54+
run: pnpm precompile-mdx
55+
56+
- name: Upload Compiled MDX to R2
57+
env:
58+
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
59+
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
60+
ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com
61+
COMPILED_DIR: .compiled-mdx
62+
CONTENT_DIR: src/app/content
63+
run: |
64+
# Size-only sync first (handles new files, size changes, and deletions efficiently)
65+
aws s3 sync "$COMPILED_DIR/" "s3://${{ secrets.R2_BUCKET }}/compiled-mdx" \
66+
--endpoint-url "$ENDPOINT" \
67+
--no-progress \
68+
--size-only \
69+
--delete \
70+
--content-type "application/json"
71+
72+
# Then force-upload any files changed in this commit (catches same-size content edits)
73+
# Skip if this is the first commit
74+
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
75+
changed_files=$(git diff --name-only --diff-filter=ACM HEAD^ "$CONTENT_DIR/" | grep '\.mdx$' || echo "")
76+
77+
for file in $changed_files; do
78+
# Convert .mdx path to .json path in compiled directory
79+
relative_path="${file#$CONTENT_DIR/}"
80+
json_path="${relative_path%.mdx}.json"
81+
compiled_file="$COMPILED_DIR/$json_path"
82+
83+
if [ -f "$compiled_file" ]; then
84+
aws s3 cp "$compiled_file" "s3://${{ secrets.R2_BUCKET }}/compiled-mdx/$json_path" \
85+
--endpoint-url "$ENDPOINT" \
86+
--no-progress \
87+
--content-type "application/json"
88+
fi
89+
done
90+
fi
91+
92+
- name: Build
93+
env:
94+
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
95+
NEXT_PUBLIC_CHALLENGE_SECRET: ${{ secrets.NEXT_PUBLIC_CHALLENGE_SECRET }}
96+
NEXT_PUBLIC_CHALLENGE_RPC_ENDPOINT: ${{ secrets.NEXT_PUBLIC_CHALLENGE_RPC_ENDPOINT }}
97+
CERTIFICATION_MINTER_PROGRAM_ID: ${{ secrets.CERTIFICATION_MINTER_PROGRAM_ID }}
98+
NEXT_PUBLIC_RPC_ENDPOINT: ${{ secrets.NEXT_PUBLIC_RPC_ENDPOINT }}
99+
NEXT_PUBLIC_TWITTER_LINK: ${{ secrets.NEXT_PUBLIC_TWITTER_LINK }}
100+
NEXT_PUBLIC_GITHUB_LINK: ${{ secrets.NEXT_PUBLIC_GITHUB_LINK }}
101+
NEXT_PUBLIC_DISCORD_LINK: ${{ secrets.NEXT_PUBLIC_DISCORD_LINK }}
102+
NEXT_PUBLIC_STAKING_URL: ${{ secrets.NEXT_PUBLIC_STAKING_URL }}
103+
run: pnpm exec opennextjs-cloudflare build
104+
105+
- name: Deploy
106+
uses: cloudflare/wrangler-action@v3
107+
with:
108+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
109+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
110+
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ next-env.d.ts
5151
# Editor and IDE configs
5252
.idea
5353
i18n.cache
54+
55+
# Compiled MDX
56+
.compiled-mdx

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
24

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This is the frontend for [Blueshift](https://learn.blueshift.gg).
55
First, run the development server:
66

77
```bash
8-
npm install
9-
npm run dev
8+
pnpm install
9+
pnpm dev
1010
```
1111

1212
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

0 commit comments

Comments
 (0)