ref: cache getSitemapAsArray call to reduce redundant calls#1894
Merged
ref: cache getSitemapAsArray call to reduce redundant calls#1894
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors reference-link resolution to use a precomputed sitemap array (siteMapArray) instead of converting the sitemap tree on every call, and wires that derived data through IsomerSiteProps/rendering and UI components.
Changes:
- Update
getReferenceLinkHrefto acceptsitemapArray: IsomerSitemap[]and migrate call sites to passsite.siteMapArray. - Introduce
siteMapArrayas a derived site prop (IsomerDerivedSiteProps) and populate it inRenderEngineviagetSitemapAsArray(site.siteMap). - Update affected tests/stories/helpers to provide
siteMapArray.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/components/src/utils/getTextAsHtml.ts | Passes site.siteMapArray into getReferenceLinkHref when rendering link marks. |
| packages/components/src/utils/getReferenceLinkHref.ts | Changes API to accept a precomputed sitemap array (and removes internal conversion). |
| packages/components/src/utils/tests/getReferenceLinkHref.test.ts | Updates tests to build and pass EXAMPLE_SITEMAP_ARRAY. |
| packages/components/src/types/site.ts | Adds IsomerDerivedSiteProps with required siteMapArray and composes it into IsomerSiteProps. |
| packages/components/src/templates/next/layouts/Collection/utils/processCollectionItems.ts | Passes site.siteMapArray into getReferenceLinkHref for collection item URLs. |
| packages/components/src/templates/next/components/internal/Vica/VicaWidget.tsx | Updates Vica widget asset/reference URL conversion to use siteMapArray. |
| packages/components/src/templates/next/components/internal/Navbar/Navbar.tsx | Updates navbar URL processing to use siteMapArray. |
| packages/components/src/templates/next/components/internal/Footer/Footer.tsx | Updates footer/social/contact/legal link resolution to use siteMapArray. |
| packages/components/src/templates/next/components/internal/ContentPageHeader/ContentPageHeader.tsx | Updates header button link resolution to use siteMapArray. |
| packages/components/src/templates/next/components/complex/* | Updates multiple complex components’ button/link href resolution to use siteMapArray. |
| packages/components/src/templates/next/components/complex/CollectionBlock/utils/getCollectionParent.ts | Switches collection parent lookup to site.siteMapArray. |
| packages/components/src/templates/next/components/complex/CollectionBlock/utils/tests/getCollectionParent.test.ts | Adds siteMapArray to fixtures (but currently not kept in sync with siteMap). |
| packages/components/src/templates/next/components/complex/CollectionBlock/utils/tests/getCollectionPages.test.ts | Adds siteMapArray to fixtures. |
| packages/components/src/stories/helpers/generateSiteConfig.ts | Adds siteMapArray to default story site config. |
| packages/components/src/interfaces/internal/Vica.ts | Updates Vica prop typing to require siteMapArray (instead of siteMap). |
| packages/components/src/engine/render.tsx | Derives siteMapArray inside RenderEngine from siteMap before rendering layouts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
...omponents/src/templates/next/components/complex/CollectionBlock/utils/getCollectionParent.ts
Show resolved
Hide resolved
...emplates/next/components/complex/CollectionBlock/utils/__tests__/getCollectionParent.test.ts
Show resolved
Hide resolved
6d03e3d to
a5800e2
Compare
a5800e2 to
117e065
Compare
adriangohjw
approved these changes
Mar 23, 2026
dcshzj
added a commit
that referenced
this pull request
Mar 23, 2026
* ref: cache getSitemapAsArray call to reduce redundant calls * fix: update based on Copilot comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
We are calling
getSitemapAsArrayrepeatedly, especially when generating a large collection page which usesgetReferenceLinkHrefon every item in the collection.Solution
Breaking Changes
Improvements:
getSitemapAsArrayinside a new derived property inside the site-wide props.getReferenceLinkHrefto use the newsiteMapArraysite-wide prop.Before & After Screenshots
Screen.Recording.2026-03-18.at.14.12.54.mov
Tests