Skip to content

Commit dc469c0

Browse files
committed
Merge by themes
1 parent 694cdee commit dc469c0

File tree

3 files changed

+193
-5
lines changed

3 files changed

+193
-5
lines changed

dist/zola-shortcodes-netlify-cms.DeepThought.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,11 +279,11 @@ CMS.registerEditorComponent({
279279
},
280280
toBlock: function(obj) {
281281
const id = obj.id || '';
282-
return `{{ vimeo(id="${obj.id || ''}") }}`;
282+
return `{{ vimeo(id="${id}") }}`;
283283
},
284284
toPreview: function(obj) {
285285
const id = obj.id || '';
286-
return `{{ vimeo(id="${obj.id || ''}") }}`;
286+
return `{{ vimeo(id="${id}") }}`;
287287
},
288288
});
289289
CMS.registerEditorComponent({
@@ -304,9 +304,10 @@ CMS.registerEditorComponent({
304304
},
305305
toBlock: function(obj) {
306306
const id = obj.id || '';
307-
return `{{ youtube(id="${obj.id || ''}") }}`;
307+
return `{{ youtube(id="${id}") }}`;
308308
},
309309
toPreview: function(obj) {
310-
return `<img src="http://img.youtube.com/vi/${obj.id}/mqdefault.jpg" alt="Youtube Video"/>`;
310+
const id = obj.id || '';
311+
return `<img src="http://img.youtube.com/vi/${id}/mqdefault.jpg" alt="Youtube Video"/>`;
311312
},
312313
});

dist/zola-shortcodes-netlify-cms.built-in.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ CMS.registerEditorComponent({
155155
return `{{ youtube(id="${id}"${p}${a}${c}) }}`;
156156
},
157157
toPreview: function(obj) {
158-
return `<img src="http://img.youtube.com/vi/${obj.id}/mqdefault.jpg" alt="Youtube Video"/>`;
158+
const id = obj.id || '';
159+
return `<img src="http://img.youtube.com/vi/${id}/mqdefault.jpg" alt="Youtube Video"/>`;
159160
},
160161
});
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
CMS.registerEditorComponent({
2+
id: "gist",
3+
label: "Gist",
4+
fields: [
5+
{
6+
name: "username",
7+
label: "Github Username (mandatory)",
8+
widget: "string"
9+
},
10+
{
11+
name: "gid",
12+
label: "Gist ID (mandatory)",
13+
widget: "string"
14+
},
15+
{
16+
name: "file",
17+
label: "by default, the shortcode will pull every file from the URL unless a specific filename is requested (optional)",
18+
widget: "string"
19+
},
20+
{
21+
name: "class",
22+
label: "a class to add to the <div> surrounding the iframe (optional)",
23+
widget: "string"
24+
},
25+
],
26+
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 ]*)")?\) }}/,
27+
fromBlock: function(match) {
28+
return {
29+
username: match[1],
30+
gid: match[2],
31+
file: match[4],
32+
class: match[6],
33+
};
34+
},
35+
toBlock: function(obj) {
36+
const gid = obj.gid || '';
37+
const username = obj.username || '';
38+
const f = !!obj.file ? `, file="${obj.file}"` : '';
39+
const c = !!obj.class ? `, class="${obj.class}"` : '';
40+
return `{{ gist(url="https://gist.github.com/${username}/${gid}"${f}${c}) }}`;
41+
},
42+
toPreview: function(obj) {
43+
const gid = obj.gid || '';
44+
const username = obj.username || '';
45+
const f = !!obj.file ? `, file="${obj.file}"` : '';
46+
const c = !!obj.class ? `, class="${obj.class}"` : '';
47+
return `{{ gist(url="https://gist.github.com/${username}/${gid}"${f}${c}) }}`;
48+
},
49+
});
50+
CMS.registerEditorComponent({
51+
id: "issue",
52+
label: "GitHub Issue",
53+
fields: [
54+
{
55+
name: "id",
56+
label: "the issue id (mandatory)",
57+
widget: "number"
58+
},
59+
],
60+
pattern: /{{ issue\(id=([1-9][0-9]*)\) }}/,
61+
fromBlock: function(match) {
62+
return {
63+
id: match[1],
64+
};
65+
},
66+
toBlock: function(obj) {
67+
const id = obj.id || '';
68+
return `{{ issue(id=${id}) }}`;
69+
},
70+
toPreview: function(obj) {
71+
const id = obj.id || '';
72+
return `<a href="">Github Issue #${id}</a>`;
73+
},
74+
});
75+
CMS.registerEditorComponent({
76+
id: "streamable",
77+
label: "Streamable",
78+
fields: [
79+
{
80+
name: "id",
81+
label: "the video id (mandatory)",
82+
widget: "string"
83+
},
84+
{
85+
name: "class",
86+
label: "a class to add to the <div> surrounding the iframe (optional)",
87+
widget: "string"
88+
},
89+
],
90+
pattern: /{{ streamable\(id="([a-zA-Z0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
91+
fromBlock: function(match) {
92+
return {
93+
id: match[1],
94+
class: match[3],
95+
};
96+
},
97+
toBlock: function(obj) {
98+
const id = obj.id || '';
99+
const c = !!obj.class ? `, class="${obj.class}"` : '';
100+
return `{{ streamable(id="${id}"${c}) }}`;
101+
},
102+
toPreview: function(obj) {
103+
const id = obj.id || '';
104+
const c = !!obj.class ? `, class="${obj.class}"` : '';
105+
return `{{ streamable(id="${id}"${c}) }}`;
106+
},
107+
});
108+
CMS.registerEditorComponent({
109+
id: "vimeo",
110+
label: "Vimeo",
111+
fields: [
112+
{
113+
name: "id",
114+
label: "the video id (mandatory)",
115+
widget: "string"
116+
},
117+
{
118+
name: "class",
119+
label: "a class to add to the <div> surrounding the iframe (optional)",
120+
widget: "string"
121+
},
122+
],
123+
pattern: /{{ vimeo\(id="([0-9]+)"(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
124+
fromBlock: function(match) {
125+
return {
126+
id: match[1],
127+
class: match[3],
128+
};
129+
},
130+
toBlock: function(obj) {
131+
const id = obj.id || '';
132+
const c = !!obj.class ? `, class="${obj.class}"` : '';
133+
return `{{ vimeo(id="${id}"${c}) }}`;
134+
},
135+
toPreview: function(obj) {
136+
const id = obj.id || '';
137+
const c = !!obj.class ? `, class="${obj.class}"` : '';
138+
return `{{ vimeo(id="${id}"${c}) }}`;
139+
},
140+
});
141+
CMS.registerEditorComponent({
142+
id: "youtube",
143+
label: "YouTube",
144+
fields: [
145+
{
146+
name: "id",
147+
label: "the video id (mandatory)",
148+
widget: "string"
149+
},
150+
{
151+
name: "playlist",
152+
label: "the playlist id (optional)",
153+
widget: "string"
154+
},
155+
{
156+
name: "autoplay",
157+
label: "when set to \"true\", the video autoplays on load (optional)",
158+
widget: "boolean"
159+
},
160+
{
161+
name: "class",
162+
label: "a class to add to the <div> surrounding the iframe (optional)",
163+
widget: "string"
164+
},
165+
],
166+
pattern: /{{ youtube\(id="([-a-zA-Z0-9]+)"(, playlist="([a-zA-Z0-9]+)")?(, autoplay=(true|false))?(, class="([a-zA-Z][-_.:a-zA-Z0-9 ]*)")?\) }}/,
167+
fromBlock: function(match) {
168+
return {
169+
id: match[1],
170+
playlist: match[3],
171+
autoplay: match[5],
172+
class: match[7],
173+
};
174+
},
175+
toBlock: function(obj) {
176+
const id = obj.id || '';
177+
const p = !!obj.playlist ? `, playlist="${obj.playlist}"` : '';
178+
const a = !!obj.autoplay ? `, autoplay=${obj.autoplay}` : '';
179+
const c = !!obj.class ? `, class="${obj.class}"` : '';
180+
return `{{ youtube(id="${id}"${p}${a}${c}) }}`;
181+
},
182+
toPreview: function(obj) {
183+
const id = obj.id || '';
184+
return `<img src="http://img.youtube.com/vi/${id}/mqdefault.jpg" alt="Youtube Video"/>`;
185+
},
186+
});

0 commit comments

Comments
 (0)