Skip to content

Commit f04b6c9

Browse files
committed
Prerender all posts routes
1 parent f9caa1d commit f04b6c9

10 files changed

Lines changed: 13 additions & 17 deletions

File tree

src/routes/api/authors/[id]/+server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { error, json } from '@sveltejs/kit';
44
import type { RequestHandler } from './$types';
55
import authors from './authors';
66

7+
// We can't be sure that all routes are prerendered.
8+
export const prerender = 'auto';
9+
710
export const GET: RequestHandler = async ({ params }) => {
811
const id = params.id;
912
const author = resolve<AvatarMeta>(id, authors);

src/routes/api/posts/2021/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import postMoveYourIdeToTheCloud from '$posts/(2021)/move-your-ide-to-the-cloud-
66
import { json } from '@sveltejs/kit';
77
import type { RequestHandler } from './$types';
88

9-
// Needs to be set explicitly because we prerender endpoint `/sitemap.xml`.
10-
// export const prerender = true;
9+
export const prerender = true;
1110

1211
export const GET: RequestHandler = async (event) => {
1312
// Sort order: latest first.

src/routes/api/posts/2022/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ import postAtAndHashtagSymbols from '$posts/(2022)/using-the-at-and-hash-symbols
1010
import { json } from '@sveltejs/kit';
1111
import type { RequestHandler } from './$types';
1212

13-
// Needs to be set explicitly because we prerender endpoint `/sitemap.xml`.
14-
// export const prerender = true;
13+
export const prerender = true;
1514

1615
export const GET: RequestHandler = async (event) => {
1716
// Sort order: latest first.

src/routes/api/posts/2023/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import postStackBlitzCodeflowBeta from '$posts/(2023)/is-stackblitz-codeflow-bet
99
import { json } from '@sveltejs/kit';
1010
import type { RequestHandler } from './$types';
1111

12-
// Needs to be set explicitly because we prerender endpoint `/sitemap.xml`.
13-
// export const prerender = true;
12+
export const prerender = true;
1413

1514
export const GET: RequestHandler = async (event) => {
1615
// Sort order: latest first.

src/routes/api/posts/2024/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import postCopilotContext from '$posts/(2024)/github-copilot-context/meta';
33
import { json } from '@sveltejs/kit';
44
import type { RequestHandler } from './$types';
55

6-
// Needs to be set explicitly because we prerender endpoint `/sitemap.xml`.
7-
// export const prerender = true;
6+
export const prerender = true;
87

98
export const GET: RequestHandler = async (event) => {
109
// Sort order: latest first.

src/routes/api/posts/2025/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import postManagingEnvVarsWithVercel from '$posts/(2025)/managing-environment-va
55
import { json } from '@sveltejs/kit';
66
import type { RequestHandler } from './$types';
77

8-
// export const prerender = true;
8+
export const prerender = true;
99

1010
export const GET: RequestHandler = async (event) => {
1111
// Sort order: latest first.

src/routes/api/posts/all/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type { ResolvedPost } from '@maiertech/sveltekit-helpers';
22
import { json } from '@sveltejs/kit';
33
import type { RequestHandler } from './$types';
44

5-
// Needs to be set explicitly because we prerender endpoint `/sitemap.xml`.
6-
// export const prerender = true;
5+
export const prerender = true;
76

87
// Return all posts.
98
export const GET: RequestHandler = async ({ fetch }) => {

src/routes/api/posts/latest/+server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import type { ResolvedPost } from '@maiertech/sveltekit-helpers';
22
import { json } from '@sveltejs/kit';
33
import type { RequestHandler } from './$types';
44

5-
// No need to set `export const prerender = true;`.
6-
// Prerendering is triggered by `/`, which uses this endpoint and iself is prerendered.
5+
export const prerender = true;
76

87
// Return latest posts (up to 10).
98
export const GET: RequestHandler = async ({ fetch }) => {

src/routes/api/posts/rss/+server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ResolvedPost } from '@maiertech/sveltekit-helpers';
55
import { json } from '@sveltejs/kit';
66
import type { RequestHandler } from './$types';
77

8-
// export const prerender = true;
8+
export const prerender = true;
99

1010
export const GET: RequestHandler = async ({ fetch }) => {
1111
const response = await fetch('/api/posts/latest');

src/routes/api/tags/[id]/+server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { error, json } from '@sveltejs/kit';
44
import type { RequestHandler } from './$types';
55
import tags from './tags';
66

7-
// Include this endpoint into the manifest.
8-
// This ensures that dynamic calls for tags that have not been prerendered still work.
9-
// export const prerender = 'auto';
7+
// We can't be sure that all routes are prerendered.
8+
export const prerender = 'auto';
109

1110
export const GET: RequestHandler = async ({ params }) => {
1211
const id = params.id;

0 commit comments

Comments
 (0)