mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
add backlinks
This commit is contained in:
parent
6222b75563
commit
811e7740a9
21 changed files with 257 additions and 56 deletions
|
@ -1,22 +1,29 @@
|
|||
import React, { createContext, FC, useContext } from 'react';
|
||||
|
||||
import { EMPTY_NODE } from '~/constants/node';
|
||||
import { INode } from '~/types';
|
||||
import { INode, NodeBackLink } from '~/types';
|
||||
|
||||
export interface NodeContextProps {
|
||||
node: INode;
|
||||
backlinks?: NodeBackLink[];
|
||||
update: (node: Partial<INode>) => Promise<unknown>;
|
||||
isLoading: boolean;
|
||||
}
|
||||
|
||||
export const NodeContext = createContext<NodeContextProps>({
|
||||
node: EMPTY_NODE,
|
||||
backlinks: [] as NodeBackLink[] | undefined,
|
||||
update: async () => {},
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
export const NodeContextProvider: FC<NodeContextProps> = ({ children, ...contextValue }) => {
|
||||
return <NodeContext.Provider value={contextValue}>{children}</NodeContext.Provider>;
|
||||
export const NodeContextProvider: FC<NodeContextProps> = ({
|
||||
children,
|
||||
...contextValue
|
||||
}) => {
|
||||
return (
|
||||
<NodeContext.Provider value={contextValue}>{children}</NodeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useNodeContext = () => useContext(NodeContext);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue