Skip to content

Commit 3a431c5

Browse files
author
Juliano Rafael
committed
🐛 Strip out tags on title
1 parent a66391c commit 3a431c5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

getLatestArticles.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const X = Xray({
88
}
99
})
1010

11-
module.exports = async tag => {
11+
const getLatestArticles = async tag => {
1212
const articles = await X(
1313
`https://dev.to/t/${tag}/latest`,
1414
"#substories .single-article",
@@ -25,6 +25,15 @@ module.exports = async tag => {
2525
]
2626
).then(articles => articles.filter(article => article.title))
2727

28+
// clean tags out of title
29+
for (article of articles) {
30+
article.tags.forEach(tag => {
31+
if (article.title.indexOf(tag) > -1) {
32+
article.title = article.title.split(tag)[1].trim()
33+
}
34+
})
35+
}
36+
2837
// get twitter handle
2938
for (article of articles) {
3039
const socialLinks = await X(article.author.link, [
@@ -39,3 +48,5 @@ module.exports = async tag => {
3948

4049
return articles
4150
}
51+
52+
module.exports = getLatestArticles

0 commit comments

Comments
 (0)