Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected document behaviour #16

Closed
Steffo99 opened this issue Jun 14, 2024 · 4 comments
Closed

Unexpected document behaviour #16

Steffo99 opened this issue Jun 14, 2024 · 4 comments

Comments

@Steffo99
Copy link

Heya, since this repository seems to be pretty new, I hope you don't mind if I open a couple issues about my experience in learning to use LumeCMS, so that it can be made even easier to use!

What I did

I defined a document with the following code:

cms.document(
	"site",
	"src:site.yml",
	[
		{
			name: "title",
			type: "text",
			label: "Site title", 
			description: "The main title of the site.",
		}
	]
)

Then I went to http://localhost:3000/admin/document/site to set a title.

What I expected

I expected an empty site.yml file to be created, and then it to be filled with what I entered in the CMS form.

What happened

The webpage returned:

There was an error. See logs for more info.

The logs returned:

ERROR NotFound: 2024-06-14T09:17:07.839Z [GET] http://localhost:3000/admin/document/site - No such file or directory (os error 2): readfile './site.yml'
    at Object.readTextFile (ext:deno_fs/30_fs.js:878:24)
    at FsEntry.readData (https://cdn.jsdelivr.net/gh/lumeland/cms@v0.5.1/storage/fs.ts:104:32)
    at Document.read (https://cdn.jsdelivr.net/gh/lumeland/cms@v0.5.1/core/document.ts:45:30)
    at template (https://cdn.jsdelivr.net/gh/lumeland/cms@v0.5.1/core/templates/document/edit.ts:18:31)
    at Object.handler (https://cdn.jsdelivr.net/gh/lumeland/cms@v0.5.1/core/routes/document.ts:18:9)
    at eventLoopTick (ext:core/01_core.js:168:7)
    at async dispatch (https://jsr.io/@hono/hono/4.4.5/src/compose.ts:74:17)
    at async handler (https://jsr.io/@hono/hono/4.4.5/src/hono-base.ts:224:12)
    at async dispatch (https://jsr.io/@hono/hono/4.4.5/src/compose.ts:74:17)
    at async dispatch (https://jsr.io/@hono/hono/4.4.5/src/compose.ts:74:17)

How I worked around the issue

By manually creating a site.yml file containing the following:

title: ""
@oscarotero
Copy link
Member

@Steffo99 Thanks for the feedback!

Unlike Collections, Documents cannot create or remove files, only edit the existing one.
But maybe I can relax this restriction and allow to create it if it doesn't exist.

@Steffo99
Copy link
Author

Forgive me if I ask, but... why is the restriction there?

It feels a bit counter-intuitive, is there a technical reason for it?

@oscarotero
Copy link
Member

oscarotero commented Jun 18, 2024

No technical reason. It's just that the CMS has been designed to edit an already created website. And while collections can grow over time (because you can create new posts in a blog, for example), documents are intended to edit files already existing (like a json file with settings, a special page like the homepage, etc).

@Steffo99
Copy link
Author

Thanks for implementing this!

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

No branches or pull requests

2 participants