@bndynet/vue-site 0.1.1 → 0.1.2
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 +6 -1
- package/bin/vue-site.mjs +8 -2
- package/dist/create-app.d.ts +1 -1
- package/dist/index.es.js +17 -7
- package/dist/types.d.ts +13 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -67,6 +67,8 @@ Add `"dev": "vue-site dev"` (or `vs dev`) in `package.json` scripts if you like.
|
|
|
67
67
|
| `links` | Header links: Lucide `icon` + `link`, optional `title` |
|
|
68
68
|
| `packageRepository` | Usually set by CLI from `package.json`; omit when using `createSiteApp` alone |
|
|
69
69
|
| `env` | Dev/build options — see below |
|
|
70
|
+
| `bootstrap` | Optional path from site root (e.g. `./bootstrap.ts`) — module loaded once before the Vue app |
|
|
71
|
+
| `configureApp` | Optional `(app) => void` after router install, before `mount` |
|
|
70
72
|
|
|
71
73
|
### `NavItem`
|
|
72
74
|
|
|
@@ -106,9 +108,12 @@ import { createSiteApp } from '@bndynet/vue-site'
|
|
|
106
108
|
import '@bndynet/vue-site/style.css'
|
|
107
109
|
import config from './site.config'
|
|
108
110
|
|
|
109
|
-
createSiteApp(config)
|
|
111
|
+
const app = await createSiteApp(config)
|
|
112
|
+
app.mount('#app')
|
|
110
113
|
```
|
|
111
114
|
|
|
115
|
+
Use a top-level `await` in your entry (or an async IIFE): `createSiteApp` is async. If you set optional `bootstrap` in config, that module loads before the app is created; if you omit `bootstrap`, that step is skipped.
|
|
116
|
+
|
|
112
117
|
Exports: `createSiteApp`, `defineConfig`, `useTheme`, `useSiteConfig`, `themeRefKey`. Types: `SiteConfig`, `SiteEnvConfig`, `SiteViteConfig`, `SiteExternalLink`, `NavItem`, `ThemeConfig`, `ThemeOption`, `ThemePaletteVars`, `ResolvedNavItem`.
|
|
113
118
|
|
|
114
119
|
### Theme in Vue pages (`useTheme`)
|
package/bin/vue-site.mjs
CHANGED
|
@@ -104,7 +104,10 @@ const entryCode = [
|
|
|
104
104
|
`import '${pkgDir.replace(/\\/g, '/')}/dist/style.css'`,
|
|
105
105
|
`import siteConfig from '/${foundConfig}'`,
|
|
106
106
|
`import { repositoryUrl } from '${VIRTUAL_PACKAGE}'`,
|
|
107
|
-
|
|
107
|
+
`;(async () => {`,
|
|
108
|
+
` const app = await createSiteApp({ ...siteConfig, packageRepository: repositoryUrl })`,
|
|
109
|
+
` app.mount('#app')`,
|
|
110
|
+
`})()`,
|
|
108
111
|
].join('\n')
|
|
109
112
|
|
|
110
113
|
const htmlTemplate = `<!DOCTYPE html>
|
|
@@ -324,7 +327,10 @@ import { createSiteApp } from '${pkgDir.replace(/\\/g, '/')}/dist/index.es.js'
|
|
|
324
327
|
import '${pkgDir.replace(/\\/g, '/')}/dist/style.css'
|
|
325
328
|
import siteConfig from './${foundConfig}'
|
|
326
329
|
import { repositoryUrl } from '${VIRTUAL_PACKAGE}'
|
|
327
|
-
|
|
330
|
+
;(async () => {
|
|
331
|
+
const app = await createSiteApp({ ...siteConfig, packageRepository: repositoryUrl })
|
|
332
|
+
app.mount('#app')
|
|
333
|
+
})()
|
|
328
334
|
</script>
|
|
329
335
|
</body>
|
|
330
336
|
</html>`
|
package/dist/create-app.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { SiteConfig } from './types';
|
|
2
|
-
export declare function createSiteApp(config: SiteConfig): import('vue').App<Element
|
|
2
|
+
export declare function createSiteApp(config: SiteConfig): Promise<import('vue').App<Element>>;
|
package/dist/index.es.js
CHANGED
|
@@ -38128,9 +38128,19 @@ const CS = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
38128
38128
|
};
|
|
38129
38129
|
}
|
|
38130
38130
|
});
|
|
38131
|
-
function
|
|
38132
|
-
|
|
38133
|
-
|
|
38131
|
+
function lA(e) {
|
|
38132
|
+
const a = e.trim();
|
|
38133
|
+
if (!a) throw new Error("[vue-site] bootstrap path is empty");
|
|
38134
|
+
return a.startsWith("/") ? a : "/" + a.replace(/^\.\//, "");
|
|
38135
|
+
}
|
|
38136
|
+
async function sA(e) {
|
|
38137
|
+
if (e.bootstrap == null || String(e.bootstrap).trim() === "") return;
|
|
38138
|
+
await import(lA(String(e.bootstrap)));
|
|
38139
|
+
}
|
|
38140
|
+
async function fA(e) {
|
|
38141
|
+
var d, h, s, y, f;
|
|
38142
|
+
await sA(e);
|
|
38143
|
+
const a = GI(e.nav), c = fS(a), o = ["light", "dark", ...((h = (d = e.theme) == null ? void 0 : d.extraThemes) == null ? void 0 : h.filter((k) => k.id !== "light" && k.id !== "dark").map((k) => k.id)) ?? []], i = bS(e.theme), u = me("light");
|
|
38134
38144
|
mS(
|
|
38135
38145
|
u,
|
|
38136
38146
|
((s = e.theme) == null ? void 0 : s.default) ?? "light",
|
|
@@ -38139,15 +38149,15 @@ function pA(e) {
|
|
|
38139
38149
|
(y = e.theme) == null ? void 0 : y.colors
|
|
38140
38150
|
), document.title = e.title;
|
|
38141
38151
|
const r = tL(hA);
|
|
38142
|
-
return r.provide(XI, u), r.provide(dI, { config: e, resolvedNav: a }), r.use(c), r;
|
|
38152
|
+
return r.provide(XI, u), r.provide(dI, { config: e, resolvedNav: a }), r.use(c), (f = e.configureApp) == null || f.call(e, r), r;
|
|
38143
38153
|
}
|
|
38144
|
-
function
|
|
38154
|
+
function MA(e) {
|
|
38145
38155
|
return e;
|
|
38146
38156
|
}
|
|
38147
38157
|
export {
|
|
38148
38158
|
eI as builtinThemePalettes,
|
|
38149
|
-
|
|
38150
|
-
|
|
38159
|
+
fA as createSiteApp,
|
|
38160
|
+
MA as defineConfig,
|
|
38151
38161
|
XI as themeRefKey,
|
|
38152
38162
|
Rt as useSiteConfig,
|
|
38153
38163
|
xS as useTheme
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from 'vue';
|
|
1
|
+
import { App, Component } from 'vue';
|
|
2
2
|
import { UserConfig as ViteUserConfig } from 'vite';
|
|
3
3
|
export interface NavItem {
|
|
4
4
|
label: string;
|
|
@@ -97,6 +97,18 @@ export interface SiteConfig {
|
|
|
97
97
|
packageRepository?: string | null;
|
|
98
98
|
/** Development / build environment configuration */
|
|
99
99
|
env?: SiteEnvConfig;
|
|
100
|
+
/**
|
|
101
|
+
* Optional. Path to a module under the site root (Vite `root`), loaded once **before** the Vue app
|
|
102
|
+
* is created. Omit or leave unset to skip. Use for global side effects (polyfills, telemetry,
|
|
103
|
+
* `window` setup). Relative to root, e.g. `./bootstrap.ts` or `src/bootstrap.ts` (resolved as
|
|
104
|
+
* `/bootstrap.ts`, `/src/bootstrap.ts`).
|
|
105
|
+
*/
|
|
106
|
+
bootstrap?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Called after the app is created, context is provided, and the router is installed — before
|
|
109
|
+
* `createSiteApp` resolves (call `.mount()` after `await`). Use for `app.use()`, global directives, etc.
|
|
110
|
+
*/
|
|
111
|
+
configureApp?: (app: App) => void;
|
|
100
112
|
}
|
|
101
113
|
export interface ResolvedNavItem extends NavItem {
|
|
102
114
|
resolvedPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bndynet/vue-site",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A configurable Vue 3 site framework with sidebar navigation, markdown rendering, and theme switching.",
|
|
6
6
|
"repository": {
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/markdown-it": "^14.1.0",
|
|
53
|
-
"concurrently": "^9.2.1",
|
|
54
53
|
"rimraf": "^6.1.3",
|
|
55
54
|
"typescript": "~5.7.0",
|
|
56
55
|
"vite-plugin-dts": "^4.5.0",
|