Fix theme cookie parsing
This commit is contained in:
parent
c2a55bb5e3
commit
4bf1609b24
@ -116,14 +116,13 @@ async function setTheme(context: RequestContext) {
|
|||||||
|
|
||||||
const cookieList = cookies.split("; ");
|
const cookieList = cookies.split("; ");
|
||||||
|
|
||||||
const value = cookieList.find((c) => {
|
const themeCookie = cookieList.find((c) =>
|
||||||
if (!c.startsWith("chakra-ui-color-mode")) return false;
|
c.startsWith("chakra-ui-color-mode")
|
||||||
|
);
|
||||||
|
const theme = themeCookie?.split("=").at(1);
|
||||||
|
|
||||||
return c.split("=")[1];
|
if (!theme) context.data.theme = "dark";
|
||||||
});
|
else context.data.theme = theme;
|
||||||
|
|
||||||
if (!value) context.data.theme = "dark";
|
|
||||||
else context.data.theme = value;
|
|
||||||
|
|
||||||
return await context.next();
|
return await context.next();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user