@tenjot/fumi 0.1.0 → 0.1.1
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/dist/index.mjs +26 -9
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import vue from "@vitejs/plugin-vue";
|
|
|
5
5
|
import { createFilter, defineConfig as defineConfig$1, loadConfigFromFile, normalizePath } from "vite";
|
|
6
6
|
import { mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
7
7
|
import { readFile } from "fs/promises";
|
|
8
|
+
import { join, resolve as resolve$1 } from "node:path";
|
|
8
9
|
import { toHtml } from "hast-util-to-html";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
9
11
|
import { glob } from "tinyglobby";
|
|
10
12
|
import pm from "picomatch";
|
|
11
13
|
import { unified } from "unified";
|
|
@@ -15,7 +17,7 @@ import remarkParse from "remark-parse";
|
|
|
15
17
|
import remarkRehype from "remark-rehype";
|
|
16
18
|
import rehypeStringify from "rehype-stringify";
|
|
17
19
|
import matter from "gray-matter";
|
|
18
|
-
|
|
20
|
+
const APP = join(resolve$1(fileURLToPath(import.meta.url), ".."), "main.mjs");
|
|
19
21
|
function headConfigToHast(head) {
|
|
20
22
|
return head.map(([tagName, a, c]) => {
|
|
21
23
|
return {
|
|
@@ -71,7 +73,7 @@ function urlToOutPath(outDir, url) {
|
|
|
71
73
|
if (url === "/") return resolve(outDir, "index.html");
|
|
72
74
|
return resolve(outDir, url.slice(1) + ".html");
|
|
73
75
|
}
|
|
74
|
-
function build(
|
|
76
|
+
function build() {
|
|
75
77
|
let outDir;
|
|
76
78
|
return {
|
|
77
79
|
name: "fumi:build",
|
|
@@ -272,16 +274,16 @@ function dataLoader(markdownOptions, config) {
|
|
|
272
274
|
//#endregion
|
|
273
275
|
//#region src/plugins/dev-server.ts
|
|
274
276
|
const isCss = createFilter([/\.css(?:$|\?)/], [/[?&](?:worker|sharedworker|raw|url)\b/, /[?&]commonjs-proxy/]);
|
|
275
|
-
function devServer(
|
|
277
|
+
function devServer() {
|
|
276
278
|
return {
|
|
277
279
|
name: "fumi:dev-server",
|
|
278
280
|
apply: "serve",
|
|
279
281
|
configureServer(server) {
|
|
280
|
-
return dev(server
|
|
282
|
+
return dev(server);
|
|
281
283
|
}
|
|
282
284
|
};
|
|
283
285
|
}
|
|
284
|
-
async function dev(server
|
|
286
|
+
async function dev(server) {
|
|
285
287
|
const root = server.config.root;
|
|
286
288
|
const fumiRoot = resolve(root, ".fumi");
|
|
287
289
|
const ssrEnv = server.environments.ssr;
|
|
@@ -293,6 +295,7 @@ async function dev(server, config) {
|
|
|
293
295
|
if (url.endsWith(".map")) return next();
|
|
294
296
|
if (url === "/favicon.ico") return next();
|
|
295
297
|
if (url.startsWith("/__app/")) return next();
|
|
298
|
+
if (url.startsWith("/@")) return next();
|
|
296
299
|
let html = readFileSync(resolve(fumiRoot, "index.html"), "utf-8");
|
|
297
300
|
html = await server.transformIndexHtml(url, html);
|
|
298
301
|
const { render } = await ssrEnv.runner.import("@tenjot/fumi/ssr");
|
|
@@ -357,7 +360,7 @@ function renderCssMod(mod) {
|
|
|
357
360
|
}
|
|
358
361
|
//#endregion
|
|
359
362
|
//#region src/plugins/page.ts
|
|
360
|
-
function page(
|
|
363
|
+
function page() {
|
|
361
364
|
let root;
|
|
362
365
|
return [{
|
|
363
366
|
name: "fumi:page",
|
|
@@ -385,6 +388,19 @@ function existsFile(path) {
|
|
|
385
388
|
}
|
|
386
389
|
}
|
|
387
390
|
//#endregion
|
|
391
|
+
//#region src/plugins/client.ts
|
|
392
|
+
function client() {
|
|
393
|
+
return {
|
|
394
|
+
name: "fumi:client",
|
|
395
|
+
transformIndexHtml: {
|
|
396
|
+
order: "pre",
|
|
397
|
+
handler(html) {
|
|
398
|
+
return html.replace("<!--app-html-->", `<!--app-html-->\n<script type="module" src="/@fs${APP}"><\/script>`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
//#endregion
|
|
388
404
|
//#region src/config.ts
|
|
389
405
|
/**
|
|
390
406
|
* Viteの設定。
|
|
@@ -397,9 +413,10 @@ function defineConfig(userConfig = {}) {
|
|
|
397
413
|
...viteUserConfig,
|
|
398
414
|
plugins: [
|
|
399
415
|
vue(vueOptions),
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
416
|
+
client(),
|
|
417
|
+
devServer(),
|
|
418
|
+
build(),
|
|
419
|
+
page(),
|
|
403
420
|
markdown(markdownOptions, fumiConfig),
|
|
404
421
|
dataLoader(markdownOptions, fumiConfig),
|
|
405
422
|
...viteUserConfig.plugins ?? []
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenjot/fumi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "A static site generator for Vue + remark",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "tenjo-t",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
7
10
|
"type": "module",
|
|
8
11
|
"imports": {
|
|
9
12
|
"#editor/*": "./dist/editor/*"
|
|
@@ -29,9 +32,6 @@
|
|
|
29
32
|
"default": "./dist/ssr.mjs"
|
|
30
33
|
}
|
|
31
34
|
},
|
|
32
|
-
"files": [
|
|
33
|
-
"dist"
|
|
34
|
-
],
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|