Skip to Content
Vuesho

Graph View

An interactive graph of your pages.

@vuesho/graph-view draws your pages as nodes and the links between them as edges. Hover a node to see its description and highlight its links, and click it to open the page:

Setup

Install the Package

npm i @vuesho/graph-view

Add the Plugin

graphViewPlugin() builds a graph of the pages in each language:

vuesho.config.ts
import { graphViewPlugin } from "@vuesho/graph-view";
import { createSite, recommendedPreset } from "vuesho/config";

export default createSite(docs.toSource()).plugins(
  recommendedPreset(),
  graphViewPlugin(), 
);

Show the Graph

Add <SiteGraph /> to any page:

content/map.md
---
title: Map of the Docs
---

<SiteGraph />

The graph has an edge for each Markdown link to another page, written as a URL like /guide/install or a file like ./install.md. Links in HTML and in component props, like a <Card>'s href, aren't in the graph.

Pages from every content source are in the graph. The graph loads in the browser, so a page with <SiteGraph /> has no graph in its HTML or its Markdown.

Customizing the Graph

SiteGraph's default slot receives { graph }, with the graph's nodes and links, empty on the server and until the graph loads. Each node has a text, a description and a url.

To change how the graph is drawn, copy the drawing code into your project with vuesho add:

npx vuesho add components/graph-view --from @vuesho/graph-view

Then write a component that passes the graph to the copy:

src/components/content/SiteGraph.vue
<script setup lang="ts">
import { SiteGraph } from "@vuesho/graph-view/client";
import { GraphView } from "../../ui/@vuesho/graph-view/components/graph-view";
</script>

<template>
  <SiteGraph v-slot="{ graph }">
    <GraphView :graph="graph" />
  </SiteGraph>
</template>