mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-29 09:27:16 +09:00
Refactor: Move the post logic to each plugins
This commit is contained in:
parent
85e00bf66f
commit
7a28b44d44
@ -106,10 +106,10 @@ export default async (url: URL.Url): Promise<Summary> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: title,
|
title: title || null,
|
||||||
icon: icon,
|
icon: icon || null,
|
||||||
description: description,
|
description: description || null,
|
||||||
thumbnail: image,
|
thumbnail: image || null,
|
||||||
sitename: siteName
|
sitename: siteName || null
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
10
src/index.ts
10
src/index.ts
@ -64,16 +64,6 @@ export default async (url: string, options: Options): Promise<Result> => {
|
|||||||
? await match.summary(_url)
|
? await match.summary(_url)
|
||||||
: await general(_url);
|
: await general(_url);
|
||||||
|
|
||||||
// Replace '' to null
|
|
||||||
Object.keys(summary).forEach(k => {
|
|
||||||
if (summary[k]) {
|
|
||||||
summary[k] = summary[k].trim();
|
|
||||||
if (summary[k] === '') {
|
|
||||||
summary[k] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return Object.assign(summary, {
|
return Object.assign(summary, {
|
||||||
url: actualUrl
|
url: actualUrl
|
||||||
});
|
});
|
||||||
|
@ -34,10 +34,10 @@ export async function summary(url: URL.Url) {
|
|||||||
const thumbnail: string = $('#landingImage').attr('src');
|
const thumbnail: string = $('#landingImage').attr('src');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: title,
|
title: title || null,
|
||||||
icon: 'https://www.amazon.com/favicon.ico',
|
icon: 'https://www.amazon.com/favicon.ico',
|
||||||
description: description,
|
description: description || null,
|
||||||
thumbnail: thumbnail,
|
thumbnail: thumbnail || null,
|
||||||
sitename: 'Amazon'
|
sitename: 'Amazon'
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user