Fix TypeScript errors for Netlify Identity integration
- Add proper TypeScript types for Netlify Identity in env.d.ts - Define NetlifyUser and NetlifyIdentity interfaces - Fix ESLint errors by removing 'any' types - Add optional chaining for safe access - Apply code formatting with Prettier All TypeScript, ESLint, and Prettier checks now pass successfully. 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vendored
+25
@@ -3,3 +3,28 @@
|
||||
/// <reference types="astro/client" />
|
||||
/// <reference types="vite/client" />
|
||||
/// <reference types="../vendor/integration/types.d.ts" />
|
||||
|
||||
// Netlify Identity types
|
||||
interface NetlifyUser {
|
||||
id: string;
|
||||
email: string;
|
||||
user_metadata: Record<string, unknown>;
|
||||
app_metadata: Record<string, unknown>;
|
||||
}
|
||||
|
||||
interface NetlifyIdentity {
|
||||
on: (event: string, callback: (user?: NetlifyUser) => void) => void;
|
||||
init: () => void;
|
||||
open: () => void;
|
||||
close: () => void;
|
||||
currentUser: () => NetlifyUser | null;
|
||||
logout: () => void;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
netlifyIdentity?: NetlifyIdentity;
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
@@ -35,7 +35,7 @@ const { language, textDirection } = I18N;
|
||||
<Metadata {...metadata} />
|
||||
<SiteVerification />
|
||||
<Analytics />
|
||||
|
||||
|
||||
<!-- Netlify Identity for Decap CMS -->
|
||||
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
|
||||
|
||||
@@ -47,14 +47,14 @@ const { language, textDirection } = I18N;
|
||||
<slot />
|
||||
|
||||
<BasicScripts />
|
||||
|
||||
|
||||
<!-- Netlify Identity initialization -->
|
||||
<script>
|
||||
if (window.netlifyIdentity) {
|
||||
window.netlifyIdentity.on("init", user => {
|
||||
window.netlifyIdentity.on('init', (user) => {
|
||||
if (!user) {
|
||||
window.netlifyIdentity.on("login", () => {
|
||||
document.location.href = "/admin/";
|
||||
window.netlifyIdentity?.on('login', () => {
|
||||
document.location.href = '/admin/';
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,4 +12,4 @@
|
||||
<body>
|
||||
<p>Redirecting to CMS...</p>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user