File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @afterpython/project-website-template" ,
3- "version" : " 0.3.1 " ,
3+ "version" : " 0.3.2 " ,
44 "license" : " Apache-2.0" ,
55 "type" : " module" ,
66 "scripts" : {
Original file line number Diff line number Diff line change 1- import { error } from '@sveltejs/kit' ;
21import type { PageServerLoad } from './$types' ;
32
43export const prerender = true ;
@@ -9,11 +8,13 @@ type FaqItem = {
98 category ?: string ;
109} ;
1110
11+ const FILE = 'faq' as const ;
12+
1213export const load : PageServerLoad = async ( ) => {
1314 try {
14- const faq = await import ( ' $static/faq .json' ) ;
15+ const faq = await import ( ` $static/${ FILE } .json` ) ;
1516 return { faq : ( faq . default ?? faq ) as FaqItem [ ] } ;
1617 } catch {
17- throw error ( 404 , 'FAQs are not available for this project.' ) ;
18+ return { faq : [ ] as FaqItem [ ] } ;
1819 }
1920} ;
Original file line number Diff line number Diff line change @@ -24,20 +24,21 @@ def build_faq_json():
2424 click .echo ("No faq.yml found, skip building faq.json" )
2525 return
2626
27- click .echo ("Building faq.json..." )
28-
2927 raw = read_yaml (faq_yml_path )
3028 if raw is None :
31- items : list [dict ] = []
32- else :
33- items = [
34- {
35- "question" : str (item ["question" ]),
36- "answer" : str (item ["answer" ]),
37- "category" : str (item ["category" ]) if item .get ("category" ) else "" ,
38- }
39- for item in raw
40- ]
29+ click .echo ("faq.yml is empty, skip building faq.json" )
30+ return
31+
32+ click .echo ("Building faq.json..." )
33+
34+ items = [
35+ {
36+ "question" : str (item ["question" ]),
37+ "answer" : str (item ["answer" ]),
38+ "category" : str (item ["category" ]) if item .get ("category" ) else "" ,
39+ }
40+ for item in raw
41+ ]
4142
4243 with open (build_path / "faq.json" , "w" ) as f :
4344 json .dump (items , f , indent = 2 )
You can’t perform that action at this time.
0 commit comments