mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 22:23:03 -04:00
new search experience - google
This commit is contained in:
parent
4639dd13df
commit
aa02daa830
1 changed files with 8 additions and 5 deletions
|
@ -11,7 +11,12 @@ function createSearchResultPage(context, result){
|
||||||
switch(result.type){
|
switch(result.type){
|
||||||
case 1: // Search Result Entry
|
case 1: // Search Result Entry
|
||||||
res = page(createEmbed("default", context, {
|
res = page(createEmbed("default", context, {
|
||||||
description: `**${link(result.url, result.title)}**\n${result.content}`,
|
author: {
|
||||||
|
iconUrl: `https://www.google.com/s2/favicons?domain=${encodeURIComponent(result.url)}&sz=256`,
|
||||||
|
name: result.title,
|
||||||
|
url: result.url
|
||||||
|
},
|
||||||
|
description: result.content,
|
||||||
footer: {
|
footer: {
|
||||||
iconUrl: STATICS.google,
|
iconUrl: STATICS.google,
|
||||||
text: `Google • ${context.application.name}`
|
text: `Google • ${context.application.name}`
|
||||||
|
@ -19,7 +24,6 @@ function createSearchResultPage(context, result){
|
||||||
}))
|
}))
|
||||||
|
|
||||||
if(result.thumbnail) res.embeds[0].thumbnail = { url: result.thumbnail };
|
if(result.thumbnail) res.embeds[0].thumbnail = { url: result.thumbnail };
|
||||||
return res;
|
|
||||||
break;
|
break;
|
||||||
case 2: // Knowledge Graph Entry
|
case 2: // Knowledge Graph Entry
|
||||||
let header = result.card.title;
|
let header = result.card.title;
|
||||||
|
@ -39,13 +43,12 @@ function createSearchResultPage(context, result){
|
||||||
if(cnt.endsWith(" ")) cnt = cnt.substr(0,cnt.length - 1)
|
if(cnt.endsWith(" ")) cnt = cnt.substr(0,cnt.length - 1)
|
||||||
res.embeds[0].description += "\n" + cnt + citation(1, result.card.url, "Source")
|
res.embeds[0].description += "\n" + cnt + citation(1, result.card.url, "Source")
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
res = page(createEmbed("error", context, "Unknown GoogleResult Type: " + result.type))
|
res = page(createEmbed("error", context, "Unknown GoogleResult Type: " + result.type))
|
||||||
return res;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue