Update StudioCMS dependencies and refactor data fetching#64
Update StudioCMS dependencies and refactor data fetching#64Adammatthiesen merged 1 commit intomainfrom
Conversation
- Adjusted site URL configuration in `astro.config.mts` for production and development environments. - Updated `@studiocms/cfetch` to version 0.2.0 and other related dependencies to their latest versions. - Modified blog page logic to check for draft status in `[slug].astro`. - Removed unnecessary parameter in `folderPages` API calls in `index.astro` and `blog/index.astro`. - Improved data fetching in `stats-helpers.ts` to utilize new response structure from `cFetch`.
📝 WalkthroughWalkthroughThe pull request upgrades StudioCMS-related dependencies and adapts the codebase to new SDK interfaces. The Astro configuration now derives the site URL from NODE_ENV and DOKPLOY_DEPLOY_URL. API calls are migrated from raw fetch to typed cFetch. Draft pages are now excluded from blog listings by removing arguments from folderPages calls. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Fix all issues with AI agents
In `@www/astro.config.mts`:
- Around line 6-10: The site value construction uses
process.env.DOKPLOY_DEPLOY_URL directly and can produce duplicated protocols
(e.g., https://https://...). Normalize DOKPLOY_DEPLOY_URL before templating in
the site variable by removing any leading scheme (http:// or https://) or by
parsing and extracting hostname via a URL-safe approach; update the site
assignment logic (the site constant in astro.config.mts) to sanitize
process.env.DOKPLOY_DEPLOY_URL first and then prepend the desired scheme so you
never get protocol duplication.
In `@www/src/pages/index.astro`:
- Around line 37-38: After fetching entries via
runSDK(SDKCoreJs.GET.folderPages(...)) filter out draft items before selecting
the homepage showcase article: apply a filter on the returned entries (e.g.,
remove entries where entry.draft is true or entry.status === 'draft') and use
the filtered list for selecting the showcase and for the blog listing; update
the code that computes the homepage article (the entries variable and any
subsequent selection logic) and mirror the same draft-filter in blog/index.astro
so drafts never appear on the homepage or index.
In `@www/src/utils/stats-helpers.ts`:
- Around line 71-72: The getDiscordMembers function currently accesses
response.data without checking response.ok; update the function (around
getDiscordMembers and its cFetch call) to mirror the error-handling used in
getNpmMonthlyDownloads and getStudioCMSStars: after awaiting cFetch, check if
response.ok is truthy and if not throw or return a safe default/error, otherwise
parse and return Number.parseInt(`${response.data.members}`); ensure the
response.ok check is applied before accessing response.data to avoid returning
NaN.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (6)
www/astro.config.mtswww/package.jsonwww/src/pages/blog/[slug].astrowww/src/pages/blog/index.astrowww/src/pages/index.astrowww/src/utils/stats-helpers.ts
🔇 Additional comments (7)
www/src/pages/blog/[slug].astro (1)
13-14: LGTM — draft guard aligns with 404 behavior.www/astro.config.mts (1)
23-23: ConfirmcFetchlifetime string format for v0.2.0.
Please verify that'1 hour'is a supported duration format for the updated integration.www/src/utils/stats-helpers.ts (2)
29-33: LGTM — typed response usage here looks solid.
47-58: LGTM — typed response handling is fine here.www/src/pages/blog/index.astro (1)
6-8: Draft filtering is correctly maintained—no changes needed.The removed parameter was not part of the SDK signature. The current call
folderPages(folderId, false)correctly excludes drafts from the listing (false= includeDrafts: false), and draft pages are additionally guarded in[slug].astrowith an explicit 404 check (if (!page || page.draft === true) return 404). No draft exposure or broken link risk exists.Likely an incorrect or invalid review comment.
www/package.json (2)
32-33: The@studiocms/uipeer dependency is not satisfied in this workspace.
The version constraint^1.0.0is declared as a peerDependency in www/package.json but no package in the repository has@studiocms/uiinstalled as a dependency. Consumers of the www package will need to provide this peer dependency themselves, or add it to this workspace to avoid resolution warnings.
16-30: Dependency upgrades and libsql→turso swap are properly implemented.Verified:
- No remaining
@libsql/kysely-libsqlimports in the codebasepnpm-lock.yamlincludes all updated dependency versions- Peer dependency
@studiocms/ui@^1.0.0is declared and installed in the www package- Monorepo configuration (pnpm-workspace.yaml) properly supports the dependency structure
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
This pull request updates dependencies, improves API data fetching patterns, and refines some logic and configuration for the Astro-based StudioCMS site. The most important changes are grouped below by theme.
Dependency and Integration Updates:
@studiocms/cfetch,studiocms, and@studiocms/mdto version0.2.0,0.1.1, and0.1.1respectively, and updated@studiocms/uipeer dependency to^1.0.0. Addedkysely-tursoas a new dependency.cFetchintegration'slifetimeoption from'1h'to'1 hour'inastro.config.mts.Configuration Improvements:
siteURL inastro.config.mtsto distinguish between production and development environments, defaulting tohttp://localhost:4321in development.API Data Fetching Enhancements:
cFetchinstats-helpers.tsto use typed responses and a custom response handler, simplifying the parsing of API responses for NPM downloads, GitHub stars, and Discord members. [1] [2] [3] [4]Content and Page Logic Changes:
trueargument fromSDKCoreJs.GET.folderPagescalls in blog and index pages, likely affecting filtering or sorting logic for blog entries. [1] [2]Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.