|
@@ -42,8 +42,18 @@ define(['base', 'directives/mathjax', 'services/algolia-search'], function(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const buildHitViewModel = function(hit) {
|
|
const buildHitViewModel = function(hit) {
|
|
|
- const page_underscored = hit.pageName.replace(/\s/g, '_')
|
|
|
|
|
- const section_underscored = hit.sectionName.replace(/\s/g, '_')
|
|
|
|
|
|
|
+ const pagePath = hit.kb ? 'how-to/' : 'latex/'
|
|
|
|
|
+ const pageSlug = hit.pageName.replace(/\s/g, '_').replace(/\?/g, '%3F')
|
|
|
|
|
+ let section_underscored = ''
|
|
|
|
|
+ if (hit.sectionName && hit.sectionName !== '') {
|
|
|
|
|
+ section_underscored = '#' + hit.sectionName.replace(/\s/g, '_')
|
|
|
|
|
+ }
|
|
|
|
|
+ const section = hit._highlightResult.sectionName
|
|
|
|
|
+ let pageName = hit._highlightResult.pageName.value
|
|
|
|
|
+ if (section && section.value && section !== '') {
|
|
|
|
|
+ pageName += ' - ' + section.value
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let content = hit._highlightResult.content.value
|
|
let content = hit._highlightResult.content.value
|
|
|
// Replace many new lines
|
|
// Replace many new lines
|
|
|
content = content.replace(/\n\n+/g, '\n\n')
|
|
content = content.replace(/\n\n+/g, '\n\n')
|
|
@@ -60,11 +70,8 @@ define(['base', 'directives/mathjax', 'services/algolia-search'], function(
|
|
|
}
|
|
}
|
|
|
content = matching_lines.join('\n...\n')
|
|
content = matching_lines.join('\n...\n')
|
|
|
const result = {
|
|
const result = {
|
|
|
- name:
|
|
|
|
|
- hit._highlightResult.pageName.value +
|
|
|
|
|
- ' - ' +
|
|
|
|
|
- hit._highlightResult.sectionName.value,
|
|
|
|
|
- url: `/learn/${page_underscored}#${section_underscored}`,
|
|
|
|
|
|
|
+ name: pageName,
|
|
|
|
|
+ url: `/learn/${pagePath}${pageSlug}${section_underscored}`,
|
|
|
content
|
|
content
|
|
|
}
|
|
}
|
|
|
return result
|
|
return result
|