Plugin markdown update (#211)

This commit is contained in:
Simon Lecoq
2021-04-07 14:13:56 +02:00
committed by GitHub
parent f93da199d6
commit a98530dd6b
10 changed files with 87 additions and 30 deletions

View File

@@ -12,16 +12,19 @@
//Retrieve posts
console.debug(`metrics/compute/${login}/plugins > posts > processing with source ${source}`)
let posts = null
let link = null
switch (source) {
//Dev.to
case "dev.to":{
console.debug(`metrics/compute/${login}/plugins > posts > querying api`)
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${user}&state=fresh`)).data.map(({title, description, published_at:date, cover_image:image}) => ({title, description, date, image}))
posts = (await imports.axios.get(`https://dev.to/api/articles?username=${user}&state=fresh`)).data.map(({title, description, published_at:date, cover_image:image, url:link}) => ({title, description, date, image, link}))
link = `https://dev.to/${user}`
break
}
//Hashnode
case "hashnode":{
posts = (await imports.axios.post("https://api.hashnode.com", {query:queries.posts.hashnode({user})}, {headers:{"Content-type":"application/json"}})).data.data.user.publication.posts.map(({title, brief:description, dateAdded:date, coverImage:image}) => ({title, description, date, image}))
posts = (await imports.axios.post("https://api.hashnode.com", {query:queries.posts.hashnode({user})}, {headers:{"Content-type":"application/json"}})).data.data.user.publication.posts.map(({title, brief:description, dateAdded:date, coverImage:image, slug}) => ({title, description, date, image, link:`https://hashnode.com/post/${slug}`}))
link = `https://hashnode.com/@${user}`
break
}
//Unsupported
@@ -42,7 +45,7 @@
posts = await Promise.all(posts.map(async({image, ...post}) => ({image:await imports.imgb64(image, {width:144, height:-1}), ...post})))
}
//Results
return {source, descriptions, covers, list:posts}
return {source, link, descriptions, covers, list:posts}
}
//Unhandled error