Skip to content

Commit

Permalink
gh-pages + google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Cattn committed Mar 11, 2024
1 parent 25a66b8 commit 6564e37
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 12 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy to GitHub Pages

on:
push:
branches: 'svelte'

jobs:
build_site:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

# If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`
# - name: Install pnpm
# uses: pnpm/action-setup@v3
# with:
# version: 8
# - name: Change directory to subdir
# run: cd gba2.0

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm install

- name: build
env:
BASE_PATH: '/${{ github.event.repository.name }}'
run: |
npm run build
- name: Upload Artifacts
uses: actions/upload-pages-artifact@v3
with:
# this should match the `pages` option in your adapter-static options
path: 'build/'

deploy:
needs: build_site
runs-on: ubuntu-latest

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v4
33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-cloudflare": "^4.1.0",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@types/eslint": "^8.56.0",
"@types/gtag.js": "^0.0.19",
"@types/node": "^20.11.25",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"autoprefixer": "^10.4.16",
Expand Down
17 changes: 17 additions & 0 deletions src/lib/components/Analytics.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<svelte:head>
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-PEYFB861NV">
</script>
<script>
window.dataLayer = window.dataLayer || []
function gtag() {
dataLayer.push(arguments)
}
gtag('js', new Date())
gtag('config', 'G-PEYFB861NV')
</script>
</svelte:head>

1 change: 1 addition & 0 deletions src/routes/+layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const prerender = true;
4 changes: 3 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import { Button } from "$lib/components/ui/button";
import * as Card from "$lib/components/ui/card/index.js";
import Analytics from "$lib/components/Analytics.svelte";
</script>

<Analytics />
<div class="flex align-center justify-center mt-12">
<img
src={MSG_Logo}
Expand Down
7 changes: 5 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import adapter from '@sveltejs/adapter-cloudflare';
// import adapter from '@sveltejs/adapter-cloudflare';
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
Expand All @@ -12,12 +13,14 @@ const config = {
routes: {
include: ['/*'],
exclude: ['<all>']
}
},
fallback: '404.html',
}),
},
paths: {
"$lib": ["./src/lib"],
"$lib/*": ["./src/lib/*"],
base: process.argv.includes('dev') ? '' : process.env.BASE_PATH
},
alias: {
lib: "src/lib",
Expand Down
11 changes: 2 additions & 9 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}

// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

0 comments on commit 6564e37

Please sign in to comment.