delucis / astro-netlify-cms

Integration to add Netlify CMS’s admin dashboard to any Astro project
161 stars 21 forks source link

is it posible to only load the identity-widget on the /admin route? #14

Closed preetamslot closed 1 year ago

preetamslot commented 2 years ago

At the moment the identity widget + the webpack://components/modal.css is served on every page. those 2 are the biggest files on every page.

is there a way to bind the scripts and styles to the /admin only?

We then can just have a small function on the homepage that looks if there is a password reset #hash present and redirect to the admin.

https://www.my-website.com/#recovery_token=<token> => https://www.my-website.com/admin/#recovery_token=<token>

delucis commented 2 years ago

Yes, I think this would be possible! It’s included by default because as you say, you need something to pick up the log-in when a user is redirected back to the site, but could make it optional. The widget is injected into pages here:

https://github.com/delucis/astro-netlify-cms/blob/0a182dc7f844889891aba970ce5bc4ddf98909ab/integration/index.ts#L45-L48

Would be reasonably straightforward to add a disableIdentityWidgetInjection option and skip that injectScript call if that’s true.

preetamslot commented 2 years ago

That would be great! I will take a look at a function for the admin redirect(s).