@@ -24,22 +24,6 @@ import { union } from 'lodash-es'
2424// every single time, we turn it into a Set once.
2525const productMapKeysAsSet = new Set ( Object . keys ( productMap ) )
2626
27- // Wrapper on renderContent() that caches the output depending on the
28- // `context` by extracting information about the page's current permalink
29- const _renderContentCache = new Map ( )
30-
31- function renderContentCacheByContext ( prefix ) {
32- return async function ( template = '' , context = { } , options = { } ) {
33- const { currentPath } = context
34- const cacheKey = prefix + currentPath
35-
36- if ( ! _renderContentCache . has ( cacheKey ) ) {
37- _renderContentCache . set ( cacheKey , await renderContent ( template , context , options ) )
38- }
39- return _renderContentCache . get ( cacheKey )
40- }
41- }
42-
4327class Page {
4428 static async init ( opts ) {
4529 opts = await Page . read ( opts )
@@ -186,26 +170,26 @@ class Page {
186170 context . englishHeadings = englishHeadings
187171 }
188172
189- this . intro = await renderContentCacheByContext ( 'intro' ) ( this . rawIntro , context )
190- this . introPlainText = await renderContentCacheByContext ( 'rawIntro' ) ( this . rawIntro , context , {
173+ this . intro = await renderContent ( this . rawIntro , context )
174+ this . introPlainText = await renderContent ( this . rawIntro , context , {
191175 textOnly : true ,
192176 } )
193- this . title = await renderContentCacheByContext ( 'rawTitle' ) ( this . rawTitle , context , {
177+ this . title = await renderContent ( this . rawTitle , context , {
194178 textOnly : true ,
195179 encodeEntities : true ,
196180 } )
197- this . titlePlainText = await renderContentCacheByContext ( 'titleText' ) ( this . rawTitle , context , {
181+ this . titlePlainText = await renderContent ( this . rawTitle , context , {
198182 textOnly : true ,
199183 } )
200- this . shortTitle = await renderContentCacheByContext ( 'shortTitle' ) ( this . shortTitle , context , {
184+ this . shortTitle = await renderContent ( this . shortTitle , context , {
201185 textOnly : true ,
202186 encodeEntities : true ,
203187 } )
204188
205189 this . product_video = await renderContent ( this . raw_product_video , context , { textOnly : true } )
206190
207191 context . relativePath = this . relativePath
208- const html = await renderContentCacheByContext ( 'markdown' ) ( this . markdown , context )
192+ const html = await renderContent ( this . markdown , context )
209193
210194 // Adding communityRedirect for Discussions, Sponsors, and Codespaces - request from Product
211195 if (
@@ -222,15 +206,12 @@ class Page {
222206
223207 // product frontmatter may contain liquid
224208 if ( this . rawProduct ) {
225- this . product = await renderContentCacheByContext ( 'product' ) ( this . rawProduct , context )
209+ this . product = await renderContent ( this . rawProduct , context )
226210 }
227211
228212 // permissions frontmatter may contain liquid
229213 if ( this . rawPermissions ) {
230- this . permissions = await renderContentCacheByContext ( 'permissions' ) (
231- this . rawPermissions ,
232- context
233- )
214+ this . permissions = await renderContent ( this . rawPermissions , context )
234215 }
235216
236217 // Learning tracks may contain Liquid and need to have versioning processed.
0 commit comments