Skip to content

Conversation

@BenjaminOddou
Copy link
Contributor

This PR resolves #116 allowing Nuxt Studio to list and edit content from remote Git repositories. It improves path resolution logic to handle custom root directories, removes hardcoded content prefixes in draft managers, and implements a fallback strategy to correctly identify collections when source metadata is unavailable in the client context.

@vercel
Copy link

vercel bot commented Nov 26, 2025

@BenjaminOddou is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@BenjaminOddou BenjaminOddou marked this pull request as ready for review November 26, 2025 08:22
@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

npm i https://pkg.pr.new/nuxt-content/studio/nuxt-studio@135

commit: 4a9b3b8

const path = joinURL(remotePathPrefix, fsPath)
let remoteFile = await gitProvider.api.fetchFile(path, { cached: true })

if (!remoteFile && type === 'document' && !path.startsWith('content/')) {
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (!remoteFile && type === 'document' && !path.startsWith('content/')) {
// Fallback strategy: if document fetch fails and path doesn't already start with 'content/',
// and rootDir doesn't already end with 'content' or 'content/', try prepending 'content/'
const rootDirNormalized = host.repository.rootDir.endsWith('/') ? host.repository.rootDir.slice(0, -1) : host.repository.rootDir
if (!remoteFile && type === 'document' && !path.startsWith('content/') && !rootDirNormalized.endsWith('content')) {

The fallback logic for fetching remote files will create double-nested paths when rootDir already includes 'content/', causing fallback attempts to fail to find documents that exist at the correct location.

View Details

Analysis

Double-nested content path when rootDir already ends with 'content'

What fails: fetchRemoteFile() in useDraftBase.ts creates a double-nested 'content' path when the fallback strategy is triggered and rootDir already ends with 'content'

How to reproduce: With rootDir: 'playground/docus/content' (current playground setup) and a missing document file:

  1. fetchRemoteFile('blog/post.md') attempts first fetch with path: 'blog/post.md'
  2. GitHub path resolves to: 'playground/docus/content/blog/post.md'
  3. If first fetch fails, fallback triggers and creates path: 'content/blog/post.md'
  4. GitHub path resolves to: 'playground/docus/content/content/blog/post.md'

Result: Fallback attempt fails because the double-nested path doesn't exist, even though the file exists at the first attempted path

Expected: Fallback strategy should only trigger when rootDir doesn't already end with 'content', to avoid double-nesting. The fallback was designed to support configurations where rootDir doesn't include 'content' (e.g., 'playground/docus'), where the fallback path would correctly resolve to 'playground/docus/content/blog/post.md'.

Fix: Updated condition at line 40 in src/app/src/composables/useDraftBase.ts to check if rootDir already ends with 'content' before attempting the fallback strategy.

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.

Handle remote github repository

1 participant