How to access .yml file at root in Netlify CMS? - yaml

I'm trying to give Netlify CMS access to a data file containing authors for a blog site, but I haven't been able to get the records from the root of the file. I need the records to be at the root because of the site generator I'm using. Is there anything I can replace the asterisks with to accomplish this?
- name: "settings"
label: "Settings"
files:
- name: "authors"
label: "Authors"
file: "_data/authors.yml"
fields:
- name: "*****"
label: "Authors"
widget: "list"
fields:
- {label: "Name", name: "name", widget: "string"}
- {label: "Last Name", name: "last_name", widget: "string"}
- {label: "First Name", name: "first_name", widget: "string"}
- {label: "Display Name", name: "display_name", widget: "string"}
- {label: "Bio", name: "bio", widget: "markdown"}

Related

Different Gatsby templates for Netlify CMS collection types?

Building a portfolio site using Gatsby and Netlify CMS. I'd like to have 2 different post types, one for projects and one for blog posts. I don't see any way to differentiate the Netlify collection types in gatsby-node.ts.
This is my netlify config in static/admin/config.yml:
collections:
- name: 'blog'
label: 'Blog'
folder: 'content/blog'
create: true
slug: 'blog/{{slug}}'
path: '{{title}}/index'
editor:
preview: true
fields:
- { name: 'title', label: 'Title', widget: 'string' }
- { name: 'date', label: 'Publish Date', widget: 'datetime' }
- { name: 'description', label: 'Description', widget: 'string' }
- { name: 'body', label: 'Body', widget: 'markdown' }
- name: 'project'
label: 'Project'
folder: 'content/projects'
create: true
slug: 'projects/{{slug}}'
path: '{{title}}/index'
editor:
preview: true
fields:
- { name: 'title', label: 'Title', widget: 'string' }
- { name: 'date', label: 'Publish Date', widget: 'datetime' }
- { name: 'description', label: 'Description', widget: 'string' }
- { name: 'image', label: 'Image', widget: 'image' }
- { name: 'body', label: 'Body', widget: 'markdown' }
I'm loading them separately in gatsby-config.ts:
module.exports= {
// ...
plugins: [
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'blog',
path: `${__dirname}/content/blog`,
},
},
{
resolve: 'gatsby-source-filesystem',
options: {
name: 'projects',
path: `${__dirname}/content/projects`,
},
},
]
// ...
}
I can create different post types in Netlify CMS which then create markdown files in the correct folders. I can't figure out how to query them separately so that I can use different templates to display them. I've been poking around in GraphiQL for hours looking for any bit of data which would differentiate these two post types.

How to add image upload functionality in Netlify CMS

Hi I'm new to Netlify CMS I just learned about it from a blog
so I have config.yml that creates two input fields in Netlify CMS
Sample:
collections:
- name: 'team'
label: 'Team'
folder: 'src/team'
create: true
slug: '{{slug}}'
fields:
- { label: 'Team Member', name: 'title', widget: 'string' }
- { label: 'Bio', name: 'bio', widget: 'markdown' }
I'm just wondering how can I add input field for the image
Thanks!
Just add
{ label: "Image", name: "thumbnail", widget: "image"}
into one of your fields
collections:
- name: 'team'
label: 'Team'
folder: 'src/team'
create: true
slug: '{{slug}}'
fields:
- { label: 'Team Member', name: 'title', widget: 'string' }
- { label: 'Bio', name: 'bio', widget: 'markdown' }
- { label: "Image", name: "thumbnail", widget: "image"}
Source: https://www.netlifycms.org/docs/add-to-your-site/

How to get multiple collections working within Netlify-CMS?

I'm running a Gridsome project where I have integrated Netlify-CMS. This is what my config.yml file looks like:
backend:
name: github
branch: master # Branch to update (optional; defaults to master)
repo: user/repo
media_folder: "images/uploads"
public_folder: "/images/uploads"
collections:
- name: "blog" # Used in routes, e.g., /admin/collections/blog
label: "Blog" # Used in the UI
folder: "blog" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Title", name: "title", widget: "string"}
- {label: "Publish Date", name: "date", widget: "datetime"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
- name: "projects" # Used in routes, e.g., /admin/collections/blog
label: "Projects" # Used in the UI
folder: "projects" # The path to the folder where the documents are stored
create: true # Allow users to create new documents in this collection
slug: "{{year}}-{{month}}-{{day}}-{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
fields: # The fields for each document, usually in front matter
- {label: "Layout", name: "layout", widget: "hidden", default: "blog"}
- {label: "Customer", name: "customer", widget: "string"}
- {label: "Activity", name: "activity", widget: "string"}
- {label: "Date", name: "date", widget: "datetime"}
- {label: "Link", name: "link", widget: "string"}
- {label: "Featured Image", name: "thumbnail", widget: "image"}
- {label: "Body", name: "body", widget: "markdown"}
I'm able to see both Blog and Projects in the admin interface, however, when I click on the Project collections it doesn't show my existing .md file within the specified folder. At the same time, when I try to create a new project, this doesn't get added and no error message is displayed.
Everything works like a charm with the Blog collection.
This is what the project directory looks like:
There's no field that can serve as an identifier. Right now you either have to have a field named "title" or set "identifier_field" to the name of a field that you'd like to use instead. The value of the field should be unique to the entry, so I'm guessing adding a "title" to each project is probably a good move anyway.
There should be an error for this, if you could open a bug in GitHub for that we can look into it.

Gatsby, how to do "join" with graphql?

I use gatsby and netlify-cms.
My schema:
collections:
- name: "tags"
label: "Tags"
folder: "src/data/tags"
create: true
slug: "{{slug}}"
fields:
- {label: "Id", name: "title", widget: "string"}
- {label: "Description", name: "description", widget: "text"}
- name: "posts"
label: "Posts"
folder: "src/data/posts"
create: true
slug: "{{slug}}"
fields:
- {label: "Id", name: "title", widget: "string"}
- label: "Tags"
name: "tags"
widget: "list"
fields:
- label: "Tag"
name: "tag"
widget: "relation"
collection: "tags"
searchFields: ["name", "description"]
valueField: "title"
displayFields: ["name"]
My query:
query PostByID($id: String!) {
markdownRemark(id: { eq: $id }) {
id
html
frontmatter {
id: title
description
tags {
tag
// get tag description????
}
}
}
}
Is there a way to get tag description? I'm trying to use fragments, but it doesn't work. I asked this question as issue on Gatsby GitHub, I was advised this example:
fragment tagDetails on Tag {
title
description
}
and with this usage:
tag {
...tagDetails
}
I get this error:
"Field \"tag\" must not have a selection since type \"String\" has no subfields."

Re-Adding Bullet & Italics to CkEditor

I have inherited an MVC3 C# .Net Web App which uses CkEditor. The ability to insert bold text and italicized text has been removed from the CkEditor boxes by another developer (who is no longer here). How can I re-add the Bold & Italics functionality back into CkEditor?
I found the answer. Attributes of the .toolbar config property had been removed. I.e.
toolbar: [
{ name: 'insert', items: ['Image'] },
{ name: 'tools', items: ['Maximize'] },
],
I modified to:
toolbar: [
{ name: 'insert', items: ['Image'] },
{ name: 'tools', items: ['Maximize'] },
['Bold', 'Italic', 'Underline'], ['NumberedList', 'BulletedList']
],
Here's the Url that helped me: CkEditor Config Stuff

Resources