Skip to content

Commit

Permalink
🚚 Rename type
Browse files Browse the repository at this point in the history
  • Loading branch information
chanjunren committed Jan 12, 2025
1 parent 4515f23 commit 363dc46
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const OBSIDIAN_TAG_REGEX = /#\S+/g;
// export const OBSIDIAN_TAG_REGEX = /#\S+/g;
export const OBSIDIAN_TAG_REGEX = /#([^\s#]+)/g;

export const OBSIDIAN_INTERNAL_LINK_REGEX = /(?<!!)\[\[.*?\]\]/g;

Expand Down
2 changes: 1 addition & 1 deletion src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type GraphInfo = {

export type GraphInfoMap = { [filePath: string]: GraphInfo };

export type AdjcacencyMap = {
export type AdjacencyMap = {
[key: string]: Set<string>;
};

Expand Down
4 changes: 2 additions & 2 deletions src/plugin/hooks/useHover.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AdjcacencyMap, GraphNodeLinkInfo } from "@vaultusaurus/common/types";
import { AdjacencyMap, GraphNodeLinkInfo } from "@vaultusaurus/common/types";
import { ObsidianNoteNode } from "@vaultusaurus/plugin/types";
import { useEffect, useState } from "react";

export default function useHover(links: GraphNodeLinkInfo[]) {
const [hoveredNode, setHoveredNode] = useState<ObsidianNoteNode>(null);
const [adjacencyMap, setAdjacencyMap] = useState<AdjcacencyMap>({});
const [adjacencyMap, setAdjacencyMap] = useState<AdjacencyMap>({});

useEffect(() => {
if (!links || links.length === 0) {
Expand Down
16 changes: 8 additions & 8 deletions src/plugin/markdown/postprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "../../common/constants";
import { VaultusaurusPluginOptions } from "../../common/options";
import {
AdjcacencyMap,
AdjacencyMap,
GraphInfo,
GraphNodeInfo,
GraphNodeLinkInfo,
Expand Down Expand Up @@ -50,7 +50,7 @@ function buildGraphInfo(
): GraphInfo {
const visitedDocuments: Set<string> = new Set([]);
const visitedTags: Set<string> = new Set([]);
const adjacencyMap: AdjcacencyMap = {};
const adjacencyMap: AdjacencyMap = {};
const tagsToIgnore = new Set(options.ignoredGraphTags || []);

const queue: GraphNodeInfo[] = [
Expand Down Expand Up @@ -133,7 +133,7 @@ function markAsVisited(
function edgeExists(
source: string,
target: string,
adjacencyMap: AdjcacencyMap
adjacencyMap: AdjacencyMap
) {
return (
(adjacencyMap[source] && adjacencyMap[source].has(target)) ||
Expand All @@ -144,7 +144,7 @@ function edgeExists(
function handleLink(
source: string,
target: string,
adjacencyMap: AdjcacencyMap,
adjacencyMap: AdjacencyMap,
links: GraphNodeLinkInfo[]
) {
if (edgeExists(source, target, adjacencyMap)) {
Expand All @@ -163,7 +163,7 @@ function handleLink(
function checkAdjacencyMap(
source: string,
target: string,
adjacencyMap: AdjcacencyMap
adjacencyMap: AdjacencyMap
) {
if (!adjacencyMap[source]) {
adjacencyMap[source] = new Set();
Expand All @@ -178,7 +178,7 @@ function handleDocumentTags(
queue: GraphNodeInfo[],
links: GraphNodeLinkInfo[],
vault: ObsidianVaultInfo,
adjacencyMap: AdjcacencyMap,
adjacencyMap: AdjacencyMap,
tagsToIgnore: Set<string>
) {
vault.documents[currentNode.label].tags.forEach((tag) => {
Expand All @@ -202,7 +202,7 @@ function handleInternalLinks(
queue: GraphNodeInfo[],
links: GraphNodeLinkInfo[],
vault: ObsidianVaultInfo,
adjacencyMap: AdjcacencyMap
adjacencyMap: AdjacencyMap
) {
vault.documents[currentNode.label].internalLinks.forEach((internalLink) => {
const internalLinkId = `${OBSIDIAN_FILE_ID_PREFIX}__${vault.documents[internalLink].relativeFilePath}`;
Expand All @@ -224,7 +224,7 @@ function handleTaggedDocuments(
links: GraphNodeLinkInfo[],
vault: ObsidianVaultInfo,
tags: ObsidianTagsInfo,
adjacencyMap: AdjcacencyMap,
adjacencyMap: AdjacencyMap,
tagsToIgnore: Set<string>
) {
if (tagsToIgnore.has(currentNode.label)) {
Expand Down
4 changes: 2 additions & 2 deletions src/plugin/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphStyle } from "@vaultusaurus/common/options";
import { AdjcacencyMap, GraphNodeInfo } from "@vaultusaurus/common/types";
import { AdjacencyMap, GraphNodeInfo } from "@vaultusaurus/common/types";
import { Simulation, SimulationLinkDatum, SimulationNodeDatum } from "d3-force";
import { MutableRefObject } from "react";

Expand All @@ -9,7 +9,7 @@ export type ObsidianNoteLink = SimulationLinkDatum<ObsidianNoteNode>;
export type LocalGraphContext = {
hoveredNode?: ObsidianNoteNode;
setHoveredNode: (node: ObsidianNoteNode) => void;
adjacencyMap: AdjcacencyMap;
adjacencyMap: AdjacencyMap;
simulation: MutableRefObject<Simulation<ObsidianNoteNode, ObsidianNoteLink>>;
graphStyle: GraphStyle;
};

0 comments on commit 363dc46

Please sign in to comment.