Skip to content

Commit 13304ae

Browse files
authored
Merge pull request #17 from kevinkace/svelte-ssg
Static site generator rewrite
2 parents e832531 + 1e38214 commit 13304ae

File tree

173 files changed

+6455
-77788
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+6455
-77788
lines changed

.github/workflows/static.yml

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,49 @@
1-
# Simple workflow for deploying static content to GitHub Pages
2-
name: Deploy static content to Pages
1+
name: Deploy SvelteKit to GitHub Pages
32

43
on:
5-
# Runs on pushes targeting the default branch
64
push:
7-
branches: ["main"]
5+
branches: [main]
86

9-
# Allows you to run this workflow manually from the Actions tab
10-
workflow_dispatch:
11-
12-
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
137
permissions:
148
contents: read
159
pages: write
1610
id-token: write
1711

18-
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19-
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20-
concurrency:
21-
group: "pages"
22-
cancel-in-progress: false
23-
12+
# 2 jobs: build the SvelteKit static site, and deploy the built site to GitHub Pages
2413
jobs:
25-
# Single deploy job since we're just deploying
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# Check out the repo code
19+
- uses: actions/checkout@v4
20+
21+
# Use the Node version defined in .nvmrc
22+
- uses: actions/setup-node@v4
23+
with:
24+
node-version-file: .nvmrc
25+
cache: npm # cache node_modules for faster builds
26+
27+
- name: Install dependencies
28+
run: npm ci # ci (not install) to install exact versions from package-lock.json
29+
30+
# Build the SvelteKit project
31+
- name: Build project
32+
run: npm run build
33+
34+
# Upload build output as artifact
35+
- uses: actions/upload-pages-artifact@v3
36+
with:
37+
path: ./build # SvelteKit static output folder
38+
2639
deploy:
40+
needs: build # make the build artifact available here in deploy job
41+
runs-on: ubuntu-latest
42+
2743
environment:
2844
name: github-pages
29-
url: ${{ steps.deployment.outputs.page_url }}
30-
runs-on: ubuntu-latest
45+
url: ${{ steps.deploy.outputs.page_url }} # just a convenience, adds page url to action summary page
46+
3147
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v3
34-
- name: Setup Pages
35-
uses: actions/configure-pages@v3
36-
- name: Upload artifact
37-
uses: actions/upload-pages-artifact@v2
38-
with:
39-
# Upload entire repository
40-
path: '.'
41-
- name: Deploy to GitHub Pages
42-
id: deployment
43-
uses: actions/deploy-pages@v2
48+
- id: deploy
49+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
test-results
2+
node_modules
3+
4+
# Output
5+
.output
6+
.vercel
7+
.netlify
8+
.wrangler
9+
/.svelte-kit
10+
/build
11+
/.vscode
12+
/project.inlang/cache
13+
14+
# OS
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Env
19+
.env
20+
.env.*
21+
!.env.example
22+
!.env.test
23+
24+
# Vite
25+
vite.config.js.timestamp-*
26+
vite.config.ts.timestamp-*
27+
28+
# Paraglide
29+
src/lib/paraglide
30+
31+
32+
/assets

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.17.0

.vscode/launch.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

CNAME

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
#SCN website (operated by LCL)
1+
# SCN website (operated by LCL)
2+
3+
Code repo for the seattlecommunitynetwork.org website.
4+
5+
This site is built using [SvelteKit](https://svelte.dev/docs/kit/introduction). SvelteKit supports building fully static sites - which is how this site is built. SvelteKit uses NodeJS to run the static site build.
6+
7+
The website is hosted on GitHub pages. See `./.github/workflows/static.yml` for deployment info.
8+
9+
10+
## How to update this website
11+
12+
You'll want to run the site locally so you can preview your changes. It's fairly simple to setup if you have any programming experience.
13+
14+
Make your changes and confirm them in your locally running site. Commit change to a feature Branch, and create a pull request in GitHub.
15+
16+
The changes will then need to be reviewed and merged. After merging, a GitHub Action (`./.github/workflows/static.yml`) will kick off to build and deploy the site. This should only take 5 mins, after which your changes will be live!
17+
18+
19+
### Local setup
20+
21+
**Install NodeJS** - two options:
22+
23+
1. Download and install NodeJS https://nodejs.org/en/download
24+
See `./.nvmrc` for the version of NodeJS to install
25+
1. Use NVM https://github.com/nvm-sh/nvm
26+
27+
**Setup**
28+
29+
1. Clone the repo
30+
1. Using NVM?
31+
1. `nvm install` to install the correct NodeJS version
32+
1. `nvm use` to use the installed NodeJS version
33+
1. Install dependencies with `npm install`
34+
1. Start a development server `npm run dev`
35+
36+
Open your browser to http://localhost:5173
37+
38+
39+
### Update text
40+
41+
All website text is in `./messages/en.json`.
42+
43+
Adding or removing text sections will most certainly require updating a template
44+
45+
46+
### Update templates
47+
48+
The website is built with a bunch of `*.svelte` files. Each file has a section for JS, HTML, and CSS.
49+
50+
Each page of the website starts with a `+page.svelte` template, eg: `./src/routes/+page.svelte` for the homepage, and `./src/routes/about-us/+page.svelte` for the About Us.
51+
52+
There's 1 layout template used for all pages - `./src/routes/+layout.ts`.
53+
54+
There is a variety of reusable components in `./src/lib/components/*.svelte`
55+
56+
57+
## Tests
58+
59+
There are automated tests using Playwright.
60+
61+
- run this the first time, to install Playwright dependencies: `npx playwright install`
62+
- `npm run test` to run tests
63+
64+
65+
## Production build
66+
67+
To create a *local* production version of your app:
68+
69+
1. `npm run build`
70+
1. `npm run preview`
71+
1. open http://localhost:4137
72+
73+
74+
## Redirects
75+
76+
No good way to do this with GitHub pages, so we need to create stub sveltekit pages that do a client side redirect.
77+
78+
See `./create-redirect.js`.

0 commit comments

Comments
 (0)