From dc469c089f5a004284ed388794710cf1912ff586 Mon Sep 17 00:00:00 2001 From: Fumihiko Hata Date: Fri, 19 Nov 2021 20:37:07 +0000 Subject: [PATCH] Merge by themes --- ...zola-shortcodes-netlify-cms.DeepThought.js | 9 +- dist/zola-shortcodes-netlify-cms.built-in.js | 3 +- dist/zola-shortcodes-netlify-cms.juice.js | 186 ++++++++++++++++++ 3 files changed, 193 insertions(+), 5 deletions(-) create mode 100644 dist/zola-shortcodes-netlify-cms.juice.js diff --git a/dist/zola-shortcodes-netlify-cms.DeepThought.js b/dist/zola-shortcodes-netlify-cms.DeepThought.js index d57a44a..3ed6c71 100644 --- a/dist/zola-shortcodes-netlify-cms.DeepThought.js +++ b/dist/zola-shortcodes-netlify-cms.DeepThought.js @@ -279,11 +279,11 @@ CMS.registerEditorComponent({ }, toBlock: function(obj) { const id = obj.id || ''; - return `{{ vimeo(id="${obj.id || ''}") }}`; + return `{{ vimeo(id="${id}") }}`; }, toPreview: function(obj) { const id = obj.id || ''; - return `{{ vimeo(id="${obj.id || ''}") }}`; + return `{{ vimeo(id="${id}") }}`; }, }); CMS.registerEditorComponent({ @@ -304,9 +304,10 @@ CMS.registerEditorComponent({ }, toBlock: function(obj) { const id = obj.id || ''; - return `{{ youtube(id="${obj.id || ''}") }}`; + return `{{ youtube(id="${id}") }}`; }, toPreview: function(obj) { - return `Youtube Video`; + const id = obj.id || ''; + return `Youtube Video`; }, }); diff --git a/dist/zola-shortcodes-netlify-cms.built-in.js b/dist/zola-shortcodes-netlify-cms.built-in.js index d5327d9..6aba365 100644 --- a/dist/zola-shortcodes-netlify-cms.built-in.js +++ b/dist/zola-shortcodes-netlify-cms.built-in.js @@ -155,6 +155,7 @@ CMS.registerEditorComponent({ return `{{ youtube(id="${id}"${p}${a}${c}) }}`; }, toPreview: function(obj) { - return `Youtube Video`; + const id = obj.id || ''; + return `Youtube Video`; }, }); diff --git a/dist/zola-shortcodes-netlify-cms.juice.js b/dist/zola-shortcodes-netlify-cms.juice.js new file mode 100644 index 0000000..53c2fb9 --- /dev/null +++ b/dist/zola-shortcodes-netlify-cms.juice.js @@ -0,0 +1,186 @@ +CMS.registerEditorComponent({ + id: "gist", + label: "Gist", + fields: [ + { + name: "username", + label: "Github Username (mandatory)", + widget: "string" + }, + { + name: "gid", + label: "Gist ID (mandatory)", + widget: "string" + }, + { + name: "file", + label: "by default, the shortcode will pull every file from the URL unless a specific filename is requested (optional)", + widget: "string" + }, + { + name: "class", + label: "a class to add to the
surrounding the iframe (optional)", + widget: "string" + }, + ], + pattern: /{{ gist\(url="https:\/\/gist\.github\.com\/([-a-zA-Z0-9]+)\/([a-zA-Z0-9]+)"(, file="([-_.a-zA-Z0-9]+)")?(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/, + fromBlock: function(match) { + return { + username: match[1], + gid: match[2], + file: match[4], + class: match[6], + }; + }, + toBlock: function(obj) { + const gid = obj.gid || ''; + const username = obj.username || ''; + const f = !!obj.file ? `, file="${obj.file}"` : ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ gist(url="https://gist.github.com/${username}/${gid}"${f}${c}) }}`; + }, + toPreview: function(obj) { + const gid = obj.gid || ''; + const username = obj.username || ''; + const f = !!obj.file ? `, file="${obj.file}"` : ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ gist(url="https://gist.github.com/${username}/${gid}"${f}${c}) }}`; + }, +}); +CMS.registerEditorComponent({ + id: "issue", + label: "GitHub Issue", + fields: [ + { + name: "id", + label: "the issue id (mandatory)", + widget: "number" + }, + ], + pattern: /{{ issue\(id=([1-9][0-9]*)\) }}/, + fromBlock: function(match) { + return { + id: match[1], + }; + }, + toBlock: function(obj) { + const id = obj.id || ''; + return `{{ issue(id=${id}) }}`; + }, + toPreview: function(obj) { + const id = obj.id || ''; + return `Github Issue #${id}`; + }, +}); +CMS.registerEditorComponent({ + id: "streamable", + label: "Streamable", + fields: [ + { + name: "id", + label: "the video id (mandatory)", + widget: "string" + }, + { + name: "class", + label: "a class to add to the
surrounding the iframe (optional)", + widget: "string" + }, + ], + pattern: /{{ streamable\(id="([a-zA-Z0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/, + fromBlock: function(match) { + return { + id: match[1], + class: match[3], + }; + }, + toBlock: function(obj) { + const id = obj.id || ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ streamable(id="${id}"${c}) }}`; + }, + toPreview: function(obj) { + const id = obj.id || ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ streamable(id="${id}"${c}) }}`; + }, +}); +CMS.registerEditorComponent({ + id: "vimeo", + label: "Vimeo", + fields: [ + { + name: "id", + label: "the video id (mandatory)", + widget: "string" + }, + { + name: "class", + label: "a class to add to the
surrounding the iframe (optional)", + widget: "string" + }, + ], + pattern: /{{ vimeo\(id="([0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/, + fromBlock: function(match) { + return { + id: match[1], + class: match[3], + }; + }, + toBlock: function(obj) { + const id = obj.id || ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ vimeo(id="${id}"${c}) }}`; + }, + toPreview: function(obj) { + const id = obj.id || ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ vimeo(id="${id}"${c}) }}`; + }, +}); +CMS.registerEditorComponent({ + id: "youtube", + label: "YouTube", + fields: [ + { + name: "id", + label: "the video id (mandatory)", + widget: "string" + }, + { + name: "playlist", + label: "the playlist id (optional)", + widget: "string" + }, + { + name: "autoplay", + label: "when set to \"true\", the video autoplays on load (optional)", + widget: "boolean" + }, + { + name: "class", + label: "a class to add to the
surrounding the iframe (optional)", + widget: "string" + }, + ], + pattern: /{{ youtube\(id="([-a-zA-Z0-9]+)"(, playlist="([a-zA-Z0-9]+)")?(, autoplay=(true|false))?(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/, + fromBlock: function(match) { + return { + id: match[1], + playlist: match[3], + autoplay: match[5], + class: match[7], + }; + }, + toBlock: function(obj) { + const id = obj.id || ''; + const p = !!obj.playlist ? `, playlist="${obj.playlist}"` : ''; + const a = !!obj.autoplay ? `, autoplay=${obj.autoplay}` : ''; + const c = !!obj.class ? `, class="${obj.class}"` : ''; + return `{{ youtube(id="${id}"${p}${a}${c}) }}`; + }, + toPreview: function(obj) { + const id = obj.id || ''; + return `Youtube Video`; + }, +});