Skip to content

Commit eec7617

Browse files
fix: update project website to v0.3.1 to fix bugs when faq.yml is missing
1 parent 9a70cd7 commit eec7617

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

afterpython/_website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@afterpython/project-website-template",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"license": "Apache-2.0",
55
"type": "module",
66
"scripts": {

afterpython/_website/src/lib/components/Footer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
projectName?: string;
1010
repositoryUrl?: string;
1111
projectSummary?: string;
12-
contentTypes?: Record<ContentType | 'doc', boolean>;
12+
contentTypes?: Record<ContentType | 'doc' | 'faq', boolean>;
1313
};
1414
1515
let { projectName, repositoryUrl, projectSummary, contentTypes }: FooterProps = $props();

afterpython/_website/src/routes/+layout.server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export const load: LayoutServerLoad = async () => {
3333
// Special handling for doc - check if directory exists instead of JSON
3434
contentTypes.doc = checkDocExists();
3535

36+
// FAQ is sourced from static/faq.json but isn't part of CONTENT_TYPES
37+
contentTypes.faq = await checkContentType('faq');
38+
3639
return {
3740
...metadata.default,
3841
metadataError: null,
@@ -41,7 +44,7 @@ export const load: LayoutServerLoad = async () => {
4144
} catch {
4245
// metadata.json is missing or invalid - return minimal data to keep layout working
4346
const emptyContentTypes = Object.fromEntries(
44-
[...CONTENT_TYPES, 'doc'].map((type) => [type, false])
47+
[...CONTENT_TYPES, 'doc', 'faq'].map((type) => [type, false])
4548
);
4649

4750
return {

afterpython/_website/src/routes/+layout.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@
6161
<a href={resolve('/blog')} data-sveltekit-preload-data>Blog</a>
6262
</li>
6363
{/if}
64-
<li>
65-
<a href={resolve('/faq')} data-sveltekit-preload-data>FAQs</a>
66-
</li>
64+
{#if data.contentTypes?.faq}
65+
<li>
66+
<a href={resolve('/faq')} data-sveltekit-preload-data>FAQs</a>
67+
</li>
68+
{/if}
6769
<!-- <li>
6870
<a href={'/exercises'}>Exercises</a>
6971
</li>

afterpython/_website/src/routes/faq/+page.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { error } from '@sveltejs/kit';
12
import type { PageServerLoad } from './$types';
23

34
export const prerender = true;
@@ -13,6 +14,6 @@ export const load: PageServerLoad = async () => {
1314
const faq = await import('$static/faq.json');
1415
return { faq: (faq.default ?? faq) as FaqItem[] };
1516
} catch {
16-
return { faq: [] as FaqItem[] };
17+
throw error(404, 'FAQs are not available for this project.');
1718
}
1819
};

0 commit comments

Comments
 (0)