79783531

Date: 2025-10-06 09:52:06
Score: 1.5
Natty:
Report link

My reply to @ztakoz didn't got formatted properly so here goes...

This code snippet will check for light or dark in the cookie and will force it to default to dark if cookie is not set to either one of those.

!['light', 'dark'].includes(localStorage.getItem('STRAPI_THEME')) ? localStorage.setItem('STRAPI_THEME', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : null;
Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @ztakoz
  • Low reputation (1):
Posted by: Marc Andersson