mirror of
https://github.com/alrayyes/wiki.git
synced 2025-06-06 13:53:16 +00:00
fix: parsing wikilinks that have codeblock anchors, scroll to anchor
This commit is contained in:
parent
fd5c8d17d3
commit
24348b24a9
16 changed files with 99 additions and 80 deletions
quartz/components/scripts
|
@ -1,6 +1,6 @@
|
|||
import { Document } from "flexsearch"
|
||||
import { ContentDetails } from "../../plugins/emitters/contentIndex"
|
||||
import { registerEscapeHandler } from "./handler"
|
||||
import { registerEscapeHandler, relative, removeAllChildren } from "./util"
|
||||
|
||||
interface Item {
|
||||
slug: string,
|
||||
|
@ -9,16 +9,6 @@ interface Item {
|
|||
}
|
||||
let index: Document<Item> | undefined = undefined
|
||||
|
||||
function relative(from: string, to: string) {
|
||||
const pieces = [location.protocol, '//', location.host, location.pathname]
|
||||
const url = pieces.join('').slice(0, -from.length) + to
|
||||
return url
|
||||
}
|
||||
|
||||
function removeAllChildren(node: HTMLElement) {
|
||||
node.innerHTML = ``
|
||||
}
|
||||
|
||||
const contextWindowWords = 30
|
||||
function highlight(searchTerm: string, text: string, trim?: boolean) {
|
||||
const tokenizedTerms = searchTerm.split(/\s+/).filter(t => t !== "")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue