twynejs 1.0.0
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 +3 -0
- package/dist/index.d.ts +180 -0
- package/dist/index.js +1122 -0
- package/dist/jsx-runtime.d.ts +20 -0
- package/dist/jsx-runtime.js +132 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +17 -0
- package/package.json +67 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
export type { HtmlValue } from "./jsx-runtime.js";
|
|
3
|
+
export interface PagesPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Directory containing the page modules (one `.ts`/`.tsx` file per page).
|
|
6
|
+
*
|
|
7
|
+
* @default "pages"
|
|
8
|
+
*/
|
|
9
|
+
pagesDir?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Directory for the Markdown files
|
|
12
|
+
*
|
|
13
|
+
* @default "docs"
|
|
14
|
+
*/
|
|
15
|
+
docsDir?: string;
|
|
16
|
+
/**
|
|
17
|
+
* File extensions that count as a page.
|
|
18
|
+
*
|
|
19
|
+
* @default [".ts", ".tsx", ".js", ".jsx"]
|
|
20
|
+
*/
|
|
21
|
+
extensions?: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Name of the global the shared entry reads to know which page to
|
|
24
|
+
* render, e.g. `"PAGE_ID"` → `window.PAGE_ID`.
|
|
25
|
+
*
|
|
26
|
+
* @default "PAGE_ID"
|
|
27
|
+
*/
|
|
28
|
+
globalVar?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Emit `<id>/index.html` instead of `<id>.html` (pretty / extensionless
|
|
31
|
+
* URLs). The page with id `"index"` is always emitted as the top-level
|
|
32
|
+
* `index.html`, never `index/index.html`.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
prettyUrls?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Per-page `<title>`. Receives the page id (e.g. `"guide/install"`).
|
|
39
|
+
*
|
|
40
|
+
* @default (id) => id
|
|
41
|
+
*/
|
|
42
|
+
title?: (id: string) => string;
|
|
43
|
+
/**
|
|
44
|
+
* Extra HTML to inject into the `<head>` of every emitted page — e.g.
|
|
45
|
+
* favicon links, `<meta name="description">`, Open Graph tags, …
|
|
46
|
+
*
|
|
47
|
+
* Can be:
|
|
48
|
+
*
|
|
49
|
+
* - a static string applied to every page
|
|
50
|
+
* - a record mapping page id → head HTML (missing ids get nothing)
|
|
51
|
+
* - a function receiving the page id → head HTML
|
|
52
|
+
*
|
|
53
|
+
* The result is inserted as-is (raw HTML) into the page shell right
|
|
54
|
+
* after the style tags, both in the default template and in custom
|
|
55
|
+
* `template` implementations via `ctx.head`.
|
|
56
|
+
*
|
|
57
|
+
* @default ""
|
|
58
|
+
*/
|
|
59
|
+
head?: string | Record<string, string> | ((id: string) => string);
|
|
60
|
+
/**
|
|
61
|
+
* Wrap/replace the emitted HTML shell entirely. Receives the computed
|
|
62
|
+
* script/style tags and page metadata; must return a full HTML document.
|
|
63
|
+
* Falls back to a minimal built-in template.
|
|
64
|
+
*/
|
|
65
|
+
template?: (ctx: PageRenderContext) => string;
|
|
66
|
+
/** Minify emitted HTML with html-minifier-terser. @default false */
|
|
67
|
+
minify?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Remove `console.log` / `console.warn` / `console.error` / `console.debug`
|
|
70
|
+
* / `console.info` calls from all built page scripts (production only).
|
|
71
|
+
*
|
|
72
|
+
* @default false
|
|
73
|
+
*/
|
|
74
|
+
removeConsole?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Write a `pages.d.ts` ambient module declaration next to `vite.config.ts`
|
|
77
|
+
* so `import { pages } from "virtual:pages"` is typed in consumers.
|
|
78
|
+
*
|
|
79
|
+
* @default true
|
|
80
|
+
*/
|
|
81
|
+
dts?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Where to write the ambient `pages.d.ts` declaration (relative to
|
|
84
|
+
* `config.root`). Ignored when `dts` is `false`.
|
|
85
|
+
*
|
|
86
|
+
* @default "src/pages.d.ts"
|
|
87
|
+
*/
|
|
88
|
+
dtsPath?: string;
|
|
89
|
+
/** Skip a file (by page id) from becoming a page. Default: ids starting with "_". */
|
|
90
|
+
ignore?: (id: string) => boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Path (relative to `root`) of the shared client entry, e.g. `"src/index.ts"`.
|
|
93
|
+
* Only used to serve pages during `vite dev` — production builds get the
|
|
94
|
+
* bundled entry automatically from Rollup's output. Required for the dev
|
|
95
|
+
* server route to work; dev falls back to a 404 passthrough if omitted.
|
|
96
|
+
*/
|
|
97
|
+
entry?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Additional CSS files per page route.
|
|
100
|
+
*
|
|
101
|
+
* Example:
|
|
102
|
+
*
|
|
103
|
+
* {
|
|
104
|
+
* "viewer/index": ["./pages/viewer/style.css"],
|
|
105
|
+
* "getting-started": ["./docs/docs.css"]
|
|
106
|
+
* }
|
|
107
|
+
*/
|
|
108
|
+
styles?: Record<string, string[]>;
|
|
109
|
+
/**
|
|
110
|
+
* If the raw Markown should be included in the build,
|
|
111
|
+
* for example for better search result
|
|
112
|
+
*
|
|
113
|
+
* @default false
|
|
114
|
+
*/
|
|
115
|
+
addRawMarkdown?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Set the paths to relative paths
|
|
118
|
+
*
|
|
119
|
+
* @default false
|
|
120
|
+
*/
|
|
121
|
+
relativePaths?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Bundle all pages into a single JS file.
|
|
124
|
+
*
|
|
125
|
+
* @default false
|
|
126
|
+
*/
|
|
127
|
+
singleBundle?: boolean;
|
|
128
|
+
/**
|
|
129
|
+
* More detailed output
|
|
130
|
+
*
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
verbose?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Put each compiled Markdown page into its own dynamically loaded chunk
|
|
136
|
+
* instead of embedding all Markdown HTML into the main bundle.
|
|
137
|
+
*
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
splitMarkdown?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Ignored Pathnames
|
|
143
|
+
*
|
|
144
|
+
* @default ["/@", "/node_modules/", "/src/"]
|
|
145
|
+
*/
|
|
146
|
+
ignoredPathnames?: string[];
|
|
147
|
+
/**
|
|
148
|
+
* Liquid Template root folder
|
|
149
|
+
*
|
|
150
|
+
* @default "src/templates"
|
|
151
|
+
*/
|
|
152
|
+
liquidTemplateRoot?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Module specifier injected into every `.tsx` page so the JSX factory
|
|
155
|
+
* (`jsx`/`Fragment`) is available. Defaults to the jsx-runtime shipped
|
|
156
|
+
* with this package.
|
|
157
|
+
*
|
|
158
|
+
* @default "twynejs/jsx-runtime"
|
|
159
|
+
*/
|
|
160
|
+
jsxRuntimePath?: string;
|
|
161
|
+
}
|
|
162
|
+
export interface PageRenderContext {
|
|
163
|
+
id: string;
|
|
164
|
+
title: string;
|
|
165
|
+
globalVar: string;
|
|
166
|
+
scriptTag: string;
|
|
167
|
+
styleTag: string;
|
|
168
|
+
/**
|
|
169
|
+
* Extra `<head>` HTML (favicon, meta description, …) computed from the
|
|
170
|
+
* plugin's `head` option for the current page. Insert it into the
|
|
171
|
+
* `<head>` of a custom `template`.
|
|
172
|
+
*/
|
|
173
|
+
head: string;
|
|
174
|
+
/**
|
|
175
|
+
* Pre-rendered body content (e.g. Liquid pages). When set, the template
|
|
176
|
+
* renders it as-is instead of bootstrapping the client app.
|
|
177
|
+
*/
|
|
178
|
+
content?: string;
|
|
179
|
+
}
|
|
180
|
+
export declare function pagesPlugin(options?: PagesPluginOptions): Plugin;
|