content icon indicating copy to clipboard operation
content copied to clipboard

Git content source - add source variant for non-Github / Bitbucket repositories

Open wale opened this issue 8 months ago • 0 comments

Is your feature request related to a problem? Please describe

I have a repository of Markdown files located on a Forgejo repository and want to dynamically load them when the Nuxt Content plugin is loaded.

I have attempted to write a custom content source with variants to make it work outside the context of Codeberg, the host I am using, but failed due to the latter presumably blocking requests to the API made from Node apps.

Describe the solution you'd like

A default source that shallow-clones the Git repository (e.g. git clone --depth=1 --single-branch --branch=<branch>), and loads the given Markdown files in a folder.

With the existing repository source definition, it could be activated if cloneRepository: true was in the same block.

import { defineCollection, defineContentConfig } from '@nuxt/content'

export default defineContentConfig({
  collections: {
    docs: defineCollection({
      type: 'page',
      source: {
        repository: 'https://github.com/nuxt/content',
        include: 'docs/content/**',
        cloneRepository: true
      },
    })
  }
})

Describe alternatives you've considered

  • defineCustomSource: as above, have attempted this, but would have also expend more efforts into making it compatible with both Forgejo, and its soft fork, Gitea.
  • Git submodules: While that works, it is very inflexible, especially if you only want to include a subdirectory in the collection.

Additional context

wale avatar May 08 '25 03:05 wale