Skip to content

Conversation

@Adammatthiesen
Copy link
Member

@Adammatthiesen Adammatthiesen commented Jan 16, 2026

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:

  • Upgraded @studiocms/cfetch, studiocms, and @studiocms/md to version 0.2.0, 0.1.1, and 0.1.1 respectively, and updated @studiocms/ui peer dependency to ^1.0.0. Added kysely-turso as a new dependency.
  • Changed the cFetch integration's lifetime option from '1h' to '1 hour' in astro.config.mts.

Configuration Improvements:

  • Improved the logic for setting the site URL in astro.config.mts to distinguish between production and development environments, defaulting to http://localhost:4321 in development.

API Data Fetching Enhancements:

  • Refactored all uses of cFetch in stats-helpers.ts to 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:

  • Updated blog page logic to return a 404 response if the page is a draft, not just if it is missing. (www/src/pages/blog/[slug].astroL13-R13)
  • Removed the true argument from SDKCoreJs.GET.folderPages calls in blog and index pages, likely affecting filtering or sorting logic for blog entries. [1] [2]

Summary by CodeRabbit

  • Bug Fixes

    • Draft blog pages now correctly return a 404 response.
  • Chores

    • Updated core dependencies to stable versions.
    • Refactored internal data fetching logic for improved consistency.
    • Updated deployment URL configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

- 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`.
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Configuration & Dependencies
www/astro.config.mts, www/package.json
Updated site URL logic to respect NODE_ENV and DOKPLOY_DEPLOY_URL for environment-specific URLs. Bumped @studiocms packages to stable 0.1.1 versions, upgraded @studiocms/cfetch to ^0.2.0, replaced @libsql/kysely-libsql with kysely-turso, and updated @studiocms/ui peer dependency to ^1.0.0. Changed cFetch lifetime format from '1h' to '1 hour'.
Blog Page Handling
www/src/pages/blog/[slug].astro, www/src/pages/blog/index.astro, www/src/pages/index.astro
Removed third boolean argument from SDKCoreJs.GET.folderPages() calls across blog pages, altering the dataset of returned entries. Added draft page filtering in [slug].astro to treat drafted pages as 404 responses.
API Utilities
www/src/utils/stats-helpers.ts
Migrated three fetch operations (getNpmMonthlyDownloads, getStudioCMSStars, getDiscordMembers) from raw fetch to typed cFetch with response bodies (cFetch<{ downloads: string }>, cFetch<{ stargazers_count: number }>, cFetch<{ members: number }>), improving type safety.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • dreyfus92
  • louisescher

Poem

🐰 A hop, skip, and type-safe leap,
Dependencies wake from beta sleep,
Draft pages hidden, folderPages trimmed,
cFetch brings structure, no JSON whimmed!
The website now blooms in NODE_ENV light.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately summarizes the main objectives of the pull request, which involve updating StudioCMS dependencies and refactoring data fetching logic across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-studiocms

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Adammatthiesen Adammatthiesen marked this pull request as ready for review January 16, 2026 10:18
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner January 16, 2026 10:18
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cee2ea and 6ab162a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (6)
  • www/astro.config.mts
  • www/package.json
  • www/src/pages/blog/[slug].astro
  • www/src/pages/blog/index.astro
  • www/src/pages/index.astro
  • www/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: Confirm cFetch lifetime 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].astro with 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/ui peer dependency is not satisfied in this workspace.
The version constraint ^1.0.0 is declared as a peerDependency in www/package.json but no package in the repository has @studiocms/ui installed 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-libsql imports in the codebase
  • pnpm-lock.yaml includes all updated dependency versions
  • Peer dependency @studiocms/ui@^1.0.0 is 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.

@Adammatthiesen Adammatthiesen changed the title Update deps and fix any needed changes Update StudioCMS dependencies and refactor data fetching Jan 16, 2026
@Adammatthiesen Adammatthiesen merged commit 97a4325 into main Jan 16, 2026
2 checks passed
@Adammatthiesen Adammatthiesen deleted the update-studiocms branch January 16, 2026 10:44
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.

3 participants