| 26 | const pendingMeta = new Map<string, RecentPageMeta>(); |
| 27 | |
| 28 | const readStorage = (): RecentPage[] => { |
| 29 | if (typeof window === 'undefined') { |
| 30 | return []; |
| 31 | } |
| 32 | try { |
| 33 | const raw = window.localStorage.getItem(STORAGE_KEY); |
| 34 | const parsed = raw ? JSON.parse(raw) : []; |
| 35 | if (!Array.isArray(parsed)) { |
| 36 | return []; |
| 37 | } |
| 38 | return parsed.filter( |
| 39 | (item): item is RecentPage => |
| 40 | !!item && |
| 41 | typeof item.path === 'string' && |
| 42 | typeof item.title === 'string', |
| 43 | ); |
| 44 | } catch { |
| 45 | return []; |
| 46 | } |
| 47 | }; |
| 48 | |
| 49 | export const getRecentPages = (): RecentPage[] => { |
| 50 | if (cache === null) { |