11import type { Tag } from '$types/sanity' ;
2- import { documentation , landings } from '$lib/sanity' ;
2+ import { documentation , landings , tutorials } from '$lib/sanity' ;
33
44/**
55 * Build documentation sections
66 * @param {Tag } category
77 * @param {string } lang
8- * @return {object }
8+ * @return {object[] }
99 */
1010export function buildSection ( category : Tag , lang : string = 'en' ) {
1111 const sections = documentation
@@ -29,6 +29,23 @@ export function buildSection(category: Tag, lang: string = 'en') {
2929 return [ landing , sections ] . flat ( ) ;
3030}
3131
32+ /**
33+ * Build documentation tutorials
34+ * @param {Tag } category
35+ * @param {string } lang
36+ * @return {object[] | null }
37+ */
38+ export function buildTutorials ( category : Tag , lang : string = 'en' ) {
39+ const tuts = tutorials
40+ . filter ( ( l ) => l . _lang === lang )
41+ . filter ( ( l ) => l . category . slug === category . slug )
42+ . map ( ( l ) => ( {
43+ title : l . title ,
44+ href : l . _path ,
45+ } ) ) ;
46+ return tuts . length > 0 ? tuts : null ;
47+ }
48+
3249/**
3350 * Build documentation topics
3451 * @param {string[] } paths Array of paths
@@ -37,6 +54,7 @@ export function buildSection(category: Tag, lang: string = 'en') {
3754export function buildTopics ( paths : string [ ] ) {
3855 return documentation
3956 . filter ( ( d ) => paths . includes ( d . _path ) )
57+ . sort ( ( a , b ) => a . title . localeCompare ( b . title ) )
4058 . sort ( ( a , b ) => a . weight - b . weight )
4159 . map ( ( d ) => ( {
4260 title : d . title ,
0 commit comments