fix: parsing wikilinks that have codeblock anchors, scroll to anchor
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
import { ContentDetails } from "../../plugins/emitters/contentIndex"
 | 
			
		||||
import * as d3 from 'd3'
 | 
			
		||||
import { registerEscapeHandler } from "./handler"
 | 
			
		||||
import { registerEscapeHandler, relative, removeAllChildren } from "./util"
 | 
			
		||||
 | 
			
		||||
type NodeData = {
 | 
			
		||||
  id: string,
 | 
			
		||||
@@ -13,18 +13,6 @@ type LinkData = {
 | 
			
		||||
  target: string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
  while (node.firstChild) {
 | 
			
		||||
    node.removeChild(node.firstChild)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function renderGraph(container: string, slug: string) {
 | 
			
		||||
  const graph = document.getElementById(container)
 | 
			
		||||
  if (!graph) return
 | 
			
		||||
@@ -117,7 +105,6 @@ async function renderGraph(container: string, slug: string) {
 | 
			
		||||
 | 
			
		||||
  // calculate radius
 | 
			
		||||
  const color = (d: NodeData) => {
 | 
			
		||||
    // TODO: does this handle the index page
 | 
			
		||||
    const isCurrent = d.id === slug
 | 
			
		||||
    return isCurrent ? "var(--secondary)" : "var(--gray)"
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user