File tree 1 file changed +7
-19
lines changed
packages/metascraper-publisher
1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ const wrap = rule => ({ htmlDom }) => {
18
18
return isString ( value ) && condenseWhitespace ( value )
19
19
}
20
20
21
+ const getFromTitle = ( text , regex ) => {
22
+ const matches = regex . exec ( text )
23
+ return matches ? matches [ 1 ] : false
24
+ }
25
+
21
26
/**
22
27
* Rules.
23
28
*/
@@ -39,24 +44,7 @@ module.exports = () => ({
39
44
wrap ( $ => $ ( '[class*="brand"]' ) . text ( ) ) ,
40
45
wrap ( $ => $ ( '[class*="logo"] a img[alt]' ) . attr ( 'alt' ) ) ,
41
46
wrap ( $ => $ ( '[class*="logo"] img[alt]' ) . attr ( 'alt' ) ) ,
42
- wrap ( $ => {
43
- const title = $ ( 'title' )
44
- . text ( )
45
- . trim ( )
46
- const matches = REGEX_TITLE . exec ( title )
47
- if ( ! matches ) return
48
- return matches [ 1 ]
49
- } ) ,
50
- wrap ( $ =>
51
- $ ( '[itemtype="http://schema.org/Blog"] [itemprop="name"]' ) . attr ( 'content' )
52
- ) ,
53
- wrap ( $ => {
54
- const desc = $ ( 'link[rel="alternate"][type="application/atom+xml"]' ) . attr (
55
- 'title'
56
- )
57
- const matches = REGEX_RSS . exec ( desc )
58
- if ( ! matches ) return
59
- return matches [ 1 ]
60
- } )
47
+ wrap ( $ => getFromTitle ( $ ( 'title' ) . text ( ) , REGEX_TITLE ) ) ,
48
+ wrap ( $ => getFromTitle ( $ ( 'link[type*="xml"]' ) . attr ( 'title' ) , REGEX_RSS ) )
61
49
]
62
50
} )
You can’t perform that action at this time.
0 commit comments