@@ -33,15 +33,25 @@ export default function (eleventyConfig) {
3333 return website . title || getWebsiteDomain ( website . url ) ;
3434 } ) ;
3535
36- eleventyConfig . addFilter ( "getSiteData" , ( url , participant ) => {
36+ // Return website matching url and year.
37+ // This allows to have different configurations for different years.
38+ // This is uSeful for prefix and suffix which might need different values depending on the year.
39+ eleventyConfig . addFilter ( "getSiteData" , ( url , participant , year ) => {
3740 return participant . websites . find ( website => {
38- return website . url === url ;
41+ return website . url === url && website . years . includes ( year ) ;
3942 } ) ;
4043 } ) ;
4144
42- eleventyConfig . addShortcode ( "linkNoSpam" , function ( callback , url , participant ) {
43- const website = eleventyConfig . getFilter ( "getSiteData" ) ( url , participant ) ;
45+ eleventyConfig . addShortcode ( "linkNoSpam" , function ( callback , url , participant , year , loopRevIndex0 ) {
46+ const website = eleventyConfig . getFilter ( "getSiteData" ) ( url , participant , year ) ;
47+
48+ if ( ! website ) {
49+ return ;
50+ } ;
51+
4452 let title ;
53+ let prefix = website . prefix ;
54+ let suffix = website . suffix ;
4555
4656 switch ( callback ) {
4757 case 'getSiteTitle' :
@@ -52,6 +62,10 @@ export default function (eleventyConfig) {
5262 break ;
5363 }
5464
65+ if ( suffix === undefined && loopRevIndex0 ) {
66+ suffix = loopRevIndex0 > 1 ? ', ' : ' & ' ;
67+ }
68+
5569 if ( ! website ?. url ) {
5670 return title ;
5771 }
@@ -60,7 +74,7 @@ export default function (eleventyConfig) {
6074 return website . url ;
6175 }
6276
63- return `<a href="${ website . url } ">${ title } </a>`
77+ return `${ prefix || '' } <a href="${ website . url } ">${ title } </a>${ suffix || '' } `
6478 } ) ;
6579
6680 // TODO: Add a tool to target duplicated domains.
0 commit comments