mirror of
https://github.com/litruv/Docs-Viewer.git
synced 2026-09-10 10:09:46 +10:00
84 lines
2.0 KiB
Markdown
84 lines
2.0 KiB
Markdown
# Docs Viewer
|
||
|
||
Static documentation viewer built on **slatehtml** + **slatehtml-ui**: panel shell, live search, wiki links, and markdown as slate blocks (inline via `slate-rich-text`).
|
||
|
||
## Install (consumer sites)
|
||
|
||
```bash
|
||
npm install github:litruv/Docs-Viewer
|
||
# peers / siblings as needed:
|
||
npm install slatehtml slatehtml-ui
|
||
```
|
||
|
||
Local sibling checkout:
|
||
|
||
```json
|
||
{
|
||
"dependencies": {
|
||
"docs-viewer": "file:../Docs-Viewer",
|
||
"slatehtml": "file:../slatehtml",
|
||
"slatehtml-ui": "file:../slatehtml/packages/slatehtml-ui"
|
||
}
|
||
}
|
||
```
|
||
|
||
## App usage
|
||
|
||
```html
|
||
<body>
|
||
<slate-docs-viewer index="./index.json"></slate-docs-viewer>
|
||
<script type="module" src="./main.js"></script>
|
||
</body>
|
||
```
|
||
|
||
```js
|
||
import "slatehtml";
|
||
import "slatehtml-ui/app-bar";
|
||
import "slatehtml-ui/icon";
|
||
import "slatehtml-ui/text-field";
|
||
import "slatehtml-ui/side-bar";
|
||
import "slatehtml-ui/text";
|
||
import "slatehtml-ui/progress";
|
||
import "slatehtml-ui/alert";
|
||
import "slatehtml-ui/divider";
|
||
import { configure } from "slatehtml-ui/configure";
|
||
import { fontAwesomeSvg } from "slatehtml-ui/icons/fontawesome";
|
||
import { mountDocs } from "docs-viewer";
|
||
import "docs-viewer/prose.css";
|
||
|
||
configure({ icons: fontAwesomeSvg });
|
||
await mountDocs("slate-docs-viewer");
|
||
```
|
||
|
||
Vite needs the UMC plugin with UI + this package’s `src`:
|
||
|
||
```js
|
||
import { umc } from "slatehtml/umc/vite";
|
||
import { createRequire } from "node:module";
|
||
import { dirname, join } from "node:path";
|
||
|
||
const require = createRequire(import.meta.url);
|
||
const uiSrc = join(dirname(require.resolve("slatehtml-ui/package.json")), "src");
|
||
const docsSrc = join(dirname(require.resolve("docs-viewer/package.json")), "src");
|
||
|
||
export default {
|
||
plugins: [umc({ roots: [uiSrc, docsSrc] })],
|
||
};
|
||
```
|
||
|
||
## Develop this repo
|
||
|
||
```bash
|
||
npm install # expects ../slatehtml checkout
|
||
npm run build:index
|
||
npm run dev
|
||
```
|
||
|
||
## Content contract
|
||
|
||
Same as before:
|
||
|
||
- `docs/**/*.md` + YAML frontmatter
|
||
- `index.json` metadata; `documents` from `npm run build:index`
|
||
- Wiki `[[Page Title]]`, embeds `![[image.png]]`
|