Skip to content

Commit

Permalink
fix: netlify identity registration link handling
Browse files Browse the repository at this point in the history
  • Loading branch information
pmelab committed Jan 8, 2024
1 parent b8504a7 commit a335194
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions apps/website/gatsby-ssr.ts → apps/website/gatsby-ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import './styles.css';

import { Locale } from '@custom/schema';
import { GatsbySSR } from 'gatsby';
import React from 'react';

export const onRenderBody: GatsbySSR['onRenderBody'] = ({
setHtmlAttributes,
setHeadComponents,
pathname,
}) => {
const locales = Object.values(Locale);
Expand All @@ -24,4 +26,23 @@ export const onRenderBody: GatsbySSR['onRenderBody'] = ({
// We don't know the language.
}
}
// Remove this if Netlify identity is not used.
setHeadComponents([
<script
key="netlify-identity-widget"
src="https://identity.netlify.com/v1/netlify-identity-widget.js"
/>,
<script key="netlify-identity-redirect" dangerouslySetInnerHTML={{
__html: `
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", user => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
}
`}} />
]);
};

0 comments on commit a335194

Please sign in to comment.