mirror of https://github.com/vuejs/vitepress
feat(theme): editLink can accept function (#2058)
parent
90e924a965
commit
192708de67
@ -0,0 +1,14 @@
|
|||||||
|
export function serializeFunctions(value: any): any {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
return value.map(serializeFunctions)
|
||||||
|
} else if (typeof value === 'object' && value !== null) {
|
||||||
|
return Object.keys(value).reduce((acc, key) => {
|
||||||
|
acc[key] = serializeFunctions(value[key])
|
||||||
|
return acc
|
||||||
|
}, {} as any)
|
||||||
|
} else if (typeof value === 'function') {
|
||||||
|
return `_vp-fn_${value.toString()}`
|
||||||
|
} else {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue