Skip to content

Commit

Permalink
Merge by themes
Browse files Browse the repository at this point in the history
  • Loading branch information
hatappo committed Nov 18, 2021
1 parent 95d8f97 commit f9706b8
Show file tree
Hide file tree
Showing 2 changed files with 292 additions and 111 deletions.
279 changes: 228 additions & 51 deletions dist/zola-shortcodes-netlify-cms.DeepThought.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,93 @@
CMS.registerEditorComponent({
id: "chart",
label: "Chart",
fields: [
{
name: "body",
label: "the body text",
widget: "text"
},
],
pattern: /^{% chart\(\) %}\n(.*?)\n^{% end %}$/ms,
fromBlock: function(match) {
return {
body: match[1],
};
},
toBlock: function(obj) {
const body = obj.body || '';
return `
{% chart() %}
${body}
{% end %}
`;
},
toPreview: function(obj) {
const body = obj.body || '';
return `
{% chart() %}
${body}
{% end %}
`;
},
});
CMS.registerEditorComponent({
id: "galleria",
label: "Galleria",
fields: [
{
name: "body",
label: "the body text",
widget: "text"
},
],
pattern: /^{% galleria\(\) %}\n(.*?)\n^{% end %}$/ms,
fromBlock: function(match) {
return {
body: match[1],
};
},
toBlock: function(obj) {
const body = obj.body || '';
return `
{% galleria() %}
${body}
{% end %}
`;
},
toPreview: function(obj) {
const body = obj.body || '';
return `
{% galleria() %}
${body}
{% end %}
`;
},
});
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 <div> surrounding the iframe (optional)",
widget: "string"
},
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 <div> 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) {
Expand All @@ -47,18 +114,134 @@ CMS.registerEditorComponent({
},
});
CMS.registerEditorComponent({
id: "streamable",
label: "Streamable",
fields: [{
name: "id",
label: "the video id (mandatory)",
widget: "string"
id: "katex",
label: "Katex",
fields: [
{
name: "body",
label: "the body text",
widget: "text"
},
{
name: "block",
label: "if true, add `mode=display` into type of the script tag.",
widget: "boolean"
},
],
pattern: /^{% katex\(block=(true|false)\) %}\n(.*?)\n^{% end %}$/ms,
fromBlock: function(match) {
return {
block: match[1],
body: match[2],
};
},
toBlock: function(obj) {
const block = !!obj.block;
const body = obj.body || '';
return `
{% katex(block=${block}) %}
${body}
{% end %}
`;
},
toPreview: function(obj) {
const block = !!obj.block;
const body = obj.body || '';
return `
{% katex(block=${block}) %}
${body}
{% end %}
`;
},
});
CMS.registerEditorComponent({
id: "mapbox",
label: "Mapbox",
fields: [
{
name: "body",
label: "the body text",
widget: "text"
},
{
name: "zoom",
label: "zoom level. see https://docs.mapbox.com/help/glossary/zoom-level/",
widget: "number"
},
],
pattern: /^{% mapbox\(zoom=([0-9]+)\) %}\n(.*?)\n^{% end %}$/ms,
fromBlock: function(match) {
return {
zoom: match[1],
body: match[2],
};
},
toBlock: function(obj) {
const zoom = obj.zoom ?? 10;
const body = obj.body || '';
return `
{% mapbox(zoom=${zoom}) %}
${body}
{% end %}
`;
},
toPreview: function(obj) {
const zoom = obj.zoom ?? 10;
const body = obj.body || '';
return `
{% mapbox(zoom=${zoom}) %}
${body}
{% end %}
`;
},
});
CMS.registerEditorComponent({
id: "mermaid",
label: "Mermaid",
fields: [
{
name: "body",
label: "the body text",
widget: "text"
},
],
pattern: /^{% mermaid\(\) %}\n(.*?)\n^{% end %}$/ms,
fromBlock: function(match) {
return {
body: match[1],
};
},
toBlock: function(obj) {
const body = obj.body || '';
return `
{% mermaid() %}
${body}
{% end %}
`;
},
{
name: "class",
label: "a class to add to the <div> surrounding the iframe (optional)",
widget: "string"
toPreview: function(obj) {
const body = obj.body || '';
return `
{% mermaid() %}
${body}
{% end %}
`;
},
});
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 <div> surrounding the iframe (optional)",
widget: "string"
},
],
pattern: /{{ streamable\(id="([a-zA-Z0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
fromBlock: function(match) {
Expand All @@ -81,43 +264,37 @@ CMS.registerEditorComponent({
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 <div> surrounding the iframe (optional)",
widget: "string"
},
fields: [
{
name: "id",
label: "the video id (mandatory)",
widget: "string"
},
],
pattern: /{{ vimeo\(id="([0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
pattern: /{{ vimeo\(id="([0-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}) }}`;
return `{{ vimeo(id="${obj.id || ''}") }}`;
},
toPreview: function(obj) {
const id = obj.id || '';
const c = !!obj.class ? `, class="${obj.class}"` : '';
return `{{ vimeo(id="${id}"${c}) }}`;
return `{{ vimeo(id="${obj.id || ''}") }}`;
},
});
CMS.registerEditorComponent({
id: "youtube",
label: "YouTube",
fields: [{
name: "id",
label: "the video id (mandatory)",
widget: "string"
},
fields: [
{
name: "id",
label: "the video id (mandatory)",
widget: "string"
},
],
pattern: /{{ youtube\(id="([a-zA-Z0-9]+)"\) }}/,
fromBlock: function(match) {
Expand Down
Loading

0 comments on commit f9706b8

Please sign in to comment.