decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

Mismatch between repo path and collection folder when deploying from a monorepo

Open tpluscode opened this issue 6 months ago • 1 comments

I think I'm looking for some concept like a "root dir".

In my setup, I have a nuxt app which serves decap and render's its content. The thing is, the app is in a subdirectory in my repository and the entire thing is a monorepo. It looks something like

/
└── nuxt-app/
    └── content/
        ├── blog
        ├── handbook
        └── pages

In my config, I have these collections to match

backend:
  name: github

collections:
  - name: handbook
    label: "Handbook articles"
    label_singular: Handbook article
    identifier_field: id
    folder: "content/handbook"
    extension: md
    widget: "list"
    create: true
    i18n: true
    summary: "{{title}}"
    view_groups:
      - label: Section
        field: section
    path: '{{section}}/{{slug}}'
    fields: []

  - name: pages
    label: "Pages"
    folder: "content/pages"
    extension: md
    widget: "list"
    create: false
    i18n: true
    fields: []

  - name: blog
    label: Blog
    label_singular: Blog Post
    folder: "content/blog"
    extension: md
    widget: "list"
    create: true
    i18n: true
    fields: []

See that each collection's folder is content/*, which works when I add local_backend: true. But when I run the deployed app, I assume decap is looking for content/blog, etc in the root of the repository.

I see a number of possible solutions but none that exist

  1. Add an option to local_backend

    local_backend:
      root: nuxt-app
    
    collections:
       - name: blog:
         folder: nuxt-app/content/blog
    

    This way, the folder must match the repo but local_backend removes it when serving local. Not super fond of this, as it appear a little unintuitive

  2. Add an option to github backend

    backend:
      name: github
      rootDir: nuxt-app
    
    collections:
       - name: blog:
         folder: content/blog
    

    A little better, keeps the relative path for folder options but the additional rootDir property of GH backend tells it look for content in the right subdirectory.

tpluscode avatar Sep 12 '25 14:09 tpluscode

My current workaround is to set the full repo paths in folder of each collection and run local decap server like cd ../..; decap-server

tpluscode avatar Sep 12 '25 14:09 tpluscode