Skip to content

Commit f072d42

Browse files
committed
feat: gitpages
1 parent 26dd5a3 commit f072d42

File tree

9 files changed

+108
-34
lines changed

9 files changed

+108
-34
lines changed

.github/workflows/deploy.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: 'main'
6+
7+
jobs:
8+
build_site:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
# If you're using pnpm, add this step then change the commands and cache key below to use `pnpm`
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v3
17+
with:
18+
version: 8
19+
20+
- name: Install Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 20
24+
cache: pnpm
25+
26+
- name: Install dependencies
27+
run: pnpm install
28+
29+
- name: build
30+
env:
31+
BASE_PATH: '/${{ github.event.repository.name }}'
32+
run: |
33+
pnpm run build
34+
35+
- name: Upload Artifacts
36+
uses: actions/upload-pages-artifact@v3
37+
with:
38+
# this should match the `pages` option in your adapter-static options
39+
path: 'build/'
40+
41+
deploy:
42+
needs: build_site
43+
runs-on: ubuntu-latest
44+
45+
permissions:
46+
pages: write
47+
id-token: write
48+
49+
environment:
50+
name: github-pages
51+
url: ${{ steps.deployment.outputs.page_url }}
52+
53+
steps:
54+
- name: Deploy
55+
id: deployment
56+
uses: actions/deploy-pages@v4

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"devDependencies": {
1515
"@skeletonlabs/skeleton": "2.9.0",
1616
"@skeletonlabs/tw-plugin": "0.3.1",
17-
"@sveltejs/adapter-auto": "^3.0.0",
17+
"@sveltejs/adapter-static": "^3.0.1",
1818
"@sveltejs/kit": "^2.0.0",
1919
"@sveltejs/vite-plugin-svelte": "^3.0.0",
2020
"@types/eslint": "^8.56.0",

pnpm-lock.yaml

+5-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/synth.svelte

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<script lang="ts">
2-
let voices = 1;
2+
import * as Tone from 'tone';
3+
4+
import { onMount } from 'svelte';
35
import Voice from '$lib/voice.svelte';
6+
7+
let voices = 1;
8+
9+
onMount(() => {
10+
Tone.start();
11+
});
412
</script>
513

614
<div class="space-y-4">

src/lib/voice.svelte

+17-13
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
<script lang="ts">
22
import { onMount } from 'svelte';
33
import * as Tone from 'tone';
4-
import Volume from './volume.svelte';
5-
import Frequency from './frequency.svelte';
4+
import Volume from '$lib/volume.svelte';
5+
import Frequency from '$lib/frequency.svelte';
66
77
export let volume = -100;
88
export let frequency = 440;
99
10-
let osc: Tone.Oscillator | null = null;
10+
let osc: Tone.Oscillator | undefined = undefined;
11+
12+
$: status = '';
13+
// $: status = osc?.state == 'started' ? '⏹' : '▶';
1114
12-
$: status = osc?.state == 'started' ? '' : '';
1315
onMount(() => {
14-
Tone.start();
15-
osc = new Tone.Oscillator(frequency, 'sine').toDestination();
16-
osc.volume.value = volume;
16+
if (osc) return;
17+
import('tone').then((Tone) => {
18+
osc = new Tone.Oscillator(frequency, 'sine').toDestination();
19+
osc.volume.value = volume;
20+
});
1721
});
1822
1923
const toggleOsc = () => {
@@ -29,11 +33,11 @@
2933
{status}
3034
</button>
3135

32-
<!-- {#if osc.state === 'started'} -->
33-
<div class="space-y-2 w-full">
34-
<Volume {osc} bind:volume />
35-
<Frequency {osc} bind:frequencyValue={frequency} />
36-
</div>
37-
<!-- {/if} -->
36+
{#if osc.state === 'started'}
37+
<div class="space-y-2 w-full">
38+
<Volume {osc} bind:volume />
39+
<Frequency {osc} bind:frequencyValue={frequency} />
40+
</div>
41+
{/if}
3842
{/if}
3943
</div>

src/routes/+layout.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const prerender = true;
2+
export const ssr = false;

src/routes/+page.svelte

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<script lang="ts">
2+
let start = false;
23
import Synth from '$lib/synth.svelte';
34
</script>
45

5-
<div class="p-4 w-full">
6-
<Synth />
6+
<div class="p-4 w-full space-y-4">
7+
<button class="btn variant-ghost w-full" on:click={() => (start = !start)}
8+
>{start ? 'Stop' : 'Start'}</button
9+
>
10+
{#if start}
11+
<Synth />
12+
{/if}
713
</div>

static/.nojekyll

Whitespace-only changes.

svelte.config.js

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
import adapter from '@sveltejs/adapter-auto';
1+
import adapter from '@sveltejs/adapter-static';
22
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
33

44
/** @type {import('@sveltejs/kit').Config} */
55
const config = {
6-
extensions: ['.svelte'],
7-
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
8-
// for more information about preprocessors
9-
preprocess: [vitePreprocess()],
10-
6+
preprocess: vitePreprocess(),
117
kit: {
12-
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
13-
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
14-
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
15-
adapter: adapter()
8+
adapter: adapter({
9+
fallback: '404.html'
10+
}),
11+
paths: {
12+
base: process.argv.includes('dev') ? '' : process.env.BASE_PATH
13+
}
1614
}
1715
};
18-
export default config;
16+
17+
export default config;

0 commit comments

Comments
 (0)