feat(app): fetch root manifest
This commit is contained in:
@@ -3,12 +3,14 @@ import { Kitty } from "./components/Kitty";
|
|||||||
import { AppProvider } from "./providers/AppProvider";
|
import { AppProvider } from "./providers/AppProvider";
|
||||||
import { Music } from "./components/Music";
|
import { Music } from "./components/Music";
|
||||||
import { Nvim } from "./components/Nvim";
|
import { Nvim } from "./components/Nvim";
|
||||||
|
import { BrowserRouter } from "react-router-dom";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [loggedIn, setLoggedIn] = useState(false);
|
const [loggedIn, setLoggedIn] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppProvider>
|
<AppProvider>
|
||||||
|
<BrowserRouter>
|
||||||
<main className="h-screen w-screen overflow-hidden bg-[url(/wallpaper.jpg)] bg-cover">
|
<main className="h-screen w-screen overflow-hidden bg-[url(/wallpaper.jpg)] bg-cover">
|
||||||
{loggedIn ? (
|
{loggedIn ? (
|
||||||
<div className="flex h-full w-full flex-col">
|
<div className="flex h-full w-full flex-col">
|
||||||
@@ -29,6 +31,7 @@ export default function App() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
|
</BrowserRouter>
|
||||||
</AppProvider>
|
</AppProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
import { createContext } from "react";
|
import { createContext } from "react";
|
||||||
|
import { type RootManifest } from "~/utils/types";
|
||||||
|
|
||||||
export const AppContext = createContext<
|
export const AppContext = createContext<
|
||||||
{ activeKitty: string; setActiveKitty: (value: string) => void } | undefined
|
| {
|
||||||
|
rootManifest: RootManifest;
|
||||||
|
activeKitty: string;
|
||||||
|
setActiveKitty: (value: string) => void;
|
||||||
|
}
|
||||||
|
| undefined
|
||||||
>(undefined);
|
>(undefined);
|
||||||
|
|||||||
@@ -1,12 +1,29 @@
|
|||||||
import { type ReactNode, useState } from "react";
|
import axios from "axios";
|
||||||
|
import { type ReactNode, useState, useEffect } from "react";
|
||||||
import { AppContext } from "~/context/AppContext";
|
import { AppContext } from "~/context/AppContext";
|
||||||
|
import { type RootManifest } from "~/utils/types";
|
||||||
|
|
||||||
export const AppProvider = (props: { children?: ReactNode }) => {
|
export const AppProvider = (props: { children?: ReactNode }) => {
|
||||||
const [activeKitty, setActiveKitty] = useState(":r0:");
|
const [activeKitty, setActiveKitty] = useState(":r0:");
|
||||||
|
const [rootManifest, setRootManifest] = useState<RootManifest>({
|
||||||
|
files: ["README.md", "pubkey.asc"],
|
||||||
|
projects: ["me", "tlock"],
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return;
|
||||||
|
void axios
|
||||||
|
.get<RootManifest>(
|
||||||
|
"https://raw.githubusercontent.com/pihkaal/pihkaal/main/manifest.json",
|
||||||
|
)
|
||||||
|
.then((x) => setRootManifest(x.data));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!rootManifest) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppContext.Provider value={{ activeKitty, setActiveKitty }}>
|
<AppContext.Provider value={{ rootManifest, activeKitty, setActiveKitty }}>
|
||||||
{props.children}
|
{rootManifest && props.children}
|
||||||
</AppContext.Provider>
|
</AppContext.Provider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { KittyContextProps } from "~/context/KittyContext";
|
import { type KittyContextProps } from "~/context/KittyContext";
|
||||||
|
|
||||||
export type Prettify<T> = NonNullable<{ [K in keyof T]: T[K] }>;
|
export type Prettify<T> = NonNullable<{ [K in keyof T]: T[K] }>;
|
||||||
|
|
||||||
@@ -7,9 +7,7 @@ export type InnerKittyProps<T extends (...args: any[]) => any> = Prettify<
|
|||||||
Parameters<T>[0] & KittyContextProps
|
Parameters<T>[0] & KittyContextProps
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export type Manifest = {
|
export type RootManifest = {
|
||||||
projects: Array<{
|
|
||||||
name: string;
|
|
||||||
files: Array<string>;
|
files: Array<string>;
|
||||||
}>;
|
projects: Array<string>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user