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

Netlify fields config and markdowning #50

Merged
merged 16 commits into from
Oct 2, 2017

Conversation

mateoclarke
Copy link
Contributor

Ok, this PR is a WIP, but I wanted to start a conversation about some of the first real limitations I'm starting to see based on Netlify CMS.

CMS UI Bugs 🐛

First, the CMS UI is kinda buggy. The cool thing is that its open source so we can write fixes and push upstream, but that's not my focus right now. Remember, I just running the CMS SPA from a CDN. This was one small hint that things still aren't very stable.
Here is how you would reproduce: Starting with an existing Project collection open to be edited. Went to the top nav, plus sign to create a new Project. The page seemed to transition, seemingly ready to create a new Project, but the old state of the markdown WSIWYG box still had the text from the previous page. Small thing, but telling on the maturity of this thing.

Poor Docs

Also, documentation needs improvement. I was reading the docs on the out-of-the box widgets trying to learn how to create the select options for a field with a the dropdown select widget. This was hard to Google. I eventually found this issue (8 days old), which led me to this example. Another small thing. And this one even easier for us to make a PR and improve for the community. In general, there is more code diving to get to understanding on how things work, what the defaults are (for example, all fields are required by default), etc.

Markdown

Last thing, some of the code in my last PR was around setting up Gatsby to read markdown files and transform them into GraphQL queries. I really like that feature of Gatsby, though it is very different at first. The confusion for me is this. When you are normally writing markdown files, you have your yml frontmatter with a body section below. In the body is where the markdown formatted texts goes. (As far as I can see so far, again hard because of bad docs) When Netlify generates its markdown files as PRs in the content editing workflow, it doesn't put anything in the body section of the .md file. Everything gets put into the frontmatter. This makes sense in some ways. We could have a multiple markdown widgets for a Collection Item and we can't have two separated bodies under the frontmatter.

But this means, I need to rewire or find a different solution for transforming data in the markdown files into html instead using the markdownRemark plugin the way Gatsby recommended in their docs. https://www.npmjs.com/package/gatsby-transformer-remark

I'll point to some lines below

@@ -0,0 +1,28 @@
---
title: '[Test] Big Project'
summary: >-
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointing out here the default way that markdown widget fields get generated from Netlify CMS to .md.

goals: null
type: project
---

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, no body text below the frontmatter.

beneath the frontmatter. There are cases where we might need more than
one markdown field. Otherwise, we have to look into how Netlify CMS
creates md files.
*/}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For project .md files that have text beneath the frontmatter, the gatsby-remark plugin nicely add the html to the GraphQL node. But now, I need to solve how the transform frontmatter values to html

- name: "project"
label: "Project"
folder: "src/pages/project"
create: "true"
slug: "{{title}}"
fields:
- {label: "Title", name: "title", widget: "string"}
- {label: "Body", name: "body", widget: "markdown"}
- {label: "Summary Description", name: "summary", widget: "markdown"}
- {label: "Stage", name: "stage", widget: "select", options: ["Proposed", "Planning", "Implementing", "Live"]}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where I spun some cycles trying to learn how to create options from select dropdown.

- {label: "Contact Person", name: "contact_name", widget: "string", required: false}
- {label: "Contact Email", name: "contact_email", widget: "string", required: false}
- {label: "Related City Goals", name: "goals", widget: "string", required: false}
- {label: "Collection Type", name: "type", widget: "hidden", default: "project"}
Copy link
Contributor Author

@mateoclarke mateoclarke Sep 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was useful to create a hidden field so that I could have a consistent value to filter on to display the projects in a list on the landing page. But I was surprised there wasn't already some Collection Type available. This seems like exactly the type of thing the hidden widget was made for but also feels hacky.

This is a big commit. It adds a lot of styling for external places that we will eventually chip away at and refine into a Zilker-React component style guide. Add Sass library to Gatsby. Pulls in stylesheets from Fellows site. Adds lib files from uswds-react project.
@mateoclarke mateoclarke removed the wip label Oct 2, 2017
@mateoclarke
Copy link
Contributor Author

The main thing undone here is translating markdown in frontmatter to HTML. Made a separate issue for that... #56

@mateoclarke mateoclarke merged commit abd9e86 into auto_page_create Oct 2, 2017
@mateoclarke mateoclarke deleted the netlify_fields_frontmatter branch October 2, 2017 18:29
@erquhart
Copy link

@mateoclarke hey there - Netlify CMS lead here, noticed your PR linked to one of our issues. Great feedback! Thought I'd note a couple of things, hope it's helpful:

  • You can get the content of a markdown field generated below the frontmatter by naming the field "body". If you think that should be more obvious, I totally agree.

  • You're right about hidden fields being meant for basically setting static values in frontmatter, and I also agree on it being a bit of a hack.

  • Using the CMS from a CDN will continue to be possible even as the CMS matures to 1.0 and beyond, but we don't recommend it for bigger or more complex use cases. It's just there so folks can dabble or easily build something small with no build tooling requirements (for the cms, anyway). Pulling from npm is ideal.

  • We need to do better at making status and progress on the project clear. As of now, a completely rebuilt markdown editor was just released in 0.5.0, and a media library (asset manager UI) is about to drop in 0.6.0, followed by a 1.0 release slated for the beginning of December, which will bring a brand new UI and a lot of bugfixes.

If you run into anymore issues, reach out on Gitter, it's very active, plenty of helpful folks there to assist. Cheers!

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

Successfully merging this pull request may close these issues.

2 participants