From 9d375bafe61910a243ef04b017328f1cd3e9fa73 Mon Sep 17 00:00:00 2001 From: para7 Date: Tue, 10 Dec 2024 14:11:24 +0900 Subject: [PATCH] =?UTF-8?q?work:=20github=20pages=20=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/actions.yml | 11 +++----- .github/workflows/deploy.yml | 53 +++++++++++++++++++++++++++++++++++ src/lib/ROUTES.ts | 13 +++++---- src/routes/+layout.svelte | 2 +- src/routes/about/+page.svelte | 8 +++--- svelte.config.js | 5 +++- vite.config.ts | 3 +- 7 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index ef9ac56..a2090c9 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -10,26 +10,23 @@ on: jobs: build: runs-on: ubuntu-24.04 - strategy: - matrix: - node-version: [20] steps: - uses: actions/checkout@v4 - name: Install pnpm uses: pnpm/action-setup@v4 with: version: 9 - - name: Use Node.js ${{ matrix.node-version }} + - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: ${{ matrix.node-version }} + node-version: 22 cache: 'pnpm' - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Svelte check - run: pnpm check - name: Lint run: pnpm lint + - name: Svelte check + run: pnpm check - name: Run vitest run: pnpm test run - name: Build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..f09d2bf --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,53 @@ +# Simple workflow for deploying static content to GitHub Pages +name: build and deploy + +on: + push: + branches: ['master'] + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + +jobs: + deploy: + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + - name: Install dependencies + run: pnpm install --frozen-lockfile + - name: build page + run: pnpm build + - uses: actions/upload-pages-artifact@v1 + if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'schedule' }} + with: + path: build + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/src/lib/ROUTES.ts b/src/lib/ROUTES.ts index 80c05cc..f422991 100644 --- a/src/lib/ROUTES.ts +++ b/src/lib/ROUTES.ts @@ -4,17 +4,18 @@ * * >> DO NOT EDIT THIS FILE MANUALLY << */ +import { base } from '$app/paths' /** * PAGES */ export const PAGES = { - "/": `/`, - "/about": `/about`, - "/encoder/url": `/encoder/url`, - "/formatter/json": `/formatter/json`, - "/image-converter": `/image-converter`, - "/word-count": `/word-count` + "/": `${base}/`, + "/about": `${base}/about`, + "/encoder/url": `${base}/encoder/url`, + "/formatter/json": `${base}/formatter/json`, + "/image-converter": `${base}/image-converter`, + "/word-count": `${base}/word-count` } /** diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 396d563..e77b9ee 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -21,7 +21,7 @@

- UTILITIES + UTILITIES @para7

diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index 6bc8383..8a0ad41 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -9,7 +9,7 @@ 文字数をカウントしたり、画像の形式を変換したり。

- インターネットで検索をかければ大抵欲しいツールは見つかりますが、ソースが公開されていなかったり、サーバーにデータを送っていたり。セキュリティ面の不安から利用を躊躇する場合があります。 + インターネットで検索をかければ大抵欲しいツールは見つかりますが、ソースが公開されていなかったり、サーバーにデータを送っていそうなことも多いです。セキュリティ面の不安から利用を躊躇してしまいます。

安心して使える自前のツールセットが欲しいと思ったのが、このサイトのモチベーションです。

@@ -20,7 +20,7 @@
  • 極力外部ライブラリの利用を避け、ブラウザネイティブの動作で実現する。外部ライブラリに依存している場合は明示する。
  • -
  • オープンソース TODO: githubへのリンクを張る
  • +
  • オープンソース Github
  • 問い合わせ先

    @@ -28,7 +28,7 @@

    機能追加のリクエストや不具合報告ありましたら、今は一旦 github の issue へお願いいたします。

    -

    Pull Requestも歓迎いたします。

    +

    Pull Request も歓迎です。

    サイト構成技術

    @@ -51,7 +51,7 @@ hosting - cloudflare + github pages diff --git a/svelte.config.js b/svelte.config.js index 97afdf5..8f6c049 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -19,7 +19,10 @@ const config = { fallback: undefined, precompress: false, strict: true - }) + }), + paths: { + base: '/nana-utilities' + } } // kit: { diff --git a/vite.config.ts b/vite.config.ts index d8d84ea..44d7a0f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,7 +6,8 @@ export default defineConfig({ plugins: [ kitRoutes({ generated_file_path: 'src/lib/ROUTES.ts', - format: 'object[path]' + format: 'object[path]', + path_base: true }), sveltekit() ],