add cache for fetch post functions

This commit is contained in:
DefectingCat
2023-11-10 14:58:11 +08:00
parent f19c215386
commit 2341e7a3f9
2 changed files with 6 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import { cache } from 'react';
import * as THREE from 'three';
export const sortByDate = (
@ -47,7 +48,7 @@ export type SingleToc = {
* @param source
* @returns
*/
export const generateToc = (source: string) => {
export const generateToc = cache((source: string) => {
const regex = /^#{2,3}(?!#)(.*)/gm;
let lastH2: SingleToc | null = null;
@ -86,7 +87,7 @@ export const generateToc = (source: string) => {
});
return toc;
};
});
/**
* Get mouse or touch position on screen.