Files
omnivore/packages/api/src/services/highlights.ts
2022-08-05 16:09:26 +08:00

12 lines
416 B
TypeScript

import { diff_match_patch } from 'diff-match-patch'
import { homePageURL } from '../env'
export const getHighlightLocation = (patch: string): number | undefined => {
const dmp = new diff_match_patch()
const patches = dmp.patch_fromText(patch)
return patches[0].start1 || undefined
}
export const getHighlightUrl = (slug: string, highlightId: string): string =>
`${homePageURL()}/me/${slug}#${highlightId}`