Plugin markdown update (#211)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user