Closed bodom0015 closed 3 weeks ago
Name | Link |
---|---|
Latest commit | e9e9faa111f9040430a0b552e6acd4a9ba6c4e29 |
Latest deploy log | https://app.netlify.com/sites/cheerful-treacle-913a24/deploys/671ffe21ae87600008bbb224 |
Deploy Preview | https://deploy-preview-350--cheerful-treacle-913a24.netlify.app |
Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
Looking good so far! However, it seems like even though the Markdown widget is used for the content, it doesn't get rendered properly:
Better behavior would either
I'm assuming we can write raw HTML into this content regardless of what widget is used, so if that is the only way we can have complex content, like lists or images, then we should force the user to do that, and not provide a markdown widget that doesn't work.
Thank you for the feedback, @mradamcox!
Sorry, I had based this implementation off of the DecapCMS example "Collapsible Note": https://decapcms.org/docs/custom-widgets/#registereditorcomponent
They specified the widget type as markdown
, so I assumed this would handle Markdown appropriately by default 🤔
Apparently this case needed some special care and we now use marked
to parse the Markdown within the Toggle Section:
https://github.com/markedjs/marked
Gotchas involved that we're working around here:
/guides/[slug]
, even though both single and double quotes are accepted by the editor in DecapCMSname
attribute - without this there were some errors parsing group name out of adjacent Toggle SectionsThings that I should be well tested:
content
of the Toggle Sectiongroup
specified/guides/
view as well (rendered via RemoteMDX)@mradamcox yes, it looks like we were able to prevent the user from adding one Toggle Section within an existing Toggle Section :+1:
{
name: 'content',
label: 'Content',
widget: 'markdown',
// exclude toggle-section from being nested inside of another toggle-section
editor_components: [ "image", "code-block" ],
required: true
},
Adding the editor_components
property allows us to customize which buttons are offered under the +
button in the sub-editor :tada:
Similarly, specifying buttons
lets us choose which buttons are shown on the editor (aside from +
)
For example: choosing buttons: [ "bold" ]
will hide italics, underline, etc and only show the bold
button :+1:
Ok, perfect, thanks for figuring that out. It will make it a lot easier to add custom editor components and only use them in certain instances of the markdown widget. One final request for this PR: Could you add cursor: pointer
style to the summary element, so that the toggle looks a little bit more like a button when you hover over it? After that, ready to merge!
@mradamcox awesome! I was able to add this style pretty easily into our rendered version of the CMS (e.g. /guides/public-transit-equity
)
I didn't see an easy way to adjust this in the DecapCMS preview as well, but I can spend some time to look into that if it is important?
Problem
DecapCMS allows us to create custom editor components to render complex Markdown
Fixes #342
Approach
<details>
/<summary>
toggles as HTMLExample:
Which produces the following HTML:
TODOs
Newline characters withinregex has been adjusted to allow newline characters within collapsible content :+1:content
are not well-supported. This will be problematic for less technical users (supporting which is the whole point of using a CMS system to begin with)Images embedded inwith the corrected newline behavior (see above), this problem appears to have gone away and we can now embed images within collapsible content :+1:content
do not play well with the editor - this may be because of the newline support mentioned aboveHow to Test
title
,content
,group
Title
- this will be the clickable header when the section is collapsedContent
- this will be Markdown that becomes the main content for when the section is expandedGroup
- if specified, only a single section from the same group can be expanded at once