Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prerendering fallback #149

Merged
merged 2 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Always use trailing slash
export const trailingSlash = 'always';

// Prerender all pages
// Disable SSR and prerender all pages by default
export const ssr = false;
export const prerender = true;
3 changes: 0 additions & 3 deletions frontend/src/routes/auth/login/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {redirect} from '@sveltejs/kit';
import {getCookiesMap} from '$lib/cookies';
import {sanitizeRedirectPath} from '$lib/urls';

// Disable server-side rendering for this page
export const ssr = false;

export async function load({url}): Promise<void> {
const cookies = getCookiesMap(document.cookie);
// Note: The user_id cookie is HTTP only, so we cannot fetch it.
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/routes/auth/logout/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {goto} from '$app/navigation';

import {apiLogout} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export async function load({fetch}): Promise<void> {
await apiLogout(fetch);

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/routes/auth/password/change/+page.ts

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/routes/auth/registration/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import {redirect} from '@sveltejs/kit';
import {getCookiesMap} from '$lib/cookies';
import {sanitizeRedirectPath} from '$lib/urls';

// Disable server-side rendering for this page
export const ssr = false;

export async function load({url}): Promise<void> {
const cookies = getCookiesMap(document.cookie);
// Note: The user_id cookie is HTTP only, so we cannot fetch it.
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/routes/flights/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {loadApiFlights, type FlightListItem, type FlightLocation} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export interface Data {
readonly flights: FlightListItem[];
readonly locations: Record<number, FlightLocation>;
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/routes/flights/[id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import {z} from 'zod';

import {loadApiFlight, type Flight} from '../api';

// Disable server-side rendering for this page
export const ssr = false;
export function entries() {
return [{id: '1'}];
}
// Dynamic URL, don't prerender
export const prerender = false;

export interface Data {
readonly flight: Flight;
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/routes/flights/[id]/edit/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ import {loadApiGliders, type Glider} from '../../../gliders/api';
import {loadApiLocations} from '../../../locations/api';
import {loadApiFlights, type FlightLocation, loadApiFlight, type Flight} from '../../api';

// Disable server-side rendering for this page
export const ssr = false;
export function entries() {
return [{id: '1'}];
}
// Dynamic URL, don't prerender
export const prerender = false;

export interface Data {
/**
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/routes/flights/add/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import {loadApiGliders, type Glider} from '../../gliders/api';
import {loadApiLocations} from '../../locations/api';
import {loadApiFlights, type FlightLocation} from '../api';

// Disable server-side rendering for this page
export const ssr = false;

export interface Data {
/**
* A sorted array of flight numbers associated with existing flights.
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/routes/gliders/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {loadApiGliders, type GlidersInfo} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export type Data = GlidersInfo;

export async function load({fetch}): Promise<Data> {
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/routes/gliders/[id]/edit/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import {z} from 'zod';

import {loadApiGliders, type Glider} from '../../api';

// Disable server-side rendering for this page
export const ssr = false;
export function entries() {
return [{id: '1'}];
}
// Dynamic URL, don't prerender
export const prerender = false;

export interface Data {
readonly glider: Glider;
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/routes/gliders/add/+page.ts

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/routes/locations/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {loadApiLocations, type Location} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export interface Data {
readonly locations: Location[];
}
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/routes/locations/[id]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import {z} from 'zod';

import {loadApiLocation, type Location} from '../api';

// Disable server-side rendering for this page
export const ssr = false;
export function entries() {
return [{id: '1'}];
}
// Dynamic URL, don't prerender
export const prerender = false;

export interface Data {
readonly location: Location;
Expand Down
7 changes: 2 additions & 5 deletions frontend/src/routes/locations/[id]/edit/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import {z} from 'zod';

import {loadApiLocation, type Location} from '../../api';

// Disable server-side rendering for this page
export const ssr = false;
export function entries() {
return [{id: '1'}];
}
// Dynamic URL, don't prerender
export const prerender = false;

export interface Data {
readonly location: Location;
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/routes/locations/add/+page.ts

This file was deleted.

3 changes: 0 additions & 3 deletions frontend/src/routes/profile/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {loadApiProfile, type Profile} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export interface Data {
readonly profile: Profile;
}
Expand Down
3 changes: 0 additions & 3 deletions frontend/src/routes/stats/+page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import {loadApiStats, type Stats} from './api';

// Disable server-side rendering for this page
export const ssr = false;

export type Data = Stats;

export async function load({fetch}): Promise<Data> {
Expand Down
2 changes: 1 addition & 1 deletion frontend/svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const config = {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: undefined,
fallback: 'fallback.html',
precompress: false,
strict: true,
}),
Expand Down