Skip to content

refactor: replace Strapi fetch with @strapi/client and add configurable CMS URL#5835

Merged
vineethasok merged 8 commits intomainfrom
strapi-client-integration
Mar 26, 2026
Merged

refactor: replace Strapi fetch with @strapi/client and add configurable CMS URL#5835
vineethasok merged 8 commits intomainfrom
strapi-client-integration

Conversation

@vineethasok
Copy link
Contributor

Summary

  • Introduces src/lib/useStrapiClient.ts — a shared React hook that builds and memoizes a @strapi/client instance using CLIENT_STRAPI_URL and CLIENT_STRAPI_TOKEN from the Docusaurus customFields. Defaults to https://staging-cms.clickhouse.com.
  • Adds strapiUrl and strapiToken to customFields in all 5 locale configs, populated from CLIENT_STRAPI_URL / CLIENT_STRAPI_TOKEN env vars at build time.
  • Updates IntegrationGrid to use useStrapiClient, removes the old Strapi v4 attributes format handling (transformFallbackData, CMSIntegrationDataV4), and uses the dynamic base URL for logo URLs.
  • Updates DocItemTOC/Desktop to use useStrapiClient, replaces 5 separate ad state vars with a single ad object, fixes the useEffect dependency array, removes the redundant typeof window SSR guard, adds unmount cancellation, and replaces localStorage ad caching with a module-level variable (survives client-side navigation, resets on hard reload).

Environment variables

Variable Purpose Default
CLIENT_STRAPI_URL CMS base URL (no /api) https://staging-cms.clickhouse.com
CLIENT_STRAPI_TOKEN CMS API token (empty)

Prod build example:

CLIENT_STRAPI_URL=https://cms-new.clickhouse.com CLIENT_STRAPI_TOKEN=<token> yarn build

Introduce @strapi/client and wire up live CMS fetching across the site. IntegrationGrid: add Strapi client, types for v5/v4 responses, mapping/transform functions, use live CMS collection for integrations, switch base host to cms.clickhouse.com, enable CMS endpoint, and fall back to existing static data. DocItem TOC: replace manual fetch with strapi client single('docs-ad').find() and normalize ad attributes. package.json and yarn.lock updated to include @strapi/client (and its deps).
Introduce a reusable Strapi client hook and wire it into components. Added src/lib/useStrapiClient.ts which reads strapiUrl/strapiToken from docusaurus customFields and returns a memoized client and base URL. Updated locale docusaurus.config.* files to expose strapiUrl and strapiToken. Refactored IntegrationGrid to use the new hook, pass the Strapi base URL into transformCMSData for image URLs, and simplify fallback/CMS fetch logic. Refactored DocItem TOC (desktop) to use the hook and implement a module-level cached ad with simplified state and localStorage close handling. Also added packageManager to package.json and updated yarn.lock (dependency bumps).
@vineethasok vineethasok self-assigned this Mar 24, 2026
@vineethasok vineethasok requested a review from a team as a code owner March 24, 2026 12:03
@vercel
Copy link

vercel bot commented Mar 24, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
clickhouse-docs Ready Ready Preview, Comment Mar 25, 2026 5:20pm
clickhouse-docs-jp Building Building Preview, Comment Mar 25, 2026 5:20pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
clickhouse-docs-ko Ignored Ignored Mar 25, 2026 5:20pm
clickhouse-docs-ru Ignored Ignored Mar 25, 2026 5:20pm
clickhouse-docs-zh Ignored Ignored Mar 25, 2026 5:20pm

Request Review

Refactor the Strapi query in useCMSIntegrations to request only required fields (name, slug, category, supportLevel, docsLink), populate logo and logo_dark with just their url attributes, and add pagination (pageSize: 500). This reduces payload size and ensures the integrations list is fetched completely. Also update static/integrations-fallback.json to match the adjusted CMS response shape.
Delete the packageManager entry that specified "yarn@4.13.0" and adjust the trailing commas in the resolutions block to preserve valid JSON. This removes an explicit package manager version from the repository configuration.
Rebuild yarn.lock to reconcile resolved dependency versions. Notable adjustments include multiple @algolia packages switched to older 5.20.x/5.47.x releases, @babel packages pinned to 7.26.x series, and several @argos-ci packages reverted/normalized (cli/core/util/playwright). This commit only updates the lockfile to reflect the current dependency resolution.
Co-authored-by: Shaun Struwig <41984034+Blargian@users.noreply.github.com>
Copy link
Member

@Blargian Blargian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vineethasok vineethasok merged commit 84807a0 into main Mar 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants