Skip to content

Commit d6c5821

Browse files
authored
Enable trailing slash mode for easier Apache deployment (MFM) (#29)
* fix: enable trailing slash build output to appease Apache * fix: link should not be relative * fix: remove GH specific build stuff, explicitly show adapter default settings, disable strict mode, unset fallback since we don't want an SPA * doc: add a README.md for deploy scripts, mention the trailing slash issue in HACKING.md * fix: link should not be relative * fix: enable trailing slash mode to appease MFM Apache
1 parent 604e667 commit d6c5821

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

HACKING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ especially if you're getting a weird type error that seems wrong, give a shot ju
9191

9292
for main content included in a page, we use `enhanced:img` wherever possible, including with a hero image optionall specified in the frontmatter of blog posts. however, it s
9393

94+
### Quirks with Apache
95+
96+
On moving to MFM hosting, we ran into an issue with our build output not matching the directory structure that Apache expects. We fixed that by enabling this https://svelte.dev/docs/kit/page-options#trailingSlash
97+
9498
### Useful links
9599

96100
action network css examples

scripts/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Scripts
2+
3+
These scripts can be used to push a deployment to MFM, if you have valid credentials. Usually changes should go through a pull request, and let the workflow handle build and deployment. These scripts are here as documentation, to help illustrate what the workflow is actually doing, and also as an escape hatch if you need to push a hotfix without waiting for a PR merge.
4+
5+
Be careful, as using these will affect the production instance. Test your build locally before deploying.
6+
7+
If you are using `mise`, you can run these scripts using environment variables from a local `.env` file.
8+
9+
`mise exec -- bash .\scripts\deploy.sh`
10+
11+
or on Windows
12+
13+
`mise exec -- pwsh .\scripts\deploy.ps1`
14+
15+
and the `.env` in your project root might look like
16+
17+
```
18+
export MFM_USER=
19+
export MFM_PASSWORD=
20+
export MFM_SSH_KEY_PATH=path\\to\\key
21+
export MFM_SSH_HOST=shell.mayfirst.org
22+
export MFM_SSH_PORT=22
23+
export MFM_SCP_PATH=web
24+
```
25+

src/routes/+layout.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
// this line is required to use static site generation
22
// https://svelte.dev/docs/kit/adapter-static
3-
export const prerender = true;
3+
export const prerender = true;
4+
// our MFM host is Apache, enable trailing slash to conform to its expectation for an index.html at each route
5+
export const trailingSlash = 'always';

src/routes/campaigns/our-work.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ The Chevron corporation supplies Israel’s war machine with energy and massive
1515

1616
## 🥖🌹 FITE
1717

18-
[Famine Is The Enemy (FITE)](./fite/) is an independent mutual aid organization run mostly by Baton Rouge DSA members. It serves food each Saturday from 12-1pm at N 14th Street Park. FITE is interested in expanding its work into clothes and healthcare distribution as well as embracing the true meaning of mutual aid through community education and empowerment. [Donate and learn more here.](./fite/)
18+
[Famine Is The Enemy (FITE)](/fite/) is an independent mutual aid organization run mostly by Baton Rouge DSA members. It serves food each Saturday from 12-1pm at N 14th Street Park. FITE is interested in expanding its work into clothes and healthcare distribution as well as embracing the true meaning of mutual aid through community education and empowerment. [Donate and learn more here.](/fite/)

svelte.config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ const config = {
2020
preprocess: [vitePreprocess(), mdsvex(mdsvexOptions)],
2121
kit: {
2222
adapter: adapter({
23-
fallback: '404.html'
23+
pages: 'build',
24+
assets: 'build',
25+
fallback: undefined,
26+
precompress: false,
27+
// setting strict to false so that it doesn't complain about our /api routes
28+
strict: false
2429
}),
25-
// have to set this to make the GH workflow work
2630
paths: {
27-
base: process.argv.includes('dev') ? '' : process.env.BASE_PATH
31+
base: '',
32+
assets: ''
2833
},
2934
prerender: {
3035
handleHttpError: ({ path, referrer, message }) => {

0 commit comments

Comments
 (0)