mirror of https://github.com/logos-co/roadmap.git
feat: latex in search results
This commit is contained in:
parent
4cd6f7efdf
commit
ce5df837f5
|
@ -5,7 +5,7 @@ function htmlToElement(html) {
|
||||||
return template.content.firstChild
|
return template.content.firstChild
|
||||||
}
|
}
|
||||||
|
|
||||||
function initPopover(baseURL, useContextualBacklinks, renderLatex) {
|
function initPopover(baseURL, useContextualBacklinks) {
|
||||||
const basePath = baseURL.replace(window.location.origin, "")
|
const basePath = baseURL.replace(window.location.origin, "")
|
||||||
fetchData.then(({ content }) => {
|
fetchData.then(({ content }) => {
|
||||||
const links = [...document.getElementsByClassName("internal-link")]
|
const links = [...document.getElementsByClassName("internal-link")]
|
||||||
|
@ -42,7 +42,7 @@ function initPopover(baseURL, useContextualBacklinks, renderLatex) {
|
||||||
|
|
||||||
if (el) {
|
if (el) {
|
||||||
li.appendChild(el)
|
li.appendChild(el)
|
||||||
if (renderLatex) {
|
if (LATEX_ENABLED) {
|
||||||
renderMathInElement(el, {
|
renderMathInElement(el, {
|
||||||
delimiters: [
|
delimiters: [
|
||||||
{ left: '$$', right: '$$', display: false },
|
{ left: '$$', right: '$$', display: false },
|
||||||
|
|
|
@ -203,6 +203,16 @@ const displayResults = (term, finalResults, extractHighlight = false) => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.join("\n")
|
.join("\n")
|
||||||
|
if (LATEX_ENABLED) {
|
||||||
|
renderMathInElement(results, {
|
||||||
|
delimiters: [
|
||||||
|
{ left: '$$', right: '$$', display: false },
|
||||||
|
{ left: '$', right: '$', display: false },
|
||||||
|
],
|
||||||
|
throwOnError: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const anchors = [...document.getElementsByClassName("result-card")]
|
const anchors = [...document.getElementsByClassName("result-card")]
|
||||||
anchors.forEach((anchor) => {
|
anchors.forEach((anchor) => {
|
||||||
anchor.onclick = () => redir(anchor.id, term)
|
anchor.onclick = () => redir(anchor.id, term)
|
||||||
|
|
|
@ -82,6 +82,7 @@
|
||||||
}}
|
}}
|
||||||
<script>
|
<script>
|
||||||
const SEARCH_ENABLED = {{.Site.Data.config.search.enableSemanticSearch}}
|
const SEARCH_ENABLED = {{.Site.Data.config.search.enableSemanticSearch}}
|
||||||
|
const LATEX_ENABLED = {{.Site.Data.config.enableLatex}}
|
||||||
const PRODUCTION = {{ hugo.IsProduction }}
|
const PRODUCTION = {{ hugo.IsProduction }}
|
||||||
const BASE_URL = {{.Site.BaseURL}}
|
const BASE_URL = {{.Site.BaseURL}}
|
||||||
const fetchData = Promise.all([
|
const fetchData = Promise.all([
|
||||||
|
@ -123,8 +124,7 @@
|
||||||
{{if $data.enableLinkPreview | default $.Site.Data.config.enableLinkPreview}}
|
{{if $data.enableLinkPreview | default $.Site.Data.config.enableLinkPreview}}
|
||||||
initPopover(
|
initPopover(
|
||||||
{{strings.TrimRight "/" .Site.BaseURL }},
|
{{strings.TrimRight "/" .Site.BaseURL }},
|
||||||
{{$data.enableContextualBacklinks | default $.Site.Data.config.enableContextualBacklinks}},
|
{{$data.enableContextualBacklinks | default $.Site.Data.config.enableContextualBacklinks}}
|
||||||
{{$data.enableLatex | default $.Site.Data.config.enableLatex}}
|
|
||||||
)
|
)
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue