Always include url, title and site_name.
This commit is contained in:
parent
030625afa8
commit
e0fa91d049
1 changed files with 6 additions and 6 deletions
12
uiharu.ts
12
uiharu.ts
|
@ -346,7 +346,11 @@ const extractMetadata = async (url: string, urlInfo: URL) => {
|
|||
info[prop] = value;
|
||||
};
|
||||
|
||||
if(contentTypeRaw)
|
||||
info.url = url;
|
||||
info.title = decodeURIComponent(basename(urlInfo.pathname));
|
||||
info.site_name = urlInfo.host;
|
||||
|
||||
if(contentType[0])
|
||||
info.media_type = contentType[0];
|
||||
|
||||
if(['text/html', 'application/xhtml+xml'].includes(contentType[0])) {
|
||||
|
@ -356,7 +360,7 @@ const extractMetadata = async (url: string, urlInfo: URL) => {
|
|||
const ogData = extractOpenGraphData(html);
|
||||
const twitterData = extractTwitterData(html);
|
||||
|
||||
addInfoOrDont('url', ogData.url ?? metaData.canonical_url ?? url);
|
||||
addInfoOrDont('url', ogData.url ?? metaData.canonical_url);
|
||||
addInfoOrDont('title', ogData.title ?? twitterData.title ?? metaData.title);
|
||||
addInfoOrDont('site_name', ogData.site_name);
|
||||
addInfoOrDont('description', ogData.description ?? twitterData.description ?? metaData.description);
|
||||
|
@ -426,10 +430,6 @@ const extractMetadata = async (url: string, urlInfo: URL) => {
|
|||
info.oembed = oEmbedData;
|
||||
}
|
||||
} else {
|
||||
info.url = url;
|
||||
info.title = decodeURIComponent(basename(urlInfo.pathname));
|
||||
info.site_name = urlInfo.host;
|
||||
|
||||
if(contentType[0].startsWith('image/')) {
|
||||
//
|
||||
} else if(contentType[0].startsWith('video/')) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue