mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
Update blog layout. PR breakdown of #43455 Related: #47226 #47227 #47228
18 lines
675 B
TypeScript
18 lines
675 B
TypeScript
export type BlogView = 'list' | 'grid'
|
|
|
|
export const BLOG_VIEW_COOKIE = 'blog-view'
|
|
|
|
export function isBlogView(value: string | undefined | null): value is BlogView {
|
|
return value === 'list' || value === 'grid'
|
|
}
|
|
|
|
/**
|
|
* Persist the list/grid preference in a cookie so the server can render the
|
|
* correct view on the next load. Storing it client-side (localStorage) caused a
|
|
* hydration flicker: the server rendered the default `list`, then the client
|
|
* swapped to `grid`. Client-side only — call from an event handler.
|
|
*/
|
|
export function setBlogViewCookie(view: BlogView) {
|
|
document.cookie = `${BLOG_VIEW_COOKIE}=${view}; path=/; max-age=31536000; samesite=lax`
|
|
}
|