UNPKG

iles

Version:

Vite & Vue powered static site generator with partial hydration

18 lines (16 loc) 595 B
// src/node/utils.ts import { basename, extname } from "pathe"; function pathToHtmlFilename(path, filename) { const ext = extname(path); if (ext) return path; if (!path.endsWith("/") && filename && basename(filename).split(".")[0] === "index") path += "/"; return path + (path.endsWith("/") ? "index.html" : ".html"); } function explicitHtmlPath(path, filename) { const htmlFilename = pathToHtmlFilename(path, filename); return htmlFilename.endsWith("/index.html") ? htmlFilename.replace(/\/index\.html$/, "/") : htmlFilename; } export { pathToHtmlFilename, explicitHtmlPath };