minista 2.8.1 → 2.8.3

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 CHANGED
@@ -80,6 +80,10 @@ import { defineConfig } from "minista"
80
80
 
81
81
  export default defineConfig({
82
82
  base: "/", // string
83
+ // Absolute URL pathname, e.g. "/foo/"
84
+ // Full URL, e.g. "https://foo.com/"
85
+ // Empty string or "./" (for embedded deployment)
86
+ // https://ja.vitejs.dev/config/shared-options.html#base
83
87
  public: "public", // string
84
88
  out: "dist", // string
85
89
  root: {
package/dist/build.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Options as MdxOptions } from "@mdx-js/esbuild";
2
2
  import type { Config as SvgrOptions } from "@svgr/core";
3
3
  import type { InlineConfig } from "vite";
4
- import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions, EntryObject } from "./types.js";
4
+ import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions, EntryObject, AssetsTagObject } from "./types.js";
5
5
  export declare function buildTempPages(entryPoints: string[], buildOptions: {
6
6
  outBase: string;
7
7
  outDir: string;
@@ -15,10 +15,7 @@ export declare function buildStaticPages({ entryPoints, tempRootFilePath, outBas
15
15
  tempRootFilePath: string;
16
16
  outBase: string;
17
17
  outDir: string;
18
- assetsTagArray: {
19
- pattern: string[];
20
- tag: string;
21
- }[];
18
+ assetsTagArray: AssetsTagObject[];
22
19
  showLog: boolean;
23
20
  }): Promise<void>;
24
21
  export declare function buildRootEsmContent(tempRootFilePath: string): Promise<{
@@ -30,10 +27,7 @@ export declare function buildStaticPage({ entryPoint, outFile, rootStaticContent
30
27
  entryPoint: string;
31
28
  outFile: string;
32
29
  rootStaticContent: RootStaticContent;
33
- assetsTagArray: {
34
- pattern: string[];
35
- tag: string;
36
- }[];
30
+ assetsTagArray: AssetsTagObject[];
37
31
  outDir: string;
38
32
  showLog: boolean;
39
33
  }): Promise<void>;
@@ -43,10 +37,7 @@ export declare function buildHtmlPage({ pageJsxContent, staticDataItem, routePat
43
37
  staticDataItem: StaticDataItem;
44
38
  routePath: string;
45
39
  rootStaticContent: RootStaticContent;
46
- assetsTagArray: {
47
- pattern: string[];
48
- tag: string;
49
- }[];
40
+ assetsTagArray: AssetsTagObject[];
50
41
  frontmatter: any;
51
42
  outDir: string;
52
43
  showLog: boolean;
@@ -65,16 +56,10 @@ outBase, hrefBase, entryPattern, bundlePattern, partialPattern, }: {
65
56
  entryPattern?: EntryObject[];
66
57
  bundlePattern?: EntryObject[];
67
58
  partialPattern?: EntryObject[];
68
- }): {
69
- pattern: string[];
70
- tag: string;
71
- }[];
59
+ }): AssetsTagObject[];
72
60
  export declare function buildAssetsTagStr({ pathname, assetsTagArray, }: {
73
61
  pathname: string;
74
- assetsTagArray: {
75
- pattern: string[];
76
- tag: string;
77
- }[];
62
+ assetsTagArray: AssetsTagObject[];
78
63
  }): string;
79
64
  export declare function buildViteImporterRoots(config: MinistaResolveConfig): Promise<void>;
80
65
  export declare function buildViteImporterRoutes(config: MinistaResolveConfig): Promise<void>;
package/dist/build.js CHANGED
@@ -336,18 +336,34 @@ function buildAssetsTagArray({
336
336
  const assetPath = entryPoint.replace(outBase, hrefBase).replace(winOutBase, hrefBase).replaceAll("\\", "/");
337
337
  const name = getFilename(assetPath);
338
338
  if (assetPath.endsWith(".css")) {
339
- return { name, tag: `<link rel="stylesheet" href="${assetPath}">` };
339
+ return {
340
+ name,
341
+ assetTag: `<link rel="stylesheet" href="${assetPath}">`,
342
+ assetPath
343
+ };
340
344
  } else {
341
- return { name, tag: `<script defer src="${assetPath}"><\/script>` };
345
+ return {
346
+ name,
347
+ assetTag: `<script defer src="${assetPath}"><\/script>`,
348
+ assetPath
349
+ };
342
350
  }
343
351
  });
344
352
  const patterns = [...entryPattern, ...bundlePattern, ...partialPattern];
345
353
  const result = assets.map((asset) => {
346
354
  const targetPattern = patterns.find((pattern) => pattern.name === asset.name);
347
355
  if (targetPattern) {
348
- return { pattern: targetPattern.insertPages, tag: asset.tag };
356
+ return {
357
+ pattern: targetPattern.insertPages,
358
+ assetTag: asset.assetTag,
359
+ assetPath: asset.assetPath
360
+ };
349
361
  } else {
350
- return { pattern: ["**/*"], tag: asset.tag };
362
+ return {
363
+ pattern: ["**/*"],
364
+ assetTag: asset.assetTag,
365
+ assetPath: asset.assetPath
366
+ };
351
367
  }
352
368
  });
353
369
  return result;
@@ -361,11 +377,22 @@ function buildAssetsTagStr({
361
377
  }
362
378
  const result = assetsTagArray.map((item) => {
363
379
  const check = picomatch.isMatch(pathname, item.pattern);
364
- if (check) {
365
- return item.tag;
366
- } else {
380
+ if (!check) {
367
381
  return "";
368
382
  }
383
+ if (!item.assetPath.startsWith("./")) {
384
+ return item.assetTag;
385
+ }
386
+ const slashArray = pathname.match(/\//g);
387
+ const slashCount = slashArray ? slashArray.length : 1;
388
+ if (slashCount >= 2) {
389
+ const upStr = [...Array(slashCount - 1)].map(() => "../").join("");
390
+ const relativePath = item.assetPath.replace(/^\.\//, upStr);
391
+ const relativeAssetTag = item.assetTag.replace(new RegExp(item.assetPath), relativePath);
392
+ return relativeAssetTag;
393
+ } else {
394
+ return item.assetTag;
395
+ }
369
396
  }).join("");
370
397
  return result;
371
398
  }
@@ -412,6 +439,7 @@ async function buildViteImporterRoutes(config) {
412
439
  ${replaceFileNameArrayStr}
413
440
  .replace(/\\[\\.{3}.+\\]/, "*")
414
441
  .replace(/\\[(.+)\\]/, ":$1")
442
+ .replace(/^.\\//, "/")
415
443
  return {
416
444
  routePath: routePath,
417
445
  PageComponent: ROUTES[route].default,
@@ -734,7 +762,7 @@ async function buildSearchJson({
734
762
  blockTextElements: { script: false, style: false, pre: false }
735
763
  });
736
764
  const regTrimPath = new RegExp(`^${entryBase}|index|.html`, "g");
737
- const path2 = filePath.replace(regTrimPath, "");
765
+ const routePath = path.join(config.base, filePath.replace(regTrimPath, ""));
738
766
  const regTrimTitle = new RegExp(trimTitle);
739
767
  const pTitle = parsedHtml.querySelector("title");
740
768
  const title = pTitle ? pTitle.rawText.replace(regTrimTitle, "") : "";
@@ -743,7 +771,7 @@ async function buildSearchJson({
743
771
  if (!targetContent) {
744
772
  tempWords.push(title);
745
773
  tempPages.push({
746
- path: path2,
774
+ path: routePath,
747
775
  toc: [],
748
776
  title: titleArray,
749
777
  content: []
@@ -787,7 +815,7 @@ async function buildSearchJson({
787
815
  tempWords.push(title);
788
816
  tempWords.push(body);
789
817
  tempPages.push({
790
- path: path2,
818
+ path: routePath,
791
819
  toc,
792
820
  title: titleArray,
793
821
  content: contentArray.flat()
@@ -809,7 +837,7 @@ async function buildSearchJson({
809
837
  });
810
838
  const pages = [];
811
839
  await Promise.all(tempPages.map(async (page) => {
812
- const path2 = page.path;
840
+ const routePath = page.path;
813
841
  const toc = page.toc;
814
842
  const title = page.title.map((word) => {
815
843
  return sortedWords.indexOf(word);
@@ -817,7 +845,7 @@ async function buildSearchJson({
817
845
  const content = page.content.map((word) => {
818
846
  return sortedWords.indexOf(word);
819
847
  });
820
- pages.push({ path: path2, title, toc, content });
848
+ pages.push({ path: routePath, title, toc, content });
821
849
  }));
822
850
  const sortedPages = pages.sort((a, b) => {
823
851
  const pathA = a.path.toUpperCase();
package/dist/types.d.ts CHANGED
@@ -219,6 +219,11 @@ export declare type UserEntryObject = {
219
219
  exclude?: string[];
220
220
  };
221
221
  };
222
+ export declare type AssetsTagObject = {
223
+ pattern: string[];
224
+ assetTag: string;
225
+ assetPath: string;
226
+ };
222
227
  export declare type MinistaResolveAliasInput = AliasObject | AliasArray;
223
228
  export declare type MinistaResolveAliasConfig = {
224
229
  alias: AliasArray;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "minista",
3
3
  "description": "Next.js Like Development with 100% Static Generate",
4
- "version": "2.8.1",
4
+ "version": "2.8.3",
5
5
  "bin": {
6
6
  "minista": "./bin/minista.js"
7
7
  },