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:
Buğra
2025-07-10 01:01:12 +03:00
parent 733be12298
commit a9dce67054
6 changed files with 75 additions and 13 deletions
+25
View File
@@ -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 {};
+5 -5
View File
@@ -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/';
});
}
});
+1 -1
View File
@@ -12,4 +12,4 @@
<body>
<p>Redirecting to CMS...</p>
</body>
</html>
</html>