Skip to content

Commit 9b5bec7

Browse files
website
1 parent c745845 commit 9b5bec7

File tree

21 files changed

+389
-0
lines changed

21 files changed

+389
-0
lines changed

.github/workflows/nextjs.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
- name: npm
24+
id: install-npm
25+
run: npm i
26+
- name: Detect package manager
27+
id: detect-package-manager
28+
run: |
29+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
30+
echo "manager=yarn" >> $GITHUB_OUTPUT
31+
echo "command=install" >> $GITHUB_OUTPUT
32+
echo "runner=yarn" >> $GITHUB_OUTPUT
33+
exit 0
34+
elif [ -f "${{ github.workspace }}/package.json" ]; then
35+
echo "manager=npm" >> $GITHUB_OUTPUT
36+
echo "command=ci" >> $GITHUB_OUTPUT
37+
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
38+
exit 0
39+
else
40+
echo "Unable to determine package manager"
41+
exit 1
42+
fi
43+
- name: Setup Node
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: "20"
47+
cache: ${{ steps.detect-package-manager.outputs.manager }}
48+
- name: Setup Pages
49+
uses: actions/configure-pages@v5
50+
with:
51+
static_site_generator: next
52+
- name: Restore cache
53+
uses: actions/cache@v4
54+
with:
55+
path: |
56+
.next/cache
57+
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
58+
restore-keys: |
59+
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
60+
- name: Install dependencies
61+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
62+
- name: Build with Next.js
63+
run: ${{ steps.detect-package-manager.outputs.runner }} next build
64+
- name: Override with _just
65+
uses: js-just/latest@main
66+
- name: Move id to deploy
67+
run: mv id deploy/id
68+
- name: Upload artifact
69+
uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: deploy
72+
73+
deploy:
74+
environment:
75+
name: github-pages
76+
url: ${{ steps.deployment.outputs.page_url }}
77+
runs-on: ubuntu-latest
78+
needs: build
79+
steps:
80+
- name: Deploy to GitHub Pages
81+
id: deployment
82+
uses: actions/deploy-pages@v4

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"git.enabled": false
3+
}

404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Service Unavailable

_just/404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Not Found

_just/dangerously-insert-files/robots.txt

Whitespace-only changes.

_just/js/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log('demo');

_just/style/empty.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* nothing here */

global-context.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { createContext, useMemo, useContext, useState, useEffect } from 'react'
2+
import { useLocale } from "next-intl";
3+
4+
const GlobalContext = createContext(null)
5+
6+
export const GlobalProvider = ({ initialLocales, children }) => {
7+
const localeValue = useLocale()
8+
const [locales, setLocales] = useState(initialLocales ?? [{"name":"English","short":"en"}, {"name":"Russian","short":"ru"}])
9+
const [locale, setLocale] = useState({"name":"English","short":"en"})
10+
11+
useEffect(() => {
12+
if (!locales) {
13+
return
14+
}
15+
16+
const currentLangValue = locales.find((el) => el.short === localeValue)
17+
setLocale(currentLangValue)
18+
}, [locales])
19+
20+
const value = useMemo(() => {
21+
return {
22+
locales,
23+
locale,
24+
setLocales,
25+
setLocale
26+
}
27+
}, [locales, locale])
28+
29+
return (
30+
<GlobalContext.Provider value={value}>
31+
{children}
32+
</GlobalContext.Provider>
33+
)
34+
}
35+
36+
export const useGlobalContext = () => {
37+
const context = useContext(GlobalContext)
38+
if (!context) {
39+
throw new Error('useGlobalContext must be used within a GlobalProvider')
40+
}
41+
42+
return {
43+
...context
44+
}
45+
}

id/404.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Not Found

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Service Unavailable

0 commit comments

Comments
 (0)