Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add netlify-identity submodule #147

Merged
merged 12 commits into from
Feb 9, 2024
10 changes: 6 additions & 4 deletions layouts/_default/decap-cms.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
{{- else }}
{{- warnf "[decap-cms] please append %q into the %q output in configuration." "DecapCMSConfig" "home" }}
{{- end }}
{{ partialCached "decap-cms/hooks/head-end" . }}
{{- partialCached "decap-cms/hooks/head-end" . }}
{{- partial "hugopress/functions/render-hooks" (dict "Name" "decap-cms-head-end" "Page" .) }}
</head>
<body>
{{ partialCached "decap-cms/script" . }}
{{ partialCached "decap-cms/init" . }}
{{ partialCached "decap-cms/hooks/body-end" . }}
{{- partialCached "decap-cms/script" . }}
{{- partialCached "decap-cms/init" . }}
{{- partialCached "decap-cms/hooks/body-end" . }}
{{- partial "hugopress/functions/render-hooks" (dict "Name" "decap-cms-body-end" "Page" .) }}
</body>
</html>
9 changes: 9 additions & 0 deletions modules/netlify-identity/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Netlify Identity Support for Decap CMS

variables are:

```toml
[params.decap_cms._netlify_identity]
admin_path = "/admin/"
js_url = "https://identity.netlify.com/v1/netlify-identity-widget.js"
```
3 changes: 3 additions & 0 deletions modules/netlify-identity/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/hugomods/decap-cms/modules/netlify-identity

go 1.18
13 changes: 13 additions & 0 deletions modules/netlify-identity/hugo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[[module.imports]]
path = "github.com/hugomods/decap-cms"

[params.hugopress.modules.decap-cms-netlify-identity.hooks.head-end]

[params.hugopress.modules.decap-cms-netlify-identity.hooks.body-end]

[params.hugopress.modules.decap-cms-netlify-identity.hooks.decap-cms-head-end]
cacheable = true

[params.decap_cms._netlify_identity]
admin_path = "/admin/"
js_url = "https://identity.netlify.com/v1/netlify-identity-widget.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Page.IsHome }}
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", user => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = {{ site.Params.decap_cms._netlify_identity.admin_path }};
});
}
});
}
</script>
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script src="{{ site.Params.decap_cms._netlify_identity.js_url }}"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{{- if .Page.IsHome }}
<script src="{{ site.Params.decap_cms._netlify_identity.js_url }}"></script>
{{- end }}