From 9fde1d00f0ea14b0908f1c55ad61db8e33409ae4 Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Mon, 11 Mar 2024 17:59:58 -0700 Subject: [PATCH] github pages example --- .github/workflows/deploy.yml | 50 ++++++++++++++++++++++++++++++++++++ README.md | 3 +-- app.config.ts | 6 ++++- src/app.tsx | 3 +++ src/components/comment.tsx | 3 ++- src/components/nav.tsx | 26 ++++++++++--------- src/routes/[...stories].tsx | 9 ++++--- src/routes/stories/[id].tsx | 7 ++--- 8 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..e8bdcfa --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,50 @@ +# https://github.com/actions/deploy-pages#usage +name: Deploy to GitHub Pages + +on: + workflow_dispatch: + push: + branches: + - github-pages + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: corepack enable + - uses: actions/setup-node@v3 + with: + node-version: "18" + + - run: pnpm install + - run: BASE_URL="/solid-hackernews" pnpm run build + env: + NITRO_PRESET: github_pages + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: ./.output/public + + # Deployment job + deploy: + # Add a dependency to the build job + needs: build + + # Grant GITHUB_TOKEN the permissions required to make a Pages deployment + permissions: + pages: write # to deploy to Pages + id-token: write # to verify the deployment originates from an appropriate source + + # Deploy to the github_pages environment + environment: + name: github_pages + url: ${{ steps.deployment.outputs.page_url }} + + # Specify runner + deployment step + runs-on: ubuntu-latest + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 \ No newline at end of file diff --git a/README.md b/README.md index 9a4ad0e..3a0e38e 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ Demo app based on [Vue Hackernews 2.0](https://github.com/vuejs/vue-hackernews-2.0). It is powered by [`solid-start`](https://github.com/solidjs/solid-start); You can view it on: -[Netlify Functions](https://solid-start-hn.netlify.app/). -[Netlify Edge](https://solid-hackernews-edge.netlify.app/). +[Github Pages](https://solidjs.github.io/solid-hackernews/). ## Developing diff --git a/app.config.ts b/app.config.ts index 4cd6b82..fb79b12 100644 --- a/app.config.ts +++ b/app.config.ts @@ -1,7 +1,11 @@ import { defineConfig } from "@solidjs/start/config"; +const baseURL = process.env.BASE_URL || ""; + export default defineConfig({ + ssr: false, server: { - preset: "netlify", + preset: "github_pages", + baseURL, }, }); diff --git a/src/app.tsx b/src/app.tsx index fd368bb..e551624 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,9 +5,12 @@ import { Suspense } from "solid-js"; import "./app.css"; import Nav from "./components/nav"; +const base = import.meta.env.SERVER_BASE_URL; + export default function App() { return ( ( <>