website: fix windows path issue. #161

This commit is contained in:
jaywcjlove 2022-11-21 23:43:42 +08:00
parent 8399eafe6e
commit e0e7636ba4
2 changed files with 2 additions and 2 deletions

View File

@ -42,7 +42,7 @@ export async function createHTML(files = [], num = 0) {
const { html, data } = create(mdstr.toString(), options);
if (!options.isHome) {
const searchData = await fs.readJSON(SEARCH_DATA_CACHE);
data.path = path.relative(OUTOUT, outputHTMLPath);
data.path = path.relative(OUTOUT, outputHTMLPath).replace(/[\\/]/g, '/');
searchData[options.filename] = data;
searchData.name = options.filename;
await fs.writeJSON(SEARCH_DATA_CACHE, searchData);

View File

@ -4,7 +4,7 @@ import { getSVGNode } from './getSVGNode.mjs';
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets');
export function darkMode({ homePath = '', isHome } = {}) {
const relativePath = homePath.replace(/\/?index.html$/, isHome ? '' : '/');
const relativePath = homePath.replace(/[\\/]?index.html$/, isHome ? '' : '/');
const iconSunPath = path.resolve(ICONS_PATH, `sun.svg`);
const iconMoonPath = path.resolve(ICONS_PATH, `moon.svg`);
const sunNode = getSVGNode(iconSunPath);