feat: copyable header anchors (fixes #86)
This commit is contained in:
		
							parent
							
								
									ec86cca97b
								
							
						
					
					
						commit
						b8a660e208
					
				
					 2 changed files with 17 additions and 0 deletions
				
			
		| 
						 | 
					@ -12,6 +12,19 @@ h1, h2, h3, h4, h5, h6, ol, ul, thead {
 | 
				
			||||||
  font-weight: revert;
 | 
					  font-weight: revert;
 | 
				
			||||||
  margin: revert;
 | 
					  margin: revert;
 | 
				
			||||||
  padding: revert;
 | 
					  padding: revert;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  &:hover > .hanchor {
 | 
				
			||||||
 | 
					    opacity: 1;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.hanchor {
 | 
				
			||||||
 | 
					  font-family: Inter;
 | 
				
			||||||
 | 
					  margin-left: -1em;
 | 
				
			||||||
 | 
					  opacity: 0.3;
 | 
				
			||||||
 | 
					  transition: opacity 0.3s ease;
 | 
				
			||||||
 | 
					  color: var(--secondary);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
p, ul, text {
 | 
					p, ul, text {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,4 +53,8 @@
 | 
				
			||||||
    {{end}}
 | 
					    {{end}}
 | 
				
			||||||
  {{end}}
 | 
					  {{end}}
 | 
				
			||||||
{{end}}
 | 
					{{end}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					{{/* Add copyable anchors */}}
 | 
				
			||||||
 | 
					{{ $content = $content | replaceRE "(<h[1-9] id=\"([^\"]+)\">)(.+)(</h[1-9]>)" `<a href="#${2}">${1}<span class="hanchor" ariaLabel="Anchor"># </span>${3}${4}</a>` }}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{{ $content | safeHTML }}
 | 
					{{ $content | safeHTML }}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue