Im trying to create a file upload in admin so I can add the default frontmatter.yaml on each page (this way I wont forget). I have the code below but I get “Unsupported file type: yaml” when adding the file.
This is as per the example How to: Add a file upload | Grav Documentation. I suspect it is something to do with media.yaml but I cant seem to find the MIME type for YAML files that works. That shows error “incorrect MIME type” whatever I put in from the many on google.
I have searched extensivley, as stated Ive tried many different MIME types from google. I have read that specific post previously but it doesnt resolve the issue. What are the MIME settings for YAML? The example implies .yaml is supported without modifying media.yaml
When searching the installation for The mime type does not match to file extension the mime type is returned as application/octet-stream. No matter what I set in config files, the result remains the same.
Somewhere deep down the stack Rabbit hole, package ‘nyholm/psr7’ seems to be involved. But I gave up and went along with the returned mime type.
You might consider opening an issue at the repo of Grav and ask if there is a solution to this.
@Grayches, Just curious… Why are you taking this approach? Do you need to share frontmatter between pages? If not, wouldn’t the field ‘metadata’ in Admin be enough?
I want the same frontmatter on each page as I have a form on every page and unitegallery on a lot of pages so including one site wide means I dont have to manually add frontmatter to each page and if I want to update it I can do a find and replace all.
Im at work now so I will confirm and mark as solution when I get home to test, thanks.
Worked perfectly, thank you. It turns out Im not very good at asking forum questions so I’m probably not the best person to open an issue on the grav repo.
I just realised I can expand this topic box which makes it easier to see what Ive included and can read through without scrolling. I’ll do better next time.
I want the whole frontmatter on each page. I’ll give this a go but the only way I could see of doing this was to include a frontmatter.yaml in the page dir and I figured I could work with that. A global frontmatter would be ideal.
If I dont include this the contact form at the bottom of each page doesnt load and/or I have to manually edit/copy a default .md but I figured find and replace frontmatter.yaml files would be easier.
If I dont include this the contact form at the bottom of each page doesnt load and/or I have to manually edit/copy a default .md
I’m afraid I don’t understand the issue when using a single config file containing your shared frontmatter. Please share details. “doesnt load” does not contain much info…
after a lot of searching I decided a frontmatter.yaml was the best option.
I didnt want to go into detail about this issue as it was deviating from the original post so just answered your question.
Its quite likely I am missing something obvious. I came across grav less than 2 weeks ago and have been trying to migrate my site to it since. Ive spent hours searching and reading the forums/guides but /\ seemed like the easiest option
@Grayches, Yes, a form definition cannot be shared using my suggested config file. However, also forms can be defined once globally and displayed in every page.
I didnt want to go into detail about this issue as it was deviating from the original post so just answered your question.
In your initial question you were focusing on a problem you encountered while implemented a certain approach to solve a higher goal: Reusing globally defined data and forms.
The higher goal could be solved with different approaches:
Copying a frontmatter.yaml file into every page folder using a page blueprint.
Sharing:
Coding a blueprint.
For every page created using Admin, the file needs to be uploaded.
When creating pages using an editor, file needs to be copied manually.
Updating: Updating every copy using a script.
Using a single global copy of data in a config file and a single global definition of a form.
Sharing: Coding a page template.
Updating: Updating a single file.
That’s why I asked: “Just curious… Why are you taking this approach?”
Having said that, use the solution that fits you (or your clients) best.
I just got this working! I tried this way initially but the form would never display. I must of made an error along the way but it is now working as you have said and no need for default frontmatter. Thanks a lot, save me a lot of time going forward.