ripunzel/src/methods/redditPreview.js

27 lines
682 B
JavaScript

'use strict';
const mime = require('mime-types');
async function redditPreview(host, post) {
return {
album: post.preview.length > 1 ? {
id: post.host.id || post.id,
url: post.url,
title: post.title,
datetime: post.datetime,
original: post,
} : null,
items: post.preview.map((image) => ({
id: post.host.id || post.id,
url: image.url,
title: post.title,
datetime: post.datetime,
type: mime.lookup(image.url.split('?')[0]),
preview: true,
original: post,
})),
};
}
module.exports = redditPreview;