@mdsvex/plugin-page-data 0.0.0 → 0.1.0-next.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/LICENSE +21 -0
- package/README.md +248 -1
- package/dist/index.d.ts +80 -0
- package/dist/index.js +414 -0
- package/dist/last_modified.d.ts +13 -0
- package/dist/words.d.ts +10 -0
- package/package.json +42 -7
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 pngwn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,250 @@
|
|
|
1
1
|
# @mdsvex/plugin-page-data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Facts about each [mdsvex](https://mdsvex.pngwn.io) document, for its template and for pages that list documents: a reading time and word count, an excerpt, a title read from the first heading, an edit url, and the date it was last changed.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pnpm add --save-dev @mdsvex/plugin-page-data@next
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
// vite.config.js
|
|
11
|
+
import { mdsvex } from 'mdsvex';
|
|
12
|
+
import { page_data } from '@mdsvex/plugin-page-data';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
plugins: [
|
|
16
|
+
mdsvex({
|
|
17
|
+
plugins: [
|
|
18
|
+
page_data({
|
|
19
|
+
edit_url: 'https://github.com/you/site/edit/main/',
|
|
20
|
+
last_modified: 'git',
|
|
21
|
+
}),
|
|
22
|
+
],
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```md
|
|
29
|
+
# Moving to runes
|
|
30
|
+
|
|
31
|
+
Signals changed how I write components. Here is what I learned.
|
|
32
|
+
|
|
33
|
+
## State
|
|
34
|
+
|
|
35
|
+
...
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
import Post, { plugin_data } from './moving-to-runes.svx';
|
|
40
|
+
|
|
41
|
+
plugin_data.page;
|
|
42
|
+
// {
|
|
43
|
+
// title: 'Moving to runes',
|
|
44
|
+
// excerpt: 'Signals changed how I write components. Here is what I learned.',
|
|
45
|
+
// words: 842,
|
|
46
|
+
// minutes: 5,
|
|
47
|
+
// edit_url: 'https://github.com/you/site/edit/main/src/routes/blog/moving-to-runes.svx',
|
|
48
|
+
// last_modified: '2026-10-15T09:30:00.000Z',
|
|
49
|
+
// }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Everything is under one key, `plugin_data.page`, and each part can be turned off. A key is only there when its part is on and found something. It reaches a page the three ways all [plugin data](https://mdsvex.pngwn.io/docs#plugin-data) does: the `plugin_data` export of the document, the `plugin_data` prop of its template, and a `?data` import. The package types the key, by adding to the `PluginData` interface of mdsvex. That is in effect once TypeScript sees an import of the package, which a `vite.config.ts` gives it. With a config it does not check, add `import type {} from '@mdsvex/plugin-page-data';` to a declaration file such as `src/app.d.ts`.
|
|
53
|
+
|
|
54
|
+
`metadata` is not touched. It stays exactly the frontmatter.
|
|
55
|
+
|
|
56
|
+
## Options
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
page_data({
|
|
60
|
+
reading_time: boolean | { words_per_minute: number }, // true, 200
|
|
61
|
+
excerpt: boolean | { max_length: number, ellipsis: string }, // true, no limit, '…'
|
|
62
|
+
title: boolean, // true
|
|
63
|
+
edit_url:
|
|
64
|
+
string |
|
|
65
|
+
{ base: string, root: string } |
|
|
66
|
+
((filename: string) => string | undefined), // off
|
|
67
|
+
last_modified:
|
|
68
|
+
'git' | 'fs' | ((filename: string) => Promise<string | Date | undefined>), // off
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
An option of the wrong shape throws a `PageDataError` when the plugin is made, with `code` set to `'option'`.
|
|
73
|
+
|
|
74
|
+
## Reading time
|
|
75
|
+
|
|
76
|
+
`words` is the number of words in the prose of the document, and `minutes` is the time to read them.
|
|
77
|
+
|
|
78
|
+
- **Prose is the text a reader reads**: headings, paragraphs, list items, block quotes, table cells, footnotes, the labels of directives, and what an element, a component or a `{#if}` block holds.
|
|
79
|
+
- **Not counted**: code blocks, the alt of an image, comments, `{expressions}`, HTML attributes, link urls and titles, `<script>` and `<style>`.
|
|
80
|
+
- **Code in a sentence is counted**, since `` `npm install` `` is read as part of it.
|
|
81
|
+
- **A word is a run of characters between spaces**, so `well-known` is one word, and markup inside a word does not split it.
|
|
82
|
+
- **Chinese, Japanese and Korean are written without spaces, so each of their characters is a word**: every Han ideograph, hiragana and hangul syllable. The punctuation after one is not a word. Katakana is not counted this way, a run of it is one word, as loan words are. This is the rule of the [`reading-time`](https://www.npmjs.com/package/reading-time) package, which `remark-reading-time` counts with.
|
|
83
|
+
- **`minutes` is rounded the way `reading-time` shows it**: `words / words_per_minute`, to two decimals, then up to a whole minute. One word is 1 minute, 200 words are 1, and 202 are 2. A document with no words has 0.
|
|
84
|
+
|
|
85
|
+
Unlike `remark-reading-time`, code blocks are left out, and the last word of a block and the first of the next are two words, not one.
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
page_data({ reading_time: { words_per_minute: 250 } });
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`count_words(text)` is exported, to count some other text by the same rule.
|
|
92
|
+
|
|
93
|
+
## Excerpt
|
|
94
|
+
|
|
95
|
+
`excerpt` is the first paragraph of the document, or everything before a `<!-- more -->` comment when the document has one.
|
|
96
|
+
|
|
97
|
+
```md
|
|
98
|
+
# Title
|
|
99
|
+
|
|
100
|
+
This paragraph is the excerpt.
|
|
101
|
+
|
|
102
|
+
This one is not.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
```md
|
|
106
|
+
# Title
|
|
107
|
+
|
|
108
|
+
With the comment below, this paragraph
|
|
109
|
+
|
|
110
|
+
and this one are the excerpt.
|
|
111
|
+
|
|
112
|
+
<!-- more -->
|
|
113
|
+
|
|
114
|
+
This one is not.
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- **It is plain text.** A parse plugin sees the document before it is rendered, so there is no HTML to give. Emphasis, links and code are their text, a character reference such as `&` is its character, and the lines of a paragraph are joined with a space. For a rendered excerpt, render the start of the document in the template instead.
|
|
118
|
+
- **The first paragraph** is the first one with text that is not inside a block quote, a list, a table, a footnote, a container directive or a Svelte block. A paragraph that only holds an image, a component or an expression is passed over.
|
|
119
|
+
- **Before `<!-- more -->`** it is every block of prose, joined with spaces. Headings, code blocks, tables and footnotes are left out. The comment can be on a line of its own or inside a paragraph, which is then cut there. Only the first one counts.
|
|
120
|
+
- **`max_length`** is the most characters the excerpt has. A longer one is cut where a word ends and gets the `ellipsis`, which counts toward the length. Text with no spaces, such as Japanese, is cut between two characters.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
page_data({ excerpt: { max_length: 160 } });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Title
|
|
127
|
+
|
|
128
|
+
`title` is the text of the first `#` heading, for a document whose frontmatter has no `title`:
|
|
129
|
+
|
|
130
|
+
```svelte
|
|
131
|
+
<script>
|
|
132
|
+
let { title, plugin_data, children } = $props();
|
|
133
|
+
</script>
|
|
134
|
+
|
|
135
|
+
<svelte:head>
|
|
136
|
+
<title>{title ?? plugin_data?.page?.title}</title>
|
|
137
|
+
</svelte:head>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
- It is only set when the frontmatter has no `title`, or an empty one. A title you wrote is in `metadata` and is never copied.
|
|
141
|
+
- The heading is one that is not inside a block quote, a list or a container directive.
|
|
142
|
+
- The text is what a reader sees, without markup. A heading that is only an expression, such as `# {title}`, has no text and is passed over.
|
|
143
|
+
|
|
144
|
+
## Edit url
|
|
145
|
+
|
|
146
|
+
`edit_url` is where the source of the document can be edited. It is off until you give it a base:
|
|
147
|
+
|
|
148
|
+
```js
|
|
149
|
+
page_data({ edit_url: 'https://github.com/you/site/edit/main/' });
|
|
150
|
+
// /home/you/site/src/routes/blog/post.svx
|
|
151
|
+
// https://github.com/you/site/edit/main/src/routes/blog/post.svx
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- **The path is the file of the document relative to `root`**, which is the working directory by default. In a monorepo, where the app is not at the root of the repository, name the root, or put the directory of the app in the base:
|
|
155
|
+
|
|
156
|
+
```js
|
|
157
|
+
page_data({
|
|
158
|
+
edit_url: {
|
|
159
|
+
base: 'https://github.com/you/repo/edit/main/',
|
|
160
|
+
root: fileURLToPath(new URL('../..', import.meta.url)),
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- **A function** gets the path of the document and returns the url, or nothing for no url.
|
|
166
|
+
- A document outside the root has no `edit_url`, and the build warns `outside_root`. With `compile()` and no `filename` there is none either, and the warning is `no_filename`.
|
|
167
|
+
|
|
168
|
+
## Last modified
|
|
169
|
+
|
|
170
|
+
`last_modified` is when the document last changed, as an ISO string in UTC. It is off until you say where the date comes from:
|
|
171
|
+
|
|
172
|
+
```js
|
|
173
|
+
page_data({ last_modified: 'git' });
|
|
174
|
+
// '2026-10-15T09:30:00.000Z'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- **`'git'`** is the date of the last commit that touched the file, its committer date, which is when the change landed on the branch. A file that is not committed yet has no date.
|
|
178
|
+
- **`'fs'`** is the modification time of the file.
|
|
179
|
+
- **A function** is given the path of the document and returns a `Date`, a string a `Date` can read, or nothing for no date. It can be async. Anything else rejects with a `PageDataError` whose `code` is `'option'`.
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
page_data({
|
|
183
|
+
last_modified: async (filename) => (await cms.page(filename))?.updated_at,
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Finding the date waits, so a document with `last_modified` on needs a compile that waits. The Vite plugin waits, and so does `compile_async` from `mdsvex`. `compile` throws a `PluginAsyncError` for it, which is how mdsvex says a plugin has async work.
|
|
188
|
+
|
|
189
|
+
### Where it works
|
|
190
|
+
|
|
191
|
+
`'git'` and `'fs'` need Node, which they import when they first run, so the package still loads in a browser. Chosen where there is no Node, in the playground for instance, they throw a `PageDataError` with `code` set to `'node'` when the plugin is made. A function works anywhere.
|
|
192
|
+
|
|
193
|
+
`'git'` runs `git`. When git can not be run, or a document is not inside a git repository, the compile fails with a `PageDataError` whose `code` is `'git'`. A file that is not there gives no date and the warning `not_found`, with either. With no `filename` there is no date and the warning is `no_filename`.
|
|
194
|
+
|
|
195
|
+
### How `'git'` reads the history
|
|
196
|
+
|
|
197
|
+
It runs one `git log` for the whole repository and keeps the date of each file, shared by every document the compiler takes (the dev server, a build, or a `compile_async` given the same `plugins` array each time). On this repository, 1,064 commits, that is one process of about 90 ms against 25 ms for each file with one `git log` per file, which is 45 seconds for its 1,513 markdown files, or 8 with eight at once. A repository with a very long history pays more for the one log, but still once.
|
|
198
|
+
|
|
199
|
+
- **A shallow clone** has no history before its cut, and CI checks out one commit by default. A file whose last commit is the cut gets no date and the warning `shallow_history`, never the date of the cut. Fetch the whole history, `fetch-depth: 0` with `actions/checkout`.
|
|
200
|
+
- **In the dev server** the history is read once. A commit made while it runs shows after a restart. The date you see while writing is the one of the last commit either way, since what you are changing is not committed.
|
|
201
|
+
- **`'fs'` in CI** is the time of the checkout for every file, so it suits a site built where it is written.
|
|
202
|
+
|
|
203
|
+
## An index page
|
|
204
|
+
|
|
205
|
+
A `?data` import parses a document and runs its plugins without rendering it, so a list of posts does not load every post:
|
|
206
|
+
|
|
207
|
+
```svelte
|
|
208
|
+
<!-- src/routes/blog/+page.svelte -->
|
|
209
|
+
<script>
|
|
210
|
+
const posts = import.meta.glob('./*/+page.svx', { query: '?data', eager: true });
|
|
211
|
+
</script>
|
|
212
|
+
|
|
213
|
+
<ul>
|
|
214
|
+
{#each Object.entries(posts) as [path, { metadata, plugin_data }] (path)}
|
|
215
|
+
<li>
|
|
216
|
+
<a href="/blog/{path.split('/')[1]}">{metadata?.title ?? plugin_data?.page?.title}</a>
|
|
217
|
+
<span>{plugin_data?.page?.minutes} min read</span>
|
|
218
|
+
<p>{plugin_data?.page?.excerpt}</p>
|
|
219
|
+
</li>
|
|
220
|
+
{/each}
|
|
221
|
+
</ul>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## With `compile`
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
import { compile } from 'mdsvex';
|
|
228
|
+
|
|
229
|
+
const { data } = compile(source, {
|
|
230
|
+
filename: '/home/you/site/post.svx',
|
|
231
|
+
plugins: [page_data()],
|
|
232
|
+
});
|
|
233
|
+
data?.page;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
An empty document has no `page` key, or only `last_modified`. The data is the same from a tree built over the wire format.
|
|
237
|
+
|
|
238
|
+
With `last_modified`, use `compile_async`, and pass the same `plugins` array to each call so the history of `'git'` is read once:
|
|
239
|
+
|
|
240
|
+
```js
|
|
241
|
+
import { compile_async } from 'mdsvex';
|
|
242
|
+
|
|
243
|
+
const plugins = [page_data({ last_modified: 'git' })];
|
|
244
|
+
for (const file of files) {
|
|
245
|
+
const { data } = await compile_async(await readFile(file, 'utf8'), {
|
|
246
|
+
filename: file,
|
|
247
|
+
plugins,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Bundle } from 'mdsvex/compile';
|
|
2
|
+
import type { FailCode, LastModified } from './last_modified.js';
|
|
3
|
+
export type { LastModified, Modified } from './last_modified.js';
|
|
4
|
+
export { count_words } from './words.js';
|
|
5
|
+
export interface ReadingTimeOptions {
|
|
6
|
+
/** 200 by default */
|
|
7
|
+
words_per_minute?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ExcerptOptions {
|
|
10
|
+
/** the most characters an excerpt has, its ellipsis included, a longer one is cut at a word */
|
|
11
|
+
max_length?: number;
|
|
12
|
+
/** what ends an excerpt that was cut, the ellipsis character by default */
|
|
13
|
+
ellipsis?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface EditUrlOptions {
|
|
16
|
+
/** what the path of the document is added to, `https://github.com/you/site/edit/main/` */
|
|
17
|
+
base: string;
|
|
18
|
+
/** the directory the path is relative to, the working directory by default */
|
|
19
|
+
root?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PageDataOptions {
|
|
22
|
+
/** `words` and `minutes`, false leaves them out */
|
|
23
|
+
reading_time?: boolean | ReadingTimeOptions;
|
|
24
|
+
/** `excerpt`, false leaves it out */
|
|
25
|
+
excerpt?: boolean | ExcerptOptions;
|
|
26
|
+
/** `title`, false leaves it out */
|
|
27
|
+
title?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* `edit_url`, off by default, a string is the base, a function is given
|
|
30
|
+
* the path of the document and returns the url or nothing
|
|
31
|
+
*/
|
|
32
|
+
edit_url?: string | EditUrlOptions | ((filename: string) => string | undefined);
|
|
33
|
+
/**
|
|
34
|
+
* `last_modified`, off by default, `'git'` is the date of the last commit
|
|
35
|
+
* that touched the document, `'fs'` the modification time of its file,
|
|
36
|
+
* both need node, a function is given the path and returns the date or
|
|
37
|
+
* nothing, a document with it needs compile_async
|
|
38
|
+
*/
|
|
39
|
+
last_modified?: LastModified;
|
|
40
|
+
}
|
|
41
|
+
/** what the plugin leaves in `plugin_data.page`, each key only when its part is on and found something */
|
|
42
|
+
export interface PageData {
|
|
43
|
+
/** the text of the first `#` heading, only when the frontmatter has no title */
|
|
44
|
+
title?: string;
|
|
45
|
+
/** the first paragraph, or what is written before a `<!-- more -->` comment, as plain text */
|
|
46
|
+
excerpt?: string;
|
|
47
|
+
/** the words of the prose, code blocks left out */
|
|
48
|
+
words?: number;
|
|
49
|
+
/** `words` over the words per minute, rounded up to a whole minute */
|
|
50
|
+
minutes?: number;
|
|
51
|
+
/** where the source of the document can be edited */
|
|
52
|
+
edit_url?: string;
|
|
53
|
+
/** when the document last changed, an ISO string such as `2026-10-15T09:30:00.000Z` */
|
|
54
|
+
last_modified?: string;
|
|
55
|
+
}
|
|
56
|
+
declare module 'mdsvex/compile' {
|
|
57
|
+
interface PluginData {
|
|
58
|
+
page?: PageData;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* code `option` for an option of the wrong shape or a last_modified function
|
|
63
|
+
* that gave no date, `node` for git or fs where there is no node, `git` for
|
|
64
|
+
* git that would not run or a document outside a repository
|
|
65
|
+
*/
|
|
66
|
+
export declare class PageDataError extends Error {
|
|
67
|
+
code: FailCode;
|
|
68
|
+
constructor(message: string, code?: FailCode);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* facts about a document for its template and for listings, left in
|
|
72
|
+
* `plugin_data.page`, an inferred title, an excerpt, a word count with a
|
|
73
|
+
* reading time and an edit url
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* import { page_data } from '@mdsvex/plugin-page-data';
|
|
77
|
+
*
|
|
78
|
+
* mdsvex({ plugins: [page_data({ edit_url: 'https://github.com/you/site/edit/main/' })] });
|
|
79
|
+
*/
|
|
80
|
+
export declare function page_data(options?: PageDataOptions): Bundle;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
function I() {
|
|
2
|
+
var t;
|
|
3
|
+
const e = (t = globalThis.process) == null ? void 0 : t.versions;
|
|
4
|
+
return typeof (e == null ? void 0 : e.node) == "string";
|
|
5
|
+
}
|
|
6
|
+
function D(e, t) {
|
|
7
|
+
if (e === void 0)
|
|
8
|
+
return;
|
|
9
|
+
const n = e instanceof Date ? e : typeof e == "string" ? new Date(e) : void 0;
|
|
10
|
+
if (n === void 0 || Number.isNaN(n.getTime()))
|
|
11
|
+
throw t("option", `last_modified must give a date, a string a Date can read or undefined, it gave ${e instanceof Date ? "an invalid Date" : JSON.stringify(e)}`);
|
|
12
|
+
return n.toISOString();
|
|
13
|
+
}
|
|
14
|
+
async function v() {
|
|
15
|
+
const [e, t, n] = await Promise.all([
|
|
16
|
+
import("node:child_process"),
|
|
17
|
+
import("node:fs/promises"),
|
|
18
|
+
import("node:path")
|
|
19
|
+
]);
|
|
20
|
+
return { child_process: e, fs: t, path: n };
|
|
21
|
+
}
|
|
22
|
+
async function J(e, t) {
|
|
23
|
+
try {
|
|
24
|
+
return await e.fs.realpath(t);
|
|
25
|
+
} catch (n) {
|
|
26
|
+
if (n.code === "ENOENT")
|
|
27
|
+
return;
|
|
28
|
+
throw n;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class j extends Error {
|
|
32
|
+
constructor(t, n) {
|
|
33
|
+
super(n), this.status = t, this.stderr = n;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function w(e, t, n) {
|
|
37
|
+
return new Promise((i, r) => {
|
|
38
|
+
const s = e.child_process.spawn("git", n, {
|
|
39
|
+
cwd: t,
|
|
40
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
41
|
+
});
|
|
42
|
+
let o = "", d = "";
|
|
43
|
+
s.stdout.setEncoding("utf8"), s.stderr.setEncoding("utf8"), s.stdout.on("data", (u) => o += u), s.stderr.on("data", (u) => d += u), s.on("error", r), s.on("close", (u) => {
|
|
44
|
+
u === 0 ? i(o) : r(new j(u, d.trim()));
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
const $ = "";
|
|
49
|
+
async function M(e, t, n) {
|
|
50
|
+
const i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
51
|
+
if (await w(e, t, [
|
|
52
|
+
"rev-parse",
|
|
53
|
+
"-q",
|
|
54
|
+
"--verify",
|
|
55
|
+
"HEAD"
|
|
56
|
+
]).then(() => !1, () => !0))
|
|
57
|
+
return { dates: i, cut: r };
|
|
58
|
+
const [o, d] = await Promise.all([
|
|
59
|
+
w(e, t, [
|
|
60
|
+
"log",
|
|
61
|
+
`--format=${$}%H %cI %P`,
|
|
62
|
+
"--name-only",
|
|
63
|
+
"--no-renames",
|
|
64
|
+
"-z"
|
|
65
|
+
]),
|
|
66
|
+
w(e, t, ["rev-parse", "--git-path", "shallow"]).then((a) => e.fs.readFile(e.path.resolve(t, a.trim()), "utf8").then((c) => new Set(c.split(`
|
|
67
|
+
`).filter((f) => f !== "")), () => /* @__PURE__ */ new Set()))
|
|
68
|
+
]).catch((a) => {
|
|
69
|
+
throw n("git", `last_modified is 'git' and git could not read the history of ${t}: ${a.message}`);
|
|
70
|
+
});
|
|
71
|
+
let u = "", m = !1;
|
|
72
|
+
for (const a of o.split("\0")) {
|
|
73
|
+
if (a.startsWith($)) {
|
|
74
|
+
const [f, p] = a.slice(1).split(" ");
|
|
75
|
+
u = new Date(p).toISOString(), m = d.has(f);
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
const c = a.startsWith(`
|
|
79
|
+
`) ? a.slice(1) : a;
|
|
80
|
+
c === "" || i.has(c) || (i.set(c, u), m && r.add(c));
|
|
81
|
+
}
|
|
82
|
+
return { dates: i, cut: r };
|
|
83
|
+
}
|
|
84
|
+
function A(e, t) {
|
|
85
|
+
t.warn("not_found", `${e} is not a file, so it has no last modified date`);
|
|
86
|
+
}
|
|
87
|
+
function T(e) {
|
|
88
|
+
return async (t, n) => {
|
|
89
|
+
const i = await v(), r = await J(i, t);
|
|
90
|
+
if (r === void 0)
|
|
91
|
+
return A(t, n);
|
|
92
|
+
const s = i.path.dirname(r), o = await n.cached(`git_root:${s}`, () => w(i, s, ["rev-parse", "--show-toplevel"]).then((a) => a.trim(), (a) => {
|
|
93
|
+
throw e("git", a.code === "ENOENT" ? `last_modified is 'git' and git could not be run: ${a.message}` : `last_modified is 'git' and ${t} is not inside a git repository: ${a.message}`);
|
|
94
|
+
})), { dates: d, cut: u } = await n.cached(`git_log:${o}`, () => M(i, o, e)), m = i.path.relative(o, r).split(i.path.sep).join("/");
|
|
95
|
+
if (u.has(m)) {
|
|
96
|
+
n.warn("shallow_history", `the history of ${t} was cut by a shallow clone, so the date of its last commit is not known, fetch the whole history (fetch-depth: 0)`);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
return d.get(m);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function F() {
|
|
103
|
+
return async (e, t) => {
|
|
104
|
+
const n = await v();
|
|
105
|
+
try {
|
|
106
|
+
return (await n.fs.stat(e)).mtime.toISOString();
|
|
107
|
+
} catch (i) {
|
|
108
|
+
if (i.code !== "ENOENT")
|
|
109
|
+
throw i;
|
|
110
|
+
return A(e, t);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function H(e, t) {
|
|
115
|
+
if (!(e === void 0 || e === !1)) {
|
|
116
|
+
if (typeof e == "function") {
|
|
117
|
+
const n = e;
|
|
118
|
+
return async (i) => D(await n(i), t);
|
|
119
|
+
}
|
|
120
|
+
if (e !== "git" && e !== "fs")
|
|
121
|
+
throw t("option", `last_modified must be 'git', 'fs' or a function, got ${JSON.stringify(e)}`);
|
|
122
|
+
if (!I())
|
|
123
|
+
throw t("node", `last_modified is '${e}', which needs node, give last_modified a function to find the date here`);
|
|
124
|
+
return e === "git" ? T(t) : F();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function q(e) {
|
|
128
|
+
return e >= 12352 && e <= 12447 || e >= 19968 && e <= 40959 || e >= 44032 && e <= 55203 || e >= 131072 && e <= 191456;
|
|
129
|
+
}
|
|
130
|
+
function R(e) {
|
|
131
|
+
return e >= 33 && e <= 47 || e >= 58 && e <= 64 || e >= 91 && e <= 96 || e >= 123 && e <= 126 || e >= 12288 && e <= 12351 || e >= 65280 && e <= 65519;
|
|
132
|
+
}
|
|
133
|
+
const W = /\s/;
|
|
134
|
+
function z(e) {
|
|
135
|
+
let t = 0, n = !1, i = !1;
|
|
136
|
+
for (const r of e) {
|
|
137
|
+
const s = r.codePointAt(0);
|
|
138
|
+
if (q(s))
|
|
139
|
+
t++, n = !1, i = !0;
|
|
140
|
+
else if (W.test(r))
|
|
141
|
+
n = !1;
|
|
142
|
+
else {
|
|
143
|
+
if (i && R(s))
|
|
144
|
+
continue;
|
|
145
|
+
i = !1, n || (t++, n = !0);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return t;
|
|
149
|
+
}
|
|
150
|
+
const G = "@mdsvex/plugin-page-data", K = "page", L = "more";
|
|
151
|
+
class _ extends Error {
|
|
152
|
+
constructor(t, n = "option") {
|
|
153
|
+
super(`[${G}] ${t}`), this.name = "PageDataError", this.code = n;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function C(e) {
|
|
157
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
158
|
+
}
|
|
159
|
+
function E(e, t) {
|
|
160
|
+
if (t !== !1) {
|
|
161
|
+
if (t === void 0 || t === !0)
|
|
162
|
+
return {};
|
|
163
|
+
if (C(t))
|
|
164
|
+
return t;
|
|
165
|
+
throw new _(`${e} must be true, false or an object of options, got ${JSON.stringify(t)}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const U = /&(?:#(\d{1,7})|#[xX]([0-9a-fA-F]{1,6})|(amp|lt|gt|quot|apos|nbsp));/g, X = {
|
|
169
|
+
amp: "&",
|
|
170
|
+
lt: "<",
|
|
171
|
+
gt: ">",
|
|
172
|
+
quot: '"',
|
|
173
|
+
apos: "'",
|
|
174
|
+
nbsp: " "
|
|
175
|
+
};
|
|
176
|
+
function B(e, t, n, i) {
|
|
177
|
+
if (i !== void 0)
|
|
178
|
+
return X[i];
|
|
179
|
+
const r = t !== void 0 ? parseInt(t, 10) : parseInt(n, 16);
|
|
180
|
+
return r === 0 || r > 1114111 || r >= 55296 && r <= 57343 ? "�" : String.fromCodePoint(r);
|
|
181
|
+
}
|
|
182
|
+
function P(e) {
|
|
183
|
+
return e.indexOf("&") === -1 ? e : e.replace(U, B);
|
|
184
|
+
}
|
|
185
|
+
const Q = /^[a-z][^.:]*$/;
|
|
186
|
+
function x(e) {
|
|
187
|
+
let t = "";
|
|
188
|
+
for (let n = e.first_child; n !== null; n = n.next)
|
|
189
|
+
switch (n.type) {
|
|
190
|
+
case "text":
|
|
191
|
+
t += P(n.text_content);
|
|
192
|
+
break;
|
|
193
|
+
case "code_span":
|
|
194
|
+
t += n.text_content;
|
|
195
|
+
break;
|
|
196
|
+
case "mustache":
|
|
197
|
+
case "svelte_tag":
|
|
198
|
+
case "svelte_block":
|
|
199
|
+
case "html_comment":
|
|
200
|
+
case "directive_inline":
|
|
201
|
+
case "directive_leaf":
|
|
202
|
+
case "directive_container":
|
|
203
|
+
break;
|
|
204
|
+
case "html": {
|
|
205
|
+
const i = n.attrs.tag;
|
|
206
|
+
typeof i == "string" && Q.test(i) && (t += x(n));
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
default:
|
|
210
|
+
t += x(n);
|
|
211
|
+
}
|
|
212
|
+
return t;
|
|
213
|
+
}
|
|
214
|
+
const V = /\s+/g;
|
|
215
|
+
function g(e) {
|
|
216
|
+
const t = e.run;
|
|
217
|
+
if (t === "")
|
|
218
|
+
return;
|
|
219
|
+
e.run = "";
|
|
220
|
+
const n = t.replace(V, " ").trim();
|
|
221
|
+
n !== "" && (e.count && (e.words += z(n)), !(e.before === void 0 || e.heading || e.table > 0) && (e.more || e.before.push(n), e.first === void 0 && e.paragraph && (e.first = n)));
|
|
222
|
+
}
|
|
223
|
+
function b(e, t) {
|
|
224
|
+
for (let n = e.first_child; n !== null; n = n.next) {
|
|
225
|
+
const i = n.type;
|
|
226
|
+
switch (i) {
|
|
227
|
+
case "text":
|
|
228
|
+
t.run += P(n.text_content);
|
|
229
|
+
break;
|
|
230
|
+
// read as part of its sentence
|
|
231
|
+
case "code_span":
|
|
232
|
+
t.run += n.text_content;
|
|
233
|
+
break;
|
|
234
|
+
case "soft_break":
|
|
235
|
+
case "hard_break":
|
|
236
|
+
t.run += " ";
|
|
237
|
+
break;
|
|
238
|
+
case "line_break":
|
|
239
|
+
g(t);
|
|
240
|
+
break;
|
|
241
|
+
case "html_comment":
|
|
242
|
+
!t.more && n.text_content.trim() === L && (g(t), t.more = !0);
|
|
243
|
+
break;
|
|
244
|
+
// nothing a reader reads as prose, the alt of an image is shown in its place
|
|
245
|
+
case "code_fence":
|
|
246
|
+
case "image":
|
|
247
|
+
case "mustache":
|
|
248
|
+
case "svelte_tag":
|
|
249
|
+
case "frontmatter":
|
|
250
|
+
case "import_statement":
|
|
251
|
+
case "thematic_break":
|
|
252
|
+
break;
|
|
253
|
+
case "html": {
|
|
254
|
+
const r = n.attrs.tag;
|
|
255
|
+
r !== "script" && r !== "style" && b(n, t);
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
case "heading":
|
|
259
|
+
if (g(t), t.title === void 0 && t.nested === 0 && n.depth === 1) {
|
|
260
|
+
const r = x(n).trim();
|
|
261
|
+
r !== "" && (t.title = r);
|
|
262
|
+
}
|
|
263
|
+
t.heading = !0, b(n, t), g(t), t.heading = !1;
|
|
264
|
+
break;
|
|
265
|
+
case "paragraph":
|
|
266
|
+
g(t), t.paragraph = t.nested === 0, b(n, t), g(t), t.paragraph = !1;
|
|
267
|
+
break;
|
|
268
|
+
case "list_item":
|
|
269
|
+
case "table_cell":
|
|
270
|
+
case "directive_leaf":
|
|
271
|
+
case "directive_label":
|
|
272
|
+
case "svelte_branch":
|
|
273
|
+
g(t), b(n, t), g(t);
|
|
274
|
+
break;
|
|
275
|
+
case "block_quote":
|
|
276
|
+
case "list":
|
|
277
|
+
case "table":
|
|
278
|
+
case "footnote_definition":
|
|
279
|
+
case "directive_container":
|
|
280
|
+
case "svelte_block": {
|
|
281
|
+
const r = i === "table" || i === "footnote_definition";
|
|
282
|
+
g(t), t.nested++, r && t.table++, b(n, t), g(t), r && t.table--, t.nested--;
|
|
283
|
+
break;
|
|
284
|
+
}
|
|
285
|
+
// emphasis, links, inline directives and whatever a plugin made
|
|
286
|
+
default:
|
|
287
|
+
b(n, t);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const Y = "…", y = /\s/, N = /[\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Hangul}]/u;
|
|
292
|
+
function Z(e, t, n) {
|
|
293
|
+
const i = Array.from(e);
|
|
294
|
+
if (i.length <= t)
|
|
295
|
+
return e;
|
|
296
|
+
let s = Math.max(0, t - Array.from(n).length);
|
|
297
|
+
if (!(s === 0 || y.test(i[s]) || N.test(i[s]) || N.test(i[s - 1]))) {
|
|
298
|
+
let d = s;
|
|
299
|
+
for (; d > 0 && !y.test(i[d - 1]); )
|
|
300
|
+
d--;
|
|
301
|
+
d > 0 && (s = d);
|
|
302
|
+
}
|
|
303
|
+
for (; s > 0 && y.test(i[s - 1]); )
|
|
304
|
+
s--;
|
|
305
|
+
return i.slice(0, s).join("") + n;
|
|
306
|
+
}
|
|
307
|
+
function O(e) {
|
|
308
|
+
return e.replace(/\\/g, "/");
|
|
309
|
+
}
|
|
310
|
+
function ee(e) {
|
|
311
|
+
if (e === void 0)
|
|
312
|
+
return;
|
|
313
|
+
if (typeof e == "function")
|
|
314
|
+
return (r, s) => {
|
|
315
|
+
if (r === void 0)
|
|
316
|
+
return k(s);
|
|
317
|
+
const o = e(r);
|
|
318
|
+
if (o === void 0 || typeof o == "string")
|
|
319
|
+
return o;
|
|
320
|
+
throw new _(`edit_url must return a string or undefined, it returned ${JSON.stringify(o)}`);
|
|
321
|
+
};
|
|
322
|
+
const t = typeof e == "string" ? { base: e } : e;
|
|
323
|
+
if (!C(t) || typeof t.base != "string" || t.base === "" || t.root !== void 0 && typeof t.root != "string")
|
|
324
|
+
throw new _(`edit_url must be a base url, an object with a base and a root, or a function, got ${JSON.stringify(e)}`);
|
|
325
|
+
const n = t.base.replace(/\/+$/, "") + "/", i = t.root;
|
|
326
|
+
return (r, s) => {
|
|
327
|
+
var m;
|
|
328
|
+
if (r === void 0)
|
|
329
|
+
return k(s);
|
|
330
|
+
const o = i ?? ((m = globalThis.process) == null ? void 0 : m.cwd()), d = O(r);
|
|
331
|
+
let u = d;
|
|
332
|
+
if (o !== void 0) {
|
|
333
|
+
const a = O(o).replace(/\/+$/, "") + "/";
|
|
334
|
+
if (!d.startsWith(a)) {
|
|
335
|
+
s.warn("outside_root", `${r} is not inside ${o}, so it has no edit url, set the root of edit_url`);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
u = d.slice(a.length);
|
|
339
|
+
}
|
|
340
|
+
return n + encodeURI(u.replace(/^\/+/, ""));
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function k(e, t = "edit url") {
|
|
344
|
+
e.warn("no_filename", `the compile was given no filename, so the document has no ${t}`);
|
|
345
|
+
}
|
|
346
|
+
function te(e = {}) {
|
|
347
|
+
const t = E("reading_time", e.reading_time), n = (t == null ? void 0 : t.words_per_minute) ?? 200;
|
|
348
|
+
if (typeof n != "number" || !Number.isFinite(n) || n <= 0)
|
|
349
|
+
throw new _(`reading_time.words_per_minute must be a number above 0, got ${JSON.stringify(n)}`);
|
|
350
|
+
const i = E("excerpt", e.excerpt), r = i == null ? void 0 : i.max_length;
|
|
351
|
+
if (r !== void 0 && (typeof r != "number" || !Number.isInteger(r) || r < 1))
|
|
352
|
+
throw new _(`excerpt.max_length must be a whole number above 0, got ${JSON.stringify(r)}`);
|
|
353
|
+
const s = (i == null ? void 0 : i.ellipsis) ?? Y;
|
|
354
|
+
if (typeof s != "string")
|
|
355
|
+
throw new _(`excerpt.ellipsis must be a string, got ${JSON.stringify(s)}`);
|
|
356
|
+
if (e.title !== void 0 && typeof e.title != "boolean")
|
|
357
|
+
throw new _(`title must be true or false, got ${JSON.stringify(e.title)}`);
|
|
358
|
+
const o = e.title !== !1, d = ee(e.edit_url), u = H(e.last_modified, (c, f) => new _(f, c));
|
|
359
|
+
function m(c, f) {
|
|
360
|
+
var S;
|
|
361
|
+
let p = c.first_child;
|
|
362
|
+
for (; p !== null && p.type === "line_break"; )
|
|
363
|
+
p = p.next;
|
|
364
|
+
if (p === null)
|
|
365
|
+
return;
|
|
366
|
+
const l = {
|
|
367
|
+
run: "",
|
|
368
|
+
count: t !== void 0,
|
|
369
|
+
words: 0,
|
|
370
|
+
heading: !1,
|
|
371
|
+
table: 0,
|
|
372
|
+
paragraph: !1,
|
|
373
|
+
nested: 0,
|
|
374
|
+
before: i === void 0 ? void 0 : [],
|
|
375
|
+
more: !1,
|
|
376
|
+
first: void 0,
|
|
377
|
+
title: o ? void 0 : null
|
|
378
|
+
};
|
|
379
|
+
if (b(c, l), g(l), typeof l.title == "string") {
|
|
380
|
+
const h = (S = f.frontmatter) == null ? void 0 : S.title;
|
|
381
|
+
(h == null || h === "") && f.set("title", l.title);
|
|
382
|
+
}
|
|
383
|
+
if (l.before !== void 0) {
|
|
384
|
+
const h = l.more ? l.before.join(" ") : l.first;
|
|
385
|
+
h !== void 0 && h !== "" && f.set("excerpt", r === void 0 ? h : Z(h, r, s));
|
|
386
|
+
}
|
|
387
|
+
if (l.count && (f.set("words", l.words), f.set("minutes", Math.ceil(Number((l.words / n).toFixed(2))))), d !== void 0) {
|
|
388
|
+
const h = d(f.filename, f);
|
|
389
|
+
h !== void 0 && f.set("edit_url", h);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
async function a(c) {
|
|
393
|
+
const f = c.filename;
|
|
394
|
+
if (f === void 0)
|
|
395
|
+
return k(c, "last modified date");
|
|
396
|
+
const p = await u(f, c);
|
|
397
|
+
p !== void 0 && c.set("last_modified", p);
|
|
398
|
+
}
|
|
399
|
+
return {
|
|
400
|
+
name: K,
|
|
401
|
+
parse: {
|
|
402
|
+
// once the tree is settled, a count kept while nodes are revoked is not exact
|
|
403
|
+
document(c, f) {
|
|
404
|
+
if (m(c, f), u !== void 0)
|
|
405
|
+
return a(f);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
export {
|
|
411
|
+
_ as PageDataError,
|
|
412
|
+
z as count_words,
|
|
413
|
+
te as page_data
|
|
414
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginContext } from 'mdsvex/compile';
|
|
2
|
+
/** a date as the function of last_modified gives it */
|
|
3
|
+
export type Modified = string | Date | undefined;
|
|
4
|
+
export type LastModified = 'git' | 'fs' | ((filename: string) => Modified | Promise<Modified>);
|
|
5
|
+
/** the date of a document as an ISO string, undefined for none */
|
|
6
|
+
export type ModifiedOf = (filename: string, ctx: PluginContext) => Promise<string | undefined>;
|
|
7
|
+
export type FailCode = 'option' | 'node' | 'git';
|
|
8
|
+
type Fail = (code: FailCode, message: string) => Error;
|
|
9
|
+
/** true where node:child_process and node:fs can be imported, deno and bun say they are node */
|
|
10
|
+
export declare function has_node(): boolean;
|
|
11
|
+
/** how the date of a document is found, undefined when last_modified is off */
|
|
12
|
+
export declare function last_modified_of(option: unknown, fail: Fail): ModifiedOf | undefined;
|
|
13
|
+
export {};
|
package/dist/words.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* the words of a text, a run of characters between spaces is one word, and
|
|
3
|
+
* so is each cjk character, which is written without spaces, the punctuation
|
|
4
|
+
* after a cjk character is no word
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* count_words('Hello world'); // 2
|
|
8
|
+
* count_words('こんにちは、世界'); // 7
|
|
9
|
+
*/
|
|
10
|
+
export declare function count_words(text: string): number;
|
package/package.json
CHANGED
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdsvex/plugin-page-data",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
3
|
+
"version": "0.1.0-next.0",
|
|
4
|
+
"description": "Page data for mdsvex, the reading time, excerpt, inferred title, edit url and last modified date of a document",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"sideEffects": false,
|
|
7
17
|
"repository": {
|
|
8
18
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/pngwn/MDsveX",
|
|
19
|
+
"url": "git+https://github.com/pngwn/MDsveX.git",
|
|
10
20
|
"directory": "plugins/page-data"
|
|
11
21
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mdsvex",
|
|
24
|
+
"mdsvex-plugin",
|
|
25
|
+
"markdown",
|
|
26
|
+
"reading-time",
|
|
27
|
+
"excerpt",
|
|
28
|
+
"title",
|
|
29
|
+
"last-modified"
|
|
30
|
+
],
|
|
31
|
+
"author": "pngwn <hello@pngwn.io>",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"mdsvex": "^1.0.0-next.2"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@types/node": "^22.15.2",
|
|
38
|
+
"npm-run-all2": "^7.0.2",
|
|
39
|
+
"shx": "^0.3.4",
|
|
40
|
+
"mdsvex": "^1.0.0-next.2"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "run-s build:tsc build:vite build:copy-dts",
|
|
44
|
+
"build:tsc": "tsc",
|
|
45
|
+
"build:vite": "vite build --config vite.config.build.ts",
|
|
46
|
+
"build:copy-dts": "shx cp tsc/*.d.ts dist/",
|
|
47
|
+
"test": "vitest --disableConsoleIntercept",
|
|
48
|
+
"test:run": "vitest run"
|
|
14
49
|
}
|
|
15
50
|
}
|