File tree 1 file changed +12
-1
lines changed
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ const X = Xray({
8
8
}
9
9
} )
10
10
11
- module . exports = async tag => {
11
+ const getLatestArticles = async tag => {
12
12
const articles = await X (
13
13
`https://dev.to/t/${ tag } /latest` ,
14
14
"#substories .single-article" ,
@@ -25,6 +25,15 @@ module.exports = async tag => {
25
25
]
26
26
) . then ( articles => articles . filter ( article => article . title ) )
27
27
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
+
28
37
// get twitter handle
29
38
for ( article of articles ) {
30
39
const socialLinks = await X ( article . author . link , [
@@ -39,3 +48,5 @@ module.exports = async tag => {
39
48
40
49
return articles
41
50
}
51
+
52
+ module . exports = getLatestArticles
You can’t perform that action at this time.
0 commit comments