astro-netlify-cms icon indicating copy to clipboard operation
astro-netlify-cms copied to clipboard

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

Open preetamslot opened this issue 1 year ago • 2 comments

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>

preetamslot avatar Aug 17 '22 17:08 preetamslot

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.

delucis avatar Aug 17 '22 18:08 delucis

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

preetamslot avatar Aug 17 '22 19:08 preetamslot