v1.4 - added admin page and auth
This commit is contained in:
parent
5efdafbb97
commit
1f0aa3078f
29 changed files with 5264 additions and 217 deletions
30
src/lib/adminTitle.tsx
Normal file
30
src/lib/adminTitle.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
ADMIN TITLE
|
||||
|
||||
The layout knows which section you're in; only the page knows
|
||||
which record is on screen. Rather than have both write
|
||||
document.title and race — child effects run before parent
|
||||
effects, so the layout would win and the record name would
|
||||
never survive — the page publishes a string and the layout is
|
||||
the single writer.
|
||||
|
||||
Null is the normal state. A page that publishes nothing, or one
|
||||
still loading, simply leaves the section title showing.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
import { createContext, useContext, useEffect } from "react";
|
||||
|
||||
export const AdminTitleContext = createContext(null);
|
||||
|
||||
/* Publish the name of whatever this page is showing. Clears on
|
||||
unmount, so navigating away can't leave a stale record name in
|
||||
the tab. */
|
||||
export function useAdminDetail(name) {
|
||||
const setDetail = useContext(AdminTitleContext)?.setDetail;
|
||||
|
||||
useEffect(() => {
|
||||
if (!setDetail) return undefined;
|
||||
setDetail(name || null);
|
||||
return () => setDetail(null);
|
||||
}, [setDetail, name]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue