Skip to content

Commit

Permalink
Allow markdown/rich editor on figure block, fix toc highlight.
Browse files Browse the repository at this point in the history
Unfortunately, I couldn't get the images uploaded inside the figure block to show in the preview, but they should show after saving.

Fixes #38
Fixes #11
  • Loading branch information
BrunoBernardino committed Sep 14, 2022
1 parent a8cf1f6 commit 1eee609
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
5 changes: 5 additions & 0 deletions _includes/components/section-menu.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
{% set hideChildren = true %}
{% endif %}

{# Special case of pages/URLs with the same starting slug #}
{% if (not hideChildren) and (page.key === "/hilfe/handbuch/mitarbeiter-app" or page.key === "/hilfe/handbuch/mitarbeiter") and (eleventyNavigation.key === "/hilfe/handbuch/mitarbeiter-app" or eleventyNavigation.key === "/hilfe/handbuch/mitarbeiter") and (page.key !== eleventyNavigation.key) %}
{% set hideChildren = true %}
{% endif %}

{% if hideChildren %}
{% set hiddenAttribute = "hidden" %}
{% endif %}
Expand Down
25 changes: 16 additions & 9 deletions admin/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@
<link rel="preload" href="https://fonts.gstatic.com/s/nunito/v16/XRXV3I6Li01BKofINeaBTMnFcQ.woff2" as="font"
type="font/woff2" crossorigin />
<script src="https://unpkg.com/netlify-cms@2.10.192/dist/netlify-cms.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/13.0.1/markdown-it.min.js" integrity="sha512-SYfDUYPg5xspsG6OOpXU366G8SZsdHOhqk/icdrYJ2E/WKZxPxze7d2HD3AyXpT7U22PZ5y74xRpqZ6A2bJ+kQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
(() => {
const md = window.markdownit({
html: true,
});
CMS.registerPreviewStyle("/admin/base-preview.css");
CMS.registerPreviewStyle("/admin/news-preview.css");
CMS.registerPreviewStyle("/admin/magazin-preview.css");
Expand Down Expand Up @@ -195,7 +200,7 @@
{
name: 'body',
label: 'HTML',
widget: 'text',
widget: 'markdown',
required: true,
}
],
Expand All @@ -208,19 +213,21 @@
};
},
toBlock: function (data) {
const bodyHtml = md.renderInline(data.body || '');
return `
<figure class="${data.extraClass}">
${data.body}
<figcaption>${data.caption}</figcaption>
</figure>
<figure class="${data.extraClass}">
${bodyHtml}
<figcaption>${data.caption}</figcaption>
</figure>
`;
},
toPreview: function (data) {
const bodyHtml = md.renderInline(data.body || '');
return `
<figure class="${data.extraClass}">
${data.body}
<figcaption>${data.caption}</figcaption>
</figure>
<figure class="${data.extraClass}">
${bodyHtml}
<figcaption>${data.caption}</figcaption>
</figure>
`;
}
});
Expand Down

0 comments on commit 1eee609

Please sign in to comment.