File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,12 @@ import getLinkData from './get-link-data.js'
1818import getDocumentType from './get-document-type.js'
1919import { union } from 'lodash-es'
2020
21+ // We're going to check a lot of pages' "ID" (the first part of
22+ // the relativePath) against `productMap` to make sure it's valid.
23+ // To avoid having to do `Object.keys(productMap).includes(id)`
24+ // every single time, we turn it into a Set once.
25+ const productMapKeysAsSet = new Set ( Object . keys ( productMap ) )
26+
2127// Wrapper on renderContent() that caches the output depending on the
2228// `context` by extracting information about the page's current permalink
2329const _renderContentCache = new Map ( )
@@ -162,10 +168,7 @@ class Page {
162168
163169 // make sure the ID is valid
164170 if ( process . env . NODE_ENV !== 'test' ) {
165- assert (
166- Object . keys ( productMap ) . includes ( id ) ,
167- `page ${ this . fullPath } has an invalid product ID: ${ id } `
168- )
171+ assert ( productMapKeysAsSet . has ( id ) , `page ${ this . fullPath } has an invalid product ID: ${ id } ` )
169172 }
170173
171174 return id
You can’t perform that action at this time.
0 commit comments