@3sln/deck 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/bin/build.js +7 -5
- package/package.json +1 -1
- package/src/config.js +9 -0
- package/src/deck-demo.js +1 -1
- package/vite-plugin.js +2 -2
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
A Vite plugin for building scalable, zero-config, Markdown-based component playgrounds and documentation sites.
|
|
1
|
+
# Deck
|
|
4
2
|
|
|
5
3
|
> [!WARNING]
|
|
6
4
|
> This is a work-in-progress project.
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
Deck is a Vite-based tool for creating scalable, zero-config, Markdown-based component playgrounds and documentation sites.
|
|
7
|
+
|
|
8
|
+
It uses a client-side database to index your documentation, enabling a fast initial load and powerful full-text search, even for very large projects.
|
|
9
|
+
|
|
10
|
+
[deck.webm](https://github.com/user-attachments/assets/cc127ba6-202c-47f0-a982-560e05f7574d)
|
|
11
|
+
|
|
12
|
+
## Documentation & Live Examples
|
|
9
13
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- **Static Site Generation:** A `deck-build` command generates a fully static, production-ready site from your project files.
|
|
13
|
-
- **`<deck-demo>`:** A powerful custom element for embedding live, stateful, and hot-reloading component demos directly in your documentation.
|
|
14
|
-
- **Reactive UI:** A modern, responsive UI with a powerful search feature and a split-screen layout for easy viewing.
|
|
15
|
-
- **Configurable:** The project title and import maps for dynamic demos can be configured in your project's `package.json`.
|
|
14
|
+
For a complete guide, API reference, and to see Deck in action, you can check out Deck's own
|
|
15
|
+
[card Deck here](https://deck.3sln.com).
|
|
16
16
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
@@ -24,6 +24,7 @@ A Vite plugin for building scalable, zero-config, Markdown-based component playg
|
|
|
24
24
|
2. **Configure:** In your `package.json`, add a build script and your project's configuration:
|
|
25
25
|
```json
|
|
26
26
|
{
|
|
27
|
+
...
|
|
27
28
|
"scripts": {
|
|
28
29
|
"dev": "vite",
|
|
29
30
|
"build": "deck-build"
|
|
@@ -31,6 +32,7 @@ A Vite plugin for building scalable, zero-config, Markdown-based component playg
|
|
|
31
32
|
"@3sln/deck": {
|
|
32
33
|
"title": "My Awesome Docs"
|
|
33
34
|
}
|
|
35
|
+
...
|
|
34
36
|
}
|
|
35
37
|
```
|
|
36
38
|
|
package/bin/build.js
CHANGED
|
@@ -4,14 +4,13 @@ import {build as viteBuild} from 'vite';
|
|
|
4
4
|
import fs from 'fs-extra';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import {createRequire} from 'module';
|
|
7
|
-
import { sha256, loadDeckConfig, getProjectFiles, getHtmlTemplate } from '../src/config.js';
|
|
7
|
+
import { sha256, loadDeckConfig, getProjectFiles, getCardFiles, getHtmlTemplate } from '../src/config.js';
|
|
8
8
|
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
|
|
11
11
|
// --- Path Resolution ---
|
|
12
12
|
const userRoot = process.cwd();
|
|
13
|
-
|
|
14
|
-
const assetsDir = path.resolve(outDir, 'assets');
|
|
13
|
+
// outDir is now resolved inside build()
|
|
15
14
|
const deckPluginPath = require.resolve('@3sln/deck/vite-plugin');
|
|
16
15
|
const deckRoot = path.dirname(deckPluginPath);
|
|
17
16
|
|
|
@@ -21,7 +20,10 @@ async function build() {
|
|
|
21
20
|
console.log('Starting Deck build...');
|
|
22
21
|
|
|
23
22
|
const config = await loadDeckConfig(userRoot);
|
|
24
|
-
const buildConfig = config.build;
|
|
23
|
+
const buildConfig = config.build || {};
|
|
24
|
+
|
|
25
|
+
const outDir = path.resolve(userRoot, buildConfig.outDir || 'out');
|
|
26
|
+
const assetsDir = path.resolve(outDir, 'assets');
|
|
25
27
|
|
|
26
28
|
// Clean output directory
|
|
27
29
|
await fs.emptyDir(outDir);
|
|
@@ -72,7 +74,7 @@ async function build() {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
// Find card paths and hash content for the index
|
|
75
|
-
const cardFiles =
|
|
77
|
+
const cardFiles = getCardFiles(userRoot, buildConfig);
|
|
76
78
|
const initialCardsData = await Promise.all(cardFiles.map(async (file) => {
|
|
77
79
|
const content = await fs.readFile(path.resolve(outDir, file), 'utf-8');
|
|
78
80
|
const hash = await sha256(content);
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -49,6 +49,15 @@ export function getProjectFiles(root, config) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
export function getCardFiles(root, config) {
|
|
53
|
+
return globSync(config.include, {
|
|
54
|
+
cwd: root,
|
|
55
|
+
ignore: config.exclude,
|
|
56
|
+
nodir: true,
|
|
57
|
+
dot: true,
|
|
58
|
+
}).filter(s => s.endsWith('.md') || s.endsWith('.html'));
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
export function getHtmlTemplate({ title, importMap, initialCardsData, pinnedCardPaths, entryFile, cssFiles = [] }) {
|
|
53
62
|
return `
|
|
54
63
|
<!doctype html>
|
package/src/deck-demo.js
CHANGED
package/vite-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { sha256, loadDeckConfig, getProjectFiles, getHtmlTemplate } from './src/config.js';
|
|
3
|
+
import { sha256, loadDeckConfig, getProjectFiles, getCardFiles, getHtmlTemplate } from './src/config.js';
|
|
4
4
|
|
|
5
5
|
export default function deckPlugin() {
|
|
6
6
|
let resolvedConfig;
|
|
@@ -122,7 +122,7 @@ export default function deckPlugin() {
|
|
|
122
122
|
|
|
123
123
|
server.middlewares.use(async (req, res, next) => {
|
|
124
124
|
if (req.url.endsWith('/')) {
|
|
125
|
-
const cardPaths =
|
|
125
|
+
const cardPaths = getCardFiles(resolvedConfig.root, devConfig).map(p => `/${p}`);
|
|
126
126
|
const initialCardsData = await Promise.all(cardPaths.map(async (p) => {
|
|
127
127
|
const content = await fs.readFile(path.join(resolvedConfig.root, p), 'utf-8');
|
|
128
128
|
const hash = await sha256(content);
|