@soubiran/vite 0.6.3 → 0.6.5
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 +0 -240
- package/dist/index.mjs +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,243 +1,3 @@
|
|
|
1
1
|
# @soubiran/vite
|
|
2
2
|
|
|
3
3
|
Shared Vite plugin bundle for the `*.soubiran.dev` apps.
|
|
4
|
-
|
|
5
|
-
This package is designed for **Vue 3 + Vite + vite-ssg** projects that use:
|
|
6
|
-
|
|
7
|
-
- `pages/` as the route source
|
|
8
|
-
- `.md` and `.vue` pages
|
|
9
|
-
- frontmatter-driven SEO
|
|
10
|
-
- generated markdown exports, metadata, and sitemap output
|
|
11
|
-
|
|
12
|
-
## What it gives you
|
|
13
|
-
|
|
14
|
-
When you use this package in an app, it wires together the shared setup for:
|
|
15
|
-
|
|
16
|
-
- Vue pages and Markdown pages
|
|
17
|
-
- file-based routing from `pages/`
|
|
18
|
-
- `@nuxt/ui` auto-imports and component registration
|
|
19
|
-
- shared Markdown styling and Markdown-it enhancements
|
|
20
|
-
- frontmatter validation
|
|
21
|
-
- canonical URLs
|
|
22
|
-
- Open Graph image generation
|
|
23
|
-
- Schema.org structured data
|
|
24
|
-
- generated API JSON files
|
|
25
|
-
- generated sanitized `.md` files in `dist/`
|
|
26
|
-
- generated `meta.json`
|
|
27
|
-
- generated `sitemap.xml`
|
|
28
|
-
|
|
29
|
-
## Installation
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
pnpm install @soubiran/vite
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Basic usage
|
|
36
|
-
|
|
37
|
-
Create a `vite.config.ts`. Then use the shared plugin bundle inside `plugins`.
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import soubiran from '@soubiran/vite'
|
|
41
|
-
import { defineConfig } from 'vite'
|
|
42
|
-
|
|
43
|
-
export default defineConfig({
|
|
44
|
-
plugins: [soubiran('My App', 'my-app.soubiran.dev', {
|
|
45
|
-
extractPage,
|
|
46
|
-
})],
|
|
47
|
-
})
|
|
48
|
-
|
|
49
|
-
function extractPage(id: string) {
|
|
50
|
-
return null
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
## Public API
|
|
55
|
-
|
|
56
|
-
### `soubiran(title, hostname, options)`
|
|
57
|
-
|
|
58
|
-
Returns a Vite plugin bundle to use inside `defineConfig({ plugins: [...] })`.
|
|
59
|
-
|
|
60
|
-
#### Parameters
|
|
61
|
-
|
|
62
|
-
##### `title: string`
|
|
63
|
-
|
|
64
|
-
The site or app name.
|
|
65
|
-
|
|
66
|
-
Used for:
|
|
67
|
-
|
|
68
|
-
- generated structured data
|
|
69
|
-
- SEO-related defaults
|
|
70
|
-
|
|
71
|
-
##### `hostname: string`
|
|
72
|
-
|
|
73
|
-
The public hostname without protocol.
|
|
74
|
-
|
|
75
|
-
Example:
|
|
76
|
-
|
|
77
|
-
- `infra.soubiran.dev`
|
|
78
|
-
|
|
79
|
-
Used for:
|
|
80
|
-
|
|
81
|
-
- canonical URLs
|
|
82
|
-
- OG image URLs
|
|
83
|
-
- sitemap generation
|
|
84
|
-
- metadata generation
|
|
85
|
-
- internal link UTM tagging
|
|
86
|
-
|
|
87
|
-
##### `options: Options`
|
|
88
|
-
|
|
89
|
-
Main configuration object.
|
|
90
|
-
|
|
91
|
-
### `Options`
|
|
92
|
-
|
|
93
|
-
#### `extractPage(id)`
|
|
94
|
-
|
|
95
|
-
Required.
|
|
96
|
-
|
|
97
|
-
Maps a file path to your app-specific page identifier.
|
|
98
|
-
|
|
99
|
-
This is the main extension point used by the package to:
|
|
100
|
-
|
|
101
|
-
- annotate route metadata
|
|
102
|
-
- compute frontmatter `page`
|
|
103
|
-
- drive structured data behavior
|
|
104
|
-
- support your wrapper selection / markdown transforms
|
|
105
|
-
|
|
106
|
-
#### `markdown`
|
|
107
|
-
|
|
108
|
-
Optional Markdown configuration passed through to the shared Markdown integration.
|
|
109
|
-
|
|
110
|
-
Most useful fields in practice:
|
|
111
|
-
|
|
112
|
-
- `wrapperComponent`
|
|
113
|
-
- `transforms`
|
|
114
|
-
|
|
115
|
-
Use this when you want different wrappers or content transforms depending on the route.
|
|
116
|
-
|
|
117
|
-
#### `seo.person`
|
|
118
|
-
|
|
119
|
-
Optional override for the default person data used in structured data.
|
|
120
|
-
|
|
121
|
-
If omitted, the package uses the built-in Estéban Soubiran profile.
|
|
122
|
-
|
|
123
|
-
#### `seo.assert.rules`
|
|
124
|
-
|
|
125
|
-
Optional custom frontmatter validator.
|
|
126
|
-
|
|
127
|
-
Use this to require app-specific frontmatter fields.
|
|
128
|
-
|
|
129
|
-
Example use cases:
|
|
130
|
-
|
|
131
|
-
- require `url`
|
|
132
|
-
- require `repository`
|
|
133
|
-
- enforce app-specific content rules
|
|
134
|
-
|
|
135
|
-
#### `seo.structuredData.pageConfig`
|
|
136
|
-
|
|
137
|
-
Optional callback used to choose the structured data mode for a page.
|
|
138
|
-
|
|
139
|
-
Supported page config types are:
|
|
140
|
-
|
|
141
|
-
- `default`
|
|
142
|
-
- `article`
|
|
143
|
-
- `collection`
|
|
144
|
-
|
|
145
|
-
This is the place to add breadcrumb configuration for detail pages.
|
|
146
|
-
|
|
147
|
-
#### `apiCategories`
|
|
148
|
-
|
|
149
|
-
Optional list of top-level page categories that should generate JSON API files.
|
|
150
|
-
|
|
151
|
-
Example:
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
apiCategories: ['websites', 'platforms']
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
If empty or omitted, no category API JSON files are generated.
|
|
158
|
-
|
|
159
|
-
## Utility exports
|
|
160
|
-
|
|
161
|
-
### `getUri(id)`
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
import { getUri } from '@soubiran/vite/utils'
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
Converts a page file path into the route-like URI used by the app.
|
|
168
|
-
|
|
169
|
-
Useful inside `extractPage()`.
|
|
170
|
-
|
|
171
|
-
### `toUrl(hostname, ...paths)`
|
|
172
|
-
|
|
173
|
-
```ts
|
|
174
|
-
import { toUrl } from '@soubiran/vite/utils'
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Builds a full `https://...` URL.
|
|
178
|
-
|
|
179
|
-
Useful when composing structured data breadcrumbs or SEO links.
|
|
180
|
-
|
|
181
|
-
## Types
|
|
182
|
-
|
|
183
|
-
You can import these from `@soubiran/vite`:
|
|
184
|
-
|
|
185
|
-
```ts
|
|
186
|
-
import type {
|
|
187
|
-
BreadcrumbItem,
|
|
188
|
-
PersonOptions,
|
|
189
|
-
StructuredDataPageConfig,
|
|
190
|
-
} from '@soubiran/vite'
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Expected app structure
|
|
194
|
-
|
|
195
|
-
This package assumes a structure like this:
|
|
196
|
-
|
|
197
|
-
```text
|
|
198
|
-
pages/
|
|
199
|
-
src/
|
|
200
|
-
components/
|
|
201
|
-
composables/
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
Important expectations:
|
|
205
|
-
|
|
206
|
-
- routes come from `pages/`
|
|
207
|
-
- both `.md` and `.vue` pages are supported
|
|
208
|
-
- generated router types go to `src/typed-router.d.ts`
|
|
209
|
-
- generated auto-import types go to `src/auto-imports.d.ts`
|
|
210
|
-
- generated component types go to `src/components.d.ts`
|
|
211
|
-
- the `@` alias points to `./src`
|
|
212
|
-
|
|
213
|
-
## Generated build artifacts
|
|
214
|
-
|
|
215
|
-
Depending on your app configuration, a production build can generate:
|
|
216
|
-
|
|
217
|
-
- `dist/sitemap.xml`
|
|
218
|
-
- `dist/meta.json`
|
|
219
|
-
- `dist/index.md` and other sanitized markdown exports
|
|
220
|
-
- `dist/api/<category>.json`
|
|
221
|
-
- `public/og/<route>.png`
|
|
222
|
-
|
|
223
|
-
### `meta.json`
|
|
224
|
-
|
|
225
|
-
Contains page-level metadata for markdown pages.
|
|
226
|
-
|
|
227
|
-
### `api/<category>.json`
|
|
228
|
-
|
|
229
|
-
Contains frontmatter data for markdown files under categories like `pages/websites/` or `pages/platforms/`.
|
|
230
|
-
|
|
231
|
-
### sanitized `.md` files in `dist/`
|
|
232
|
-
|
|
233
|
-
These are markdown exports intended for machine-friendly consumption.
|
|
234
|
-
|
|
235
|
-
They:
|
|
236
|
-
|
|
237
|
-
- remove frontmatter
|
|
238
|
-
- strip HTML tags
|
|
239
|
-
- prepend the page title as an H1 when available
|
|
240
|
-
|
|
241
|
-
### `sitemap.xml`
|
|
242
|
-
|
|
243
|
-
Generated from the routes rendered during the SSG build.
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soubiran/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.5",
|
|
5
5
|
"author": "Estéban Soubiran <esteban@soubiran.dev>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://github.com/sponsors/Barbapapazes",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"vite": "^8.0.10",
|
|
63
63
|
"vite-ssg": "^28.3.0",
|
|
64
64
|
"vue-router": "^5.0.6",
|
|
65
|
-
"@soubiran/ui": "0.6.
|
|
65
|
+
"@soubiran/ui": "0.6.5"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"tsdown": "^0.21.4"
|