Skip to content

Commit

Permalink
Adjustments to router and deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
Midlou committed Jan 15, 2024
1 parent 45af96e commit f363cd3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 63 deletions.
76 changes: 39 additions & 37 deletions .github/workflows/deploy.yml
@@ -1,49 +1,51 @@
name: Deploy
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
# Runs on pushes targeting the default branch
push:
branches:
- main
branches: ['main']

jobs:
build:
name: Build
runs-on: ubuntu-latest
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

steps:
- name: Checkout repo
uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3

- name: Install dependencies
uses: bahmutov/npm-install@v1

- name: Build project
run: npm run build
# Sets the GITHUB_TOKEN permissions to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

- name: Upload production-ready build files
uses: actions/upload-artifact@v3
with:
name: production-files
path: ./dist
# Allow one concurrent deployment
concurrency:
group: 'pages'
cancel-in-progress: true

jobs:
# Single deploy job since we're just deploying
deploy:
name: Deploy
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'

steps:
- name: Download artifact
uses: actions/download-artifact@v3
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
name: production-files
path: ./dist

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build
run: npm run build
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
# Upload dist repository
path: './dist'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
42 changes: 17 additions & 25 deletions src/main.jsx
Expand Up @@ -2,40 +2,32 @@ import React from 'react'
import ReactDOM from 'react-dom/client'
import './index.css'

import { BrowserRouter, createBrowserRouter, Route, RouterProvider, Routes, } from "react-router-dom";
import { createHashRouter, RouterProvider, } from "react-router-dom";

// Pages
import PageHome from './pages/home.jsx';
import PageProjects from './pages/projects.jsx';
import ErrorPage from './error-page.jsx';
import PageMiceblocks from './pages/projects/miceblocks.jsx';

// const router = createBrowserRouter([
// {
// path: "/",
// element: <PageHome />,
// errorElement: <ErrorPage />,
// },
// {
// path: "/projects",
// element: <PageProjects />,
// },
// {
// path: "/projects/miceblocks",
// element: <PageMiceblocks />,
// },
// ]);
const router = createHashRouter([
{
path: "/",
element: <PageHome />,
errorElement: <ErrorPage />,
},
{
path: "/projects",
element: <PageProjects />,
},
{
path: "/projects/miceblocks",
element: <PageMiceblocks />,
},
]);

ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
{/* <RouterProvider router={router} /> */}

<BrowserRouter>
<Routes>
<Route path="/" element={<PageHome />} />
<Route path="/projects" element={<PageProjects />} />
<Route path="/projects/miceblocks" element={<PageMiceblocks />} />
</Routes>
</BrowserRouter>
<RouterProvider router={router} />
</React.StrictMode>,
)
1 change: 0 additions & 1 deletion vite.config.js
Expand Up @@ -4,5 +4,4 @@ import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
base: '/'
});

0 comments on commit f363cd3

Please sign in to comment.