# 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:

<SiteGraph />

## Setup [#setup]

### Install the Package [#install-the-package-step]

```npm
npm i @vuesho/graph-view
```

### Add the Plugin [#add-the-plugin-step]

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

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

export default createSite(docs.toSource()).plugins(
  recommendedPreset(),
  graphViewPlugin(), // [!code highlight]
);
```

### Show the Graph [#show-the-graph-step]

Add `<SiteGraph />` to any page:

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

<SiteGraph />
```

## Links in the Graph [#links-in-the-graph]

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 [#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`](/cli#vuesho-add):

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

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

```vue title="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>
```
