feat: latex in search results
| | |
| | | return template.content.firstChild |
| | | } |
| | | |
| | | function initPopover(baseURL, useContextualBacklinks, renderLatex) { |
| | | function initPopover(baseURL, useContextualBacklinks) { |
| | | const basePath = baseURL.replace(window.location.origin, "") |
| | | fetchData.then(({ content }) => { |
| | | const links = [...document.getElementsByClassName("internal-link")] |
| | |
| | | |
| | | if (el) { |
| | | li.appendChild(el) |
| | | if (renderLatex) { |
| | | if (LATEX_ENABLED) { |
| | | renderMathInElement(el, { |
| | | delimiters: [ |
| | | { left: '$$', right: '$$', display: false }, |
| | |
| | | } |
| | | ) |
| | | .join("\n") |
| | | if (LATEX_ENABLED) { |
| | | renderMathInElement(results, { |
| | | delimiters: [ |
| | | { left: '$$', right: '$$', display: false }, |
| | | { left: '$', right: '$', display: false }, |
| | | ], |
| | | throwOnError: false |
| | | }) |
| | | } |
| | | |
| | | const anchors = [...document.getElementsByClassName("result-card")] |
| | | anchors.forEach((anchor) => { |
| | | anchor.onclick = () => redir(anchor.id, term) |
| | |
| | | }} |
| | | <script> |
| | | const SEARCH_ENABLED = {{.Site.Data.config.search.enableSemanticSearch}} |
| | | const LATEX_ENABLED = {{.Site.Data.config.enableLatex}} |
| | | const PRODUCTION = {{ hugo.IsProduction }} |
| | | const BASE_URL = {{.Site.BaseURL}} |
| | | const fetchData = Promise.all([ |
| | |
| | | {{if $data.enableLinkPreview | default $.Site.Data.config.enableLinkPreview}} |
| | | initPopover( |
| | | {{strings.TrimRight "/" .Site.BaseURL }}, |
| | | {{$data.enableContextualBacklinks | default $.Site.Data.config.enableContextualBacklinks}}, |
| | | {{$data.enableLatex | default $.Site.Data.config.enableLatex}} |
| | | {{$data.enableContextualBacklinks | default $.Site.Data.config.enableContextualBacklinks}} |
| | | ) |
| | | {{end}} |
| | | |