Skip to content

Commit 08b66c1

Browse files
committed
add Netlify CMS
Signed-off-by: Atharva Kunte <athu.kunte@gmail.com>
1 parent 0e55481 commit 08b66c1

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

src/_includes/base.njk

+13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<script defer src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
78
<link rel="stylesheet" href="/main.css">
89
<link rel="preconnect" href="https://fonts.googleapis.com">
910
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@@ -15,5 +16,17 @@
1516
{% include "header.njk" %}
1617
{{ content | safe }}
1718
{% include "footer.njk" %}
19+
20+
<script>
21+
if (window.netlifyIdentity) {
22+
window.netlifyIdentity.on("init", user => {
23+
if (!user) {
24+
window.netlifyIdentity.on("login", () => {
25+
document.location.href = "/admin/";
26+
});
27+
}
28+
});
29+
}
30+
</script>
1831
</body>
1932
</html>

src/admin/config.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
backend:
2+
name: git-gateway
3+
branch: master
4+
publish_mode: editorial_workflow
5+
media_folder: "src/media"
6+
public_folder: "/media"
7+
collections:
8+
- name: "blog"
9+
label: "Blog"
10+
folder: "src/blog"
11+
create: true
12+
slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
13+
fields:
14+
- { label: "Title", name: "title", widget: "string" }
15+
- { label: "Description", name: "description", widget: "string" }
16+
- { label: "Author", name: "author", widget: "string" }
17+
- { label: "Date", name: "date", widget: "datetime" }
18+
- { label: "Tags", name: "tags", widget: "list", default: ["post"] }
19+
- { label: "Featured Image", name: "image", widget: "image" }
20+
- { label: "Alt Text", name: "imageAlt", widget: "string" }
21+
- { label: "Post Body", name: "body", widget: "markdown" }

src/admin/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
7+
<title>Content Manager</title>
8+
</head>
9+
<body>
10+
<!-- Include the script that builds the page and powers Netlify CMS -->
11+
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)