https://github.com/imteekay/md-links-graph
Markdown Links Graph
https://github.com/imteekay/md-links-graph
Last synced: 7 months ago
JSON representation
Markdown Links Graph
- Host: GitHub
- URL: https://github.com/imteekay/md-links-graph
- Owner: imteekay
- License: mit
- Created: 2022-01-23T18:23:11.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-30T20:16:25.000Z (almost 4 years ago)
- Last Synced: 2025-06-08T21:19:06.833Z (7 months ago)
- Language: TypeScript
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# md-links-graph
[](https://npmjs.com/package/@imtk/md-links-graph) [](https://github.com/Naereen/StrapDown.js/blob/master/LICENSE)
Create a graph data structure based on Markdown content and links.
## Install
With yarn:
```bash
yarn add @imtk/md-links-graph
```
With npm:
```bash
npm add @imtk/md-links-graph
```
## Usage
```ts
import { createGraph } from '@imtk/md-links-graph';
const posts = [
{
url: '/post-1',
title: 'Post 1',
content: 'Markdown content for post 1'
},
{
url: '/post-2',
title: 'Post 2',
content: 'Post 2 linked to [post 1](/post-1)'
}
];
const graph = createGraph(posts);
graph.nodes;
// [
// {
// url: '/post-1',
// text: 'Post 1',
// id: 0
// },
// {
// url: '/post-2',
// text: 'Post 2',
// id: 1
// }
// ]
graph.edges;
// [
// {
// source: '1',
// target: '0'
// }
// ];
```
## Types
### Node
```ts
type Url = string;
type Node = {
id: number;
text: string;
url: Url;
};
```
### Edge
```ts
type Edge = {
source: string;
target: string;
};
```
### Post input
```ts
type PostMarkdown = {
url: string;
title: string;
content: string;
};
```
## License
[MIT](./LICENSE) License © 2022 [TK](https://github.com/imteekay)