You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

vite-plugin-auto-mpa-html

Package Overview
Dependencies
Maintainers
0
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-auto-mpa-html - npm Package Compare versions

Comparing version

to
1.3.0

LICENSE

@@ -0,1 +1,10 @@

# [1.3.0](https://github.com/iamspark1e/vite-plugin-auto-mpa-html/compare/v1.2.0...v1.3.0) (2024-11-26)
### Features
* migrate template engine from liquidjs to handlebars ([16e511c](https://github.com/iamspark1e/vite-plugin-auto-mpa-html/commit/16e511c105f46ba385771c0c5c5c41e61c9d9dcc))
# [1.2.0](https://github.com/iamspark1e/vite-plugin-auto-mpa-html/compare/v1.1.3...v1.2.0) (2024-08-29)

@@ -2,0 +11,0 @@

6

dist/index.d.ts

@@ -1,2 +0,2 @@

import { LiquidOptions } from 'liquidjs';
import Handlebars from 'handlebars';
import { Plugin } from 'vite';

@@ -7,3 +7,3 @@

configName?: string;
renderEngineOption?: LiquidOptions;
renderEngineOption?: Handlebars.RuntimeOptions;
sharedData?: object;

@@ -20,3 +20,3 @@ enableDevDirectory?: boolean;

configName?: string;
renderEngineOption?: LiquidOptions;
renderEngineOption?: Handlebars.RuntimeOptions;
sharedData?: object;

@@ -23,0 +23,0 @@ enableDevDirectory: boolean;

@@ -96,3 +96,3 @@ var __defProp = Object.defineProperty;

} from "fs";
import { Liquid } from "liquidjs";
import Handlebars from "handlebars";
import path from "path";

@@ -116,5 +116,5 @@ import { pathToFileURL } from "url";

</html>`;
function renderLiquidTpl(templateStr, data, liquidjsOption) {
const engine = new Liquid(liquidjsOption);
return engine.parseAndRenderSync(templateStr, data);
function renderHandlebarsTpl(templateStr, data, handlebarsOption) {
const tmpl = Handlebars.compile(templateStr, handlebarsOption);
return tmpl(data);
}

@@ -136,3 +136,3 @@ function fetchTemplateHTML(entry, pageConfig) {

}
htmlContent = renderLiquidTpl(
htmlContent = renderHandlebarsTpl(
htmlContent,

@@ -161,3 +161,3 @@ __spreadValues(__spreadValues({}, entry.__options.sharedData), pageConfig.data),

} else if (entry.__options.configName.endsWith(".js")) {
let config = yield import(pathToFileURL(configPath).toString()).catch((e) => {
const config = yield import(pathToFileURL(configPath).toString()).catch((e) => {
_console.fatal(e.message);

@@ -178,5 +178,5 @@ });

const generatedHtml = fetchTemplateHTML(entry, pageData);
let tplPath = path.join(entry.abs, entry.__options.templateName);
const tplPath = path.join(entry.abs, entry.__options.templateName);
if (existsSync(tplPath)) {
let fileContent = readFileSync(tplPath, { encoding: "utf-8" });
const fileContent = readFileSync(tplPath, { encoding: "utf-8" });
if (!fileContent.startsWith(GENERATED_FLAG)) {

@@ -192,6 +192,6 @@ _console.warn(`There is a same named HTML file (${entry.__options.templateName}) already exist in entry '${entry.value}', template generation skipped`);

return __async(this, null, function* () {
let virtualMap = /* @__PURE__ */ new Map();
const virtualMap = /* @__PURE__ */ new Map();
yield Promise.all(entries.map((entry) => __async(this, null, function* () {
let tplPath = entry.__options.templateName.startsWith(".") ? entry.abs + entry.__options.templateName : path.join(entry.abs, entry.__options.templateName);
let generatedHtml = yield prepareSingleVirtualEntry(entry, pluginOption);
const tplPath = entry.__options.templateName.startsWith(".") ? entry.abs + entry.__options.templateName : path.join(entry.abs, entry.__options.templateName);
const generatedHtml = yield prepareSingleVirtualEntry(entry, pluginOption);
virtualMap.set(tplPath, generatedHtml);

@@ -198,0 +198,0 @@ })));

{
"name": "vite-plugin-auto-mpa-html",
"version": "1.2.0",
"description": "A file directory-based automated multi-page Vite plugin that supports HTML templates using LiquidJS.",
"version": "1.3.0",
"description": "A file directory-based automated multi-page Vite plugin that supports HTML templates using Handlebars.",
"main": "./dist/index.js",

@@ -38,3 +38,3 @@ "module": "./dist/index.js",

"glob": "^9.3.1",
"liquidjs": "^10.16.5"
"handlebars": "^4.7.8"
},

@@ -41,0 +41,0 @@ "devDependencies": {

@@ -12,4 +12,4 @@ <h1 align='center'>vite-plugin-auto-mpa-html</h1>

<br />
<p align='center'>A file directory-based automated multi-page Vite plugin that supports HTML templates using LiquidJS.</p>
<p align='center'>基于文件目录的Vite自动化多页面构建插件,支持使用 LiquidJS 的 HTML 模板。</p>
<p align='center'>A file directory-based automated multi-page Vite plugin that supports HTML templates using Handlebars.</p>
<p align='center'>基于文件目录的Vite自动化多页面构建插件,支持使用 Handlebars 的 HTML 模板。</p>
<br />

@@ -119,3 +119,3 @@

/**
* Top-level data, which will be shared to every entry during LiquidJS render.
* Top-level data, which will be shared to every entry during Handlebars render.
* @default {}

@@ -125,4 +125,4 @@ */

/**
* Render engine options, currently using LiquidJS
* @see {@link https://liquidjs.com/tutorials/options.html}
* Render engine options, currently using Handlebars
* @see {@link https://Handlebars.com/tutorials/options.html}
* @default {}

@@ -168,3 +168,3 @@ */

/**
* LiquidJS render data in this entry, which will be assigned with global `sharedData`
* Handlebars render data in this entry, which will be assigned with global `sharedData`
* @default {}

@@ -190,3 +190,3 @@ */

We have an option called `sharedData` cross pages, so you can inject the variables you need, then read them in page's config (or directly use in LiquidJS templates), like this,
We have an option called `sharedData` cross pages, so you can inject the variables you need, then read them in page's config (or directly use in Handlebars templates), like this,

@@ -193,0 +193,0 @@ ```javascript

@@ -12,3 +12,3 @@ <h1 align='center'>vite-plugin-auto-mpa-html</h1>

<br />
<p align='center'>基于文件目录的Vite自动化多页面构建插件,支持使用 LiquidJS 的 HTML 模板。</p>
<p align='center'>基于文件目录的Vite自动化多页面构建插件,支持使用 Handlebars 的 HTML 模板。</p>
<br />

@@ -118,3 +118,3 @@

/**
* 顶层配置的共享数据,在渲染LiquidJS时会添加到每个入口处。
* 顶层配置的共享数据,在渲染Handlebars时会添加到每个入口处。
* @default {}

@@ -124,4 +124,4 @@ */

/**
* LiquidJS的一些配置选项
* @see {@link https://liquidjs.com/tutorials/options.html}
* Handlebars的一些配置选项
* @see {@link https://Handlebars.com/tutorials/options.html}
* @default {}

@@ -169,3 +169,3 @@ */

/**
* 本页LiquidJS模板使用的渲染数据,会与顶层配置的sharedData进行合并
* 本页Handlebars模板使用的渲染数据,会与顶层配置的sharedData进行合并
* @default {}

@@ -191,3 +191,3 @@ */

借助跨页面的选项 `sharedData` ,您可以注入所需的变量,然后在页面配置中读取它们(或直接在 LiquidJS 模板中使用),例如:
借助跨页面的选项 `sharedData` ,您可以注入所需的变量,然后在页面配置中读取它们(或直接在 Handlebars 模板中使用),例如:

@@ -194,0 +194,0 @@ ```javascript

Sorry, the diff of this file is not supported yet