Arsero / docusaurus-graph

The Docusaurus GraphView Plugin is an open source plugin designed to generate a graph view from your Docusaurus documentation files.
MIT License
7 stars 0 forks source link

Choose what relationship between files dynamically #2

Open HunteRoi opened 5 months ago

HunteRoi commented 5 months ago

Hey @Arsero !

I have been playing with your plugin and I find it quite useful! Although I think you might want to add a system for dynamic search of the relationships between files instead of manually setting them up.

I ended up with having a few proposals for you.

1st suggestion

Use the tags header information on each blog post/docs page to create the relationships between files (sources : https://docusaurus.io/docs/create-doc#doc-tags and https://docusaurus.io/docs/blog). I have a page to list tags I used on my website (available here) which means there might be an API available in docusaurus to have the list of tags for the website as well as parse them from any file.

2nd suggestion

Shift the plugin on a more open stance by allowing users to choose what kind of relationships they want based on functions you write and export from your own package.

Let me provide you with an example.

import type { Config } from '@docusaurus/types';
import type * as Preset from '@docusaurus/preset-classic';

import { basedOnTags, basedOnParentFolder, basedOnMentions } from 'docusaurus-graph';

const config: Config = {
   // ...
   plugins: [
       [
           "docusaurus-graph",
           {
               path: "docs",
               basedOn: basedOnParentFolder
           }
       ]
   ]
   // ...
};

export default config;

As you probably understand, you could expand it with default functions you provide but also allow other people to come up with their own relationships function!