Skip to content

Commit cc6f4fb

Browse files
committed
fix: Solve the static resource cache issue. (#10)
1 parent 1be9abe commit cc6f4fb

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/nodes/darkMode.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from 'path';
22
import { Element } from 'hast';
33
import { getSVGNode } from '../utils/getSVGNode.js';
44
import { Option as InitOption } from './search.js';
5+
import { pkg } from '../utils/utils.js';
56

67
interface Option extends InitOption {
78
githubURL?: string;
@@ -13,7 +14,7 @@ export function darkMode({ homePath = '', isHome, static_path }: Option = {}): E
1314
const iconMoonPath = path.resolve(static_path, `assets/moon.svg`);
1415
const sunNode = getSVGNode(iconSunPath);
1516
const moonNode = getSVGNode(iconMoonPath);
16-
const darkJSUrl = relativePath + 'js/dark.js';
17+
const darkJSUrl = relativePath + 'js/dark.js' + `?v=${pkg.version}`;
1718
return [
1819
{
1920
type: 'element',

src/nodes/search.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import path from 'path';
22
import { Element } from 'hast';
33
import { getSVGNode } from '../utils/getSVGNode.js';
4-
import { Options as RunOptions } from '../utils/utils.js';
5-
4+
import { Options as RunOptions, pkg } from '../utils/utils.js';
65

76
export interface Option extends Partial<RunOptions> {
87
isHome?: boolean;
@@ -11,9 +10,9 @@ export interface Option extends Partial<RunOptions> {
1110

1211
export function search({ homePath = '', isHome, static_path, config }: Option = {}): Element[] {
1312
const relativePath = homePath.replace(/\/?index.html$/, isHome ? '' : '/');
14-
const fuseJSUrl = relativePath + 'js/fuse.min.js';
15-
const manJSUrl = relativePath + 'js/main.js';
16-
const dataJSUrl = relativePath + 'data.js';
13+
const fuseJSUrl = relativePath + 'js/fuse.min.js' + `?v=${pkg.version}`;
14+
const manJSUrl = relativePath + 'js/main.js' + `?v=${pkg.version}`;
15+
const dataJSUrl = relativePath + 'data.js' + `?v=${pkg.version}`;
1716
const ICONS_SEARCH_PATH = path.resolve(static_path, 'assets/search.svg');
1817
const svgSearchNode = getSVGNode(ICONS_SEARCH_PATH);
1918
return [

src/utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export async function createHTML(files: IFileDirStat[] = [], opts: Options, num
123123
createHTML(files, opts, num);
124124
}
125125

126-
const pkg = fs.readJSONSync(path.resolve(__filename, '../../../package.json'));
126+
export const pkg = fs.readJSONSync(path.resolve(__filename, '../../../package.json'));
127127

128128
export const helpStr = `
129129
Usage: \x1b[34;1mrefs-cli\x1b[0m [output-dir] [--help|h]

0 commit comments

Comments
 (0)