Merge pull request #45 from TxtDot/artegoser
refactor: optional lang and title for engines response
This commit is contained in:
commit
da67666a6c
@ -76,8 +76,6 @@ export default async function google(
|
||||
return {
|
||||
content: `${searchForm}${content.join("")}${navigation}`,
|
||||
textContent: textContent.join("\n"),
|
||||
title: window.document.title,
|
||||
lang: window.document.documentElement.lang,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
export interface IHandlerOutput {
|
||||
content: string;
|
||||
textContent: string;
|
||||
title: string;
|
||||
lang: string;
|
||||
title?: string;
|
||||
lang?: string;
|
||||
}
|
||||
|
||||
export const handlerSchema = {
|
||||
|
@ -53,9 +53,12 @@ export default async function handlePage(
|
||||
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)) {
|
||||
return match.engine(window);
|
||||
return { title, lang, ...match.engine(window) };
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user