decaporg / decaporg/decap-cms

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

Open
#7,598 1 comment 0 reactions 0 assignees View on GitHub
type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

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

```yaml
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`

```yaml
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

```yaml
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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.