@mdream/vite 0.15.2 → 0.16.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 -4
- package/dist/index.mjs +6 -13
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -177,16 +177,15 @@ export default defineConfig({
|
|
|
177
177
|
|
|
178
178
|
```javascript
|
|
179
179
|
import { viteHtmlToMarkdownPlugin } from '@mdream/vite'
|
|
180
|
-
import {
|
|
180
|
+
import { filterPlugin, isolateMainPlugin } from 'mdream/plugins'
|
|
181
181
|
|
|
182
182
|
export default defineConfig({
|
|
183
183
|
plugins: [
|
|
184
184
|
viteHtmlToMarkdownPlugin({
|
|
185
185
|
mdreamOptions: {
|
|
186
186
|
plugins: [
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})
|
|
187
|
+
isolateMainPlugin(),
|
|
188
|
+
filterPlugin({ exclude: ['nav', '.sidebar'] })
|
|
190
189
|
]
|
|
191
190
|
}
|
|
192
191
|
})
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { htmlToMarkdown } from "mdream";
|
|
4
|
-
|
|
5
|
-
//#region src/plugin.ts
|
|
6
4
|
const DEFAULT_OPTIONS = {
|
|
7
5
|
include: ["*.html", "**/*.html"],
|
|
8
6
|
exclude: ["**/node_modules/**"],
|
|
@@ -103,7 +101,7 @@ function viteHtmlToMarkdownPlugin(userOptions = {}) {
|
|
|
103
101
|
function matchesPattern(fileName, patterns) {
|
|
104
102
|
return patterns.some((pattern) => {
|
|
105
103
|
const regexPattern = pattern.replace(/\./g, "\\.").replace(/\*\*/g, ".*").replace(/\*/g, "[^/]*").replace(/\?/g, ".");
|
|
106
|
-
return
|
|
104
|
+
return new RegExp(`^${regexPattern}$`).test(fileName);
|
|
107
105
|
});
|
|
108
106
|
}
|
|
109
107
|
function shouldServeMarkdown(acceptHeader, secFetchDest) {
|
|
@@ -114,11 +112,11 @@ function viteHtmlToMarkdownPlugin(userOptions = {}) {
|
|
|
114
112
|
}
|
|
115
113
|
function createMarkdownMiddleware(getServer, getOutDir, cacheControl) {
|
|
116
114
|
return async (req, res, next) => {
|
|
117
|
-
const path
|
|
118
|
-
const hasMarkdownExtension = path
|
|
115
|
+
const path = new URL(req.url || "", "http://localhost").pathname;
|
|
116
|
+
const hasMarkdownExtension = path.endsWith(".md");
|
|
119
117
|
const clientPrefersMarkdown = shouldServeMarkdown(req.headers.accept, req.headers["sec-fetch-dest"]);
|
|
120
|
-
if (path
|
|
121
|
-
const lastSegment = path
|
|
118
|
+
if (path.startsWith("/api") || path.startsWith("/_") || path.startsWith("/@")) return next();
|
|
119
|
+
const lastSegment = path.split("/").pop() || "";
|
|
122
120
|
const hasExtension = lastSegment.includes(".");
|
|
123
121
|
const extension = hasExtension ? lastSegment.substring(lastSegment.lastIndexOf(".")) : "";
|
|
124
122
|
if (hasExtension && extension !== ".md") return next();
|
|
@@ -171,10 +169,5 @@ function viteHtmlToMarkdownPlugin(userOptions = {}) {
|
|
|
171
169
|
}
|
|
172
170
|
};
|
|
173
171
|
}
|
|
174
|
-
|
|
175
|
-
//#endregion
|
|
176
|
-
//#region src/index.ts
|
|
177
172
|
var src_default = viteHtmlToMarkdownPlugin;
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
export { src_default as default, viteHtmlToMarkdownPlugin };
|
|
173
|
+
export { src_default as default, viteHtmlToMarkdownPlugin };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdream/vite",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.16.0",
|
|
5
5
|
"description": "Vite plugin for HTML to Markdown conversion with on-demand generation",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Harlan Wilton",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"vite": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"mdream": "0.
|
|
46
|
+
"mdream": "0.16.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^
|
|
50
|
-
"vite": "^7.
|
|
49
|
+
"@types/node": "^25.2.3",
|
|
50
|
+
"vite": "^7.3.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "obuild",
|