@@ -5,6 +5,7 @@ const passthroughFiles = [
55 { from : 'src/assets' , to : 'assets' } ,
66 { from : 'src/data/graph.json' , to : 'data/graph.json' } ,
77 { from : 'src/css' , to : 'css' } ,
8+ { from : 'src/site.webmanifest' , to : 'site.webmanifest' } ,
89] ;
910
1011/** @param {import('@11ty/eleventy').UserConfig } eleventyConfig */
@@ -32,6 +33,44 @@ export default function (eleventyConfig) {
3233 return date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
3334 } ) ;
3435
36+ eleventyConfig . addNunjucksFilter ( 'isExternalLink' , ( href ) => {
37+ if ( ! href ) {
38+ return false ;
39+ }
40+ return href . startsWith ( 'http://' ) || href . startsWith ( 'https://' ) || href . startsWith ( '//' ) ;
41+ } ) ;
42+
43+ eleventyConfig . addNunjucksFilter ( 'getNodeDepth' , ( nodeId , graphData ) => {
44+ if ( ! graphData || ! graphData . links ) {
45+ return 0 ;
46+ }
47+
48+ // Build parent map - include both belongsTo and relates links
49+ const parents = new Map ( ) ;
50+ for ( const link of graphData . links ) {
51+ if ( link . kind === 'belongsTo' || link . kind === 'relates' ) {
52+ parents . set ( link . target , link . source ) ;
53+ }
54+ }
55+
56+ // Calculate depth
57+ let depth = 0 ;
58+ let current = nodeId ;
59+ while ( parents . has ( current ) ) {
60+ current = parents . get ( current ) ;
61+ depth += 1 ;
62+ }
63+
64+ return depth ;
65+ } ) ;
66+
67+ eleventyConfig . addNunjucksFilter ( 'findNodeById' , ( nodes , nodeId ) => {
68+ if ( ! nodes || ! nodeId ) {
69+ return null ;
70+ }
71+ return nodes . find ( node => node . id === nodeId ) || null ;
72+ } ) ;
73+
3574 eleventyConfig . addGlobalData ( 'graphData' , async ( ) => {
3675 const file = resolve ( 'src/data/graph.json' ) ;
3776 const content = await readFile ( file , 'utf-8' ) ;
0 commit comments