File tree Expand file tree Collapse file tree
test-cases/general-features Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,21 @@ test.describe('general-features', () => {
103103 const jsChunkFiles = files . filter ( f => f . relname . match ( / c h u n k s \/ j s \/ c h u n k - .+ \. j s $ / ) )
104104 assert . ok ( jsChunkFiles . length > 0 , 'at least one shared JS chunk was produced with a hashed name' )
105105
106+ // Verify that global.data.js output reaches template vars
107+ const feedJsonPath = path . join ( dest , 'feeds/feed.json' )
108+ try {
109+ const feedContent = await readFile ( feedJsonPath , 'utf8' )
110+ const feedData = JSON . parse ( feedContent )
111+ assert . strictEqual (
112+ feedData . _globalDataSentinel ,
113+ 'data-from-global-dot-data' ,
114+ 'feeds template received globalDataSentinel from global.data.js via vars'
115+ )
116+ } catch ( err ) {
117+ const error = err instanceof Error ? err : new Error ( 'Unknown error' , { cause : err } )
118+ assert . fail ( 'Failed to verify global.data.js output in template vars: ' + error . message )
119+ }
120+
106121 // Special test for global.data.js blogPostsHtml
107122 const indexPath = path . join ( dest , 'index.html' )
108123 try {
Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import jsonfeedToAtom from 'jsonfeed-to-atom'
1212 * authorUrl: string,
1313 * authorImgUrl: string,
1414 * publishDate: string,
15- * siteDescription: string
15+ * siteDescription: string,
16+ * globalDataSentinel: string,
1617 * }>}
1718 */
1819export default async function * feedsTemplate ( {
@@ -23,6 +24,7 @@ export default async function * feedsTemplate ({
2324 authorUrl,
2425 authorImgUrl,
2526 siteDescription,
27+ globalDataSentinel,
2628 } ,
2729 pages,
2830} ) {
@@ -39,6 +41,7 @@ export default async function * feedsTemplate ({
3941 home_page_url : homePageUrl ,
4042 feed_url : `${ homePageUrl } /feed.json` ,
4143 description : siteDescription ,
44+ _globalDataSentinel : globalDataSentinel ,
4245 author : {
4346 name : authorName ,
4447 url : authorUrl ,
Original file line number Diff line number Diff line change 55import { html } from 'htm/preact'
66import { render } from 'preact-render-to-string'
77
8- /** @type {AsyncGlobalDataFunction<{ blogPostsHtml: string }> } */
8+ /** @type {AsyncGlobalDataFunction<{ blogPostsHtml: string, globalDataSentinel: string }> } */
99export default async function ( { pages } ) {
1010 const blogPosts = pages
1111 . filter ( page => page . vars ?. layout === 'blog' && page . vars ?. publishDate )
@@ -36,5 +36,5 @@ export default async function ({ pages }) {
3636 </ ul >
3737 ` )
3838
39- return { blogPostsHtml }
39+ return { blogPostsHtml, globalDataSentinel : 'data-from-global-dot-data' }
4040}
You can’t perform that action at this time.
0 commit comments