├── .github
├── FUNDING.yml
└── workflows
│ └── merger.yml
├── LICENSE
├── README.md
├── all_sc_ncms.png
├── dist
└── hugo_shortcodes_netlify_cms.js
├── shorc_list.png
└── src
├── figure.js
├── gist.js
├── instagram.js
├── twitter.js
├── vimeo.js
└── youtube.js
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | github: sharadcodes
2 |
--------------------------------------------------------------------------------
/.github/workflows/merger.yml:
--------------------------------------------------------------------------------
1 | name: Merger CI
2 | on:
3 | push:
4 | branches: [ master ]
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - uses: actions/checkout@v3
10 | - name: Run a multi-line script
11 | run: |
12 | mkdir -p dist
13 | cat src/*.js > dist/hugo_shortcodes_netlify_cms.js
14 | - name: Add & Commit files
15 | run: |
16 | git config --local user.email "dev_sharad@outlook.com"
17 | git config --local user.name "sharadcodes"
18 | git add .
19 | git commit -m "Added Changes & Merged File" -a
20 | git push -f -q https://${{ secrets.GITHUB_TOKEN }}@github.com/sharadcodes/hugo-shortcodes-netlify-cms.git master
21 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 SHARAD RAJ
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
Hugo Shortcodes for Netlify CMS editor
3 |
4 |
5 |
6 |
7 |
8 | ---
9 |
10 | A collection of js files for shortcodes of Hugo that enables blocks in Netlify CMS Text Editor.
11 |
12 | ## List of shortcodes for the text editor
13 | 1. [Gist](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/gist.js)
14 | 2. [Youtube](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/youtube.js)
15 | 3. [Vimeo](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/vimeo.js)
16 | 4. [Twitter](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/twitter.js)
17 | 5. [Instagram](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/instagram.js)
18 | 6. [Figure](https://github.com/sharadcodes/hugo-shortcodes-netlify-cms/blob/master/src/figure.js)
19 |
20 | ## USAGE
21 |
22 | Add the following after the script tag of **Netlify CMS**
23 |
24 | ```html
25 |
26 | ```
27 |
28 | ## Asking for support!
29 |
30 | Hello everyone, If you have used this theme and if it has helped you in any way or if you just want to support me for my open source work, you can support me by donating any amount.
31 |
32 | You can use the sponsor button at the top or on the right.
33 |
34 | ### [Github Sponsor Page](https://github.com/sponsors/sharadcodes)
35 |
36 | ---
37 |
38 | ## SCREENSHOT OF DROPDOWN
39 | 
40 | ## SCREENSHOT OF UI
41 | 
42 |
43 | ---
44 |
45 | # Resources
46 |
47 | ## Themes
48 | So I've created some HUGO themes which are listed below, you may want to have a look because they look amazing :)
49 |
50 | * [Hugo Theme Serial Programmer](https://github.com/sharadcodes/hugo-theme-serial-programmer) ([Live Demo](https://sharadcodes.github.io/hugo-theme-serial-programmer/)), this theme is also available for Jekyll & Gatsby.
51 |
--------------------------------------------------------------------------------
/all_sc_ncms.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharadcodes/hugo-shortcodes-netlify-cms/db7e761d76851db9741a6327b859278621ed830f/all_sc_ncms.png
--------------------------------------------------------------------------------
/dist/hugo_shortcodes_netlify_cms.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "figure",
3 | label: "Figure",
4 | fields: [{
5 | name: "title",
6 | label: "Figure Title",
7 | widget: "string"
8 | },
9 | {
10 | name: "src",
11 | label: "Figure SRC",
12 | widget: "string"
13 | },
14 | ],
15 | pattern: /{{< figure src="([a-zA-Z0-9-_ ]+)" title="([a-zA-Z0-9-_ ]+)" >}}/,
16 | fromBlock: function(match) {
17 | return {
18 | title: match[1],
19 | src: match[2],
20 | };
21 | },
22 | toBlock: function(obj) {
23 | return `{{< figure src="${obj.src}" title="${obj.title}" >}}`;
24 | },
25 | toPreview: function(obj) {
26 | return `${obj.title} `;
27 | },
28 | });
29 | CMS.registerEditorComponent({
30 | id: "gist",
31 | label: "Gist",
32 | fields: [{
33 | name: "username",
34 | label: "Github Username",
35 | widget: "string"
36 | },
37 | {
38 | name: "gid",
39 | label: "Gist ID",
40 | widget: "string"
41 | },
42 | ],
43 | pattern: /{{< gist ([a-zA-Z0-9]+) ([a-zA-Z0-9]+) >}}/,
44 | fromBlock: function(match) {
45 | return {
46 | username: match[1],
47 | gid: match[2],
48 | };
49 | },
50 | toBlock: function(obj) {
51 | return `{{< gist ${obj.username} ${obj.gid} >}}`;
52 | },
53 | toPreview: function(obj) {
54 | return `{{< gist ${obj.username} ${obj.gid} >}}`;
55 | },
56 | });
57 | CMS.registerEditorComponent({
58 | id: "instagram",
59 | label: "Instagram",
60 | fields: [
61 | {
62 | name: "pid",
63 | label: "Post id",
64 | widget: "string"
65 | },
66 | {
67 | name: "hidecaption",
68 | label: "Hide caption",
69 | widget: "boolean"
70 | }
71 | ],
72 | pattern: /{{< instagram (?[a-zA-Z0-9]+)\s{0,}(?hidecaption)?\s+>}}/,
73 | fromBlock: function(match) {
74 | return {
75 | pid: match[1],
76 | hidecaption: match[2]
77 | };
78 | },
79 | toBlock: function(obj) {
80 | return `{{< instagram ${obj.pid} ${
81 | obj.hidecaption ? "hidecaption " : ""
82 | }>}}`;
83 | },
84 | toPreview: function(obj) {
85 | return `{{< instagram ${obj.pid} ${
86 | obj.hidecaption ? "hidecaption " : ""
87 | }>}}`;
88 | },
89 | });
90 | CMS.registerEditorComponent({
91 | id: "twitter",
92 | label: "Twitter",
93 | fields: [{
94 | name: "tid",
95 | label: "Tweet id",
96 | widget: "string"
97 | }],
98 | pattern: /{{< tweet ([a-zA-Z0-9]+) >}}/,
99 | fromBlock: function(match) {
100 | return {
101 | tid: match[1]
102 | };
103 | },
104 | toBlock: function(obj) {
105 | return `{{< tweet ${obj.tid} >}}`;
106 | },
107 | toPreview: function(obj) {
108 | return `{{< tweet ${obj.tid} >}}`;
109 | },
110 | });
111 | CMS.registerEditorComponent({
112 | id: "vimeo",
113 | label: "Vimeo",
114 | fields: [{
115 | name: "shortcode",
116 | label: "Vimeo shortcode",
117 | widget: "string"
118 | }],
119 | pattern: /{{< vimeo ([a-zA-Z0-9]+) >}}/,
120 | fromBlock: function(match) {
121 | return {
122 | shortcode: match[1]
123 | };
124 | },
125 | toBlock: function(obj) {
126 | return `{{< vimeo ${obj.shortcode} >}}`;
127 | },
128 | toPreview: function(obj) {
129 | return `{{< vimeo ${obj.shortcode} >}}`;
130 | },
131 | });
132 | CMS.registerEditorComponent({
133 | id: "youtube",
134 | label: "Youtube",
135 | fields: [{
136 | name: "id",
137 | label: "Youtube Video ID",
138 | widget: "string"
139 | }],
140 | pattern: /{{< youtube\s+(?[A-Za-z0-9\-]+)\s+>}}/,
141 | fromBlock: function(match) {
142 | return {
143 | id: match[1],
144 | };
145 | },
146 | toBlock: function(obj) {
147 | return `{{< youtube ${obj.id} >}}`;
148 | },
149 | toPreview: function(obj) {
150 | return ` `;
151 | },
152 | });
153 |
--------------------------------------------------------------------------------
/shorc_list.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sharadcodes/hugo-shortcodes-netlify-cms/db7e761d76851db9741a6327b859278621ed830f/shorc_list.png
--------------------------------------------------------------------------------
/src/figure.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "figure",
3 | label: "Figure",
4 | fields: [{
5 | name: "title",
6 | label: "Figure Title",
7 | widget: "string"
8 | },
9 | {
10 | name: "src",
11 | label: "Figure SRC",
12 | widget: "string"
13 | },
14 | ],
15 | pattern: /{{< figure src="([a-zA-Z0-9-_ ]+)" title="([a-zA-Z0-9-_ ]+)" >}}/,
16 | fromBlock: function(match) {
17 | return {
18 | title: match[1],
19 | src: match[2],
20 | };
21 | },
22 | toBlock: function(obj) {
23 | return `{{< figure src="${obj.src}" title="${obj.title}" >}}`;
24 | },
25 | toPreview: function(obj) {
26 | return `${obj.title} `;
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/src/gist.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "gist",
3 | label: "Gist",
4 | fields: [{
5 | name: "username",
6 | label: "Github Username",
7 | widget: "string"
8 | },
9 | {
10 | name: "gid",
11 | label: "Gist ID",
12 | widget: "string"
13 | },
14 | ],
15 | pattern: /{{< gist ([a-zA-Z0-9]+) ([a-zA-Z0-9]+) >}}/,
16 | fromBlock: function(match) {
17 | return {
18 | username: match[1],
19 | gid: match[2],
20 | };
21 | },
22 | toBlock: function(obj) {
23 | return `{{< gist ${obj.username} ${obj.gid} >}}`;
24 | },
25 | toPreview: function(obj) {
26 | return `{{< gist ${obj.username} ${obj.gid} >}}`;
27 | },
28 | });
29 |
--------------------------------------------------------------------------------
/src/instagram.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "instagram",
3 | label: "Instagram",
4 | fields: [
5 | {
6 | name: "pid",
7 | label: "Post id",
8 | widget: "string"
9 | },
10 | {
11 | name: "hidecaption",
12 | label: "Hide caption",
13 | widget: "boolean"
14 | }
15 | ],
16 | pattern: /{{< instagram (?[a-zA-Z0-9]+)\s{0,}(?hidecaption)?\s+>}}/,
17 | fromBlock: function(match) {
18 | return {
19 | pid: match[1],
20 | hidecaption: match[2]
21 | };
22 | },
23 | toBlock: function(obj) {
24 | return `{{< instagram ${obj.pid} ${
25 | obj.hidecaption ? "hidecaption " : ""
26 | }>}}`;
27 | },
28 | toPreview: function(obj) {
29 | return `{{< instagram ${obj.pid} ${
30 | obj.hidecaption ? "hidecaption " : ""
31 | }>}}`;
32 | },
33 | });
34 |
--------------------------------------------------------------------------------
/src/twitter.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "twitter",
3 | label: "Twitter",
4 | fields: [{
5 | name: "tid",
6 | label: "Tweet id",
7 | widget: "string"
8 | }],
9 | pattern: /{{< tweet ([a-zA-Z0-9]+) >}}/,
10 | fromBlock: function(match) {
11 | return {
12 | tid: match[1]
13 | };
14 | },
15 | toBlock: function(obj) {
16 | return `{{< tweet ${obj.tid} >}}`;
17 | },
18 | toPreview: function(obj) {
19 | return `{{< tweet ${obj.tid} >}}`;
20 | },
21 | });
22 |
--------------------------------------------------------------------------------
/src/vimeo.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "vimeo",
3 | label: "Vimeo",
4 | fields: [{
5 | name: "shortcode",
6 | label: "Vimeo shortcode",
7 | widget: "string"
8 | }],
9 | pattern: /{{< vimeo ([a-zA-Z0-9]+) >}}/,
10 | fromBlock: function(match) {
11 | return {
12 | shortcode: match[1]
13 | };
14 | },
15 | toBlock: function(obj) {
16 | return `{{< vimeo ${obj.shortcode} >}}`;
17 | },
18 | toPreview: function(obj) {
19 | return `{{< vimeo ${obj.shortcode} >}}`;
20 | },
21 | });
22 |
--------------------------------------------------------------------------------
/src/youtube.js:
--------------------------------------------------------------------------------
1 | CMS.registerEditorComponent({
2 | id: "youtube",
3 | label: "Youtube",
4 | fields: [{
5 | name: "id",
6 | label: "Youtube Video ID",
7 | widget: "string"
8 | }],
9 | pattern: /{{< youtube\s+(?[A-Za-z0-9\-]+)\s+>}}/,
10 | fromBlock: function(match) {
11 | return {
12 | id: match[1],
13 | };
14 | },
15 | toBlock: function(obj) {
16 | return `{{< youtube ${obj.id} >}}`;
17 | },
18 | toPreview: function(obj) {
19 | return ` `;
20 | },
21 | });
22 |
--------------------------------------------------------------------------------