refactor: optional lang and title for engines response
This commit is contained in:
parent
7d0d5f1888
commit
945d237fd6
@ -76,8 +76,6 @@ export default async function google(
|
|||||||
return {
|
return {
|
||||||
content: `${searchForm}${content.join("")}${navigation}`,
|
content: `${searchForm}${content.join("")}${navigation}`,
|
||||||
textContent: textContent.join("\n"),
|
textContent: textContent.join("\n"),
|
||||||
title: window.document.title,
|
|
||||||
lang: window.document.documentElement.lang,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
export interface IHandlerOutput {
|
export interface IHandlerOutput {
|
||||||
content: string;
|
content: string;
|
||||||
textContent: string;
|
textContent: string;
|
||||||
title: string;
|
title?: string;
|
||||||
lang: string;
|
lang?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handlerSchema = {
|
export const handlerSchema = {
|
||||||
|
@ -53,9 +53,12 @@ export default async function handlePage(
|
|||||||
return engines[engine](window);
|
return engines[engine](window);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let match of fallback) {
|
const title = window.document.title;
|
||||||
|
const lang = window.document.documentElement.lang;
|
||||||
|
|
||||||
|
for (const match of fallback) {
|
||||||
if (micromatch.isMatch(urlObj.hostname, match.pattern)) {
|
if (micromatch.isMatch(urlObj.hostname, match.pattern)) {
|
||||||
return match.engine(window);
|
return { title, lang, ...match.engine(window) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user