Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions layouts/partials/search-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,23 @@
}

function sortData(data) {
// Override the natural category for results coming from specific sites
const deriveCategory = (record) => {
const url = (record && record.url) || ''
if (/^https?:\/\/(www\.)?redis\.io\/blog(\/|$|\?|#)/i.test(url)) return 'Blog'
if (/^https?:\/\/(www\.)?redis\.io\/tutorials(\/|$|\?|#)/i.test(url)) return 'Tutorials'
if (/^https?:\/\/support\.redislabs\.com(\/|$|\?|#)/i.test(url)) return 'Support'
return record.hierarchy && record.hierarchy[0]
}
Comment thread
paoloredis marked this conversation as resolved.

// Get a list of unique times
const getCategories = (data) =>
data.reduce((a, c) => {
if (!a.includes(c.hierarchy[0])) {
a.push(c.hierarchy[0])
const cat = deriveCategory(c)
if (!a.includes(cat)) {
a.push(cat)
}

return a
}, [])

Expand All @@ -151,7 +161,7 @@
obj.category = category

data.forEach((record) => {
if (record.hierarchy[0] === category) {
if (deriveCategory(record) === category) {
obj[record.title] = {
path: constructSectionTitle(record),
product: record.hierarchy[2],
Expand Down
Loading