Skip to content

Commit

Permalink
Merge pull request #717 from masylum/date-title
Browse files Browse the repository at this point in the history
chore(date): get value from title attribute
  • Loading branch information
Kikobeats authored Jul 3, 2024
2 parents 1f19f59 + 235960d commit a84fff0
Show file tree
Hide file tree
Showing 6 changed files with 3,451 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@
"name": "Laurent Goderre",
"email": "[email protected]"
},
{
"name": "Pau Ramon Revilla",
"email": "[email protected]"
},
{
"name": "Omar Diab",
"email": "[email protected]"
Expand Down
2 changes: 2 additions & 0 deletions packages/metascraper-date/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const dateRules = () => {
return [
toDate($ => $('meta[name="date" i]').attr('content')),
toDate($ => $('[itemprop*="date" i]').attr('content')),
toDate($ => $('[itemprop*="date" i]').attr('title')),
toDate($ => $('time[itemprop*="date" i]').attr('datetime')),
toDate($ => $('time[datetime]').attr('datetime')),
toDate($ => $filter($, $('[class*="byline" i]'))),
Expand All @@ -23,6 +24,7 @@ const datePublishedRules = () => {
toDate($jsonld('dateCreated')),
toDate($ => $('meta[property*="published_time" i]').attr('content')),
toDate($ => $('[itemprop="datepublished" i]').attr('content')),
toDate($ => $('[itemprop="datepublished" i]').attr('title')),
toDate($ => $filter($, $('[class*="publish" i]')))
]
}
Expand Down
30 changes: 30 additions & 0 deletions packages/metascraper/test/integration/blogger/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

const { readFile } = require('fs/promises')
const { resolve } = require('path')
const test = require('ava')

const metascraper = require('../../..')([
require('metascraper-author')(),
require('metascraper-date')(),
require('metascraper-description')(),
require('metascraper-audio')(),
require('metascraper-video')(),
require('metascraper-image')(),
require('metascraper-lang')(),
require('metascraper-logo')(),
require('metascraper-logo-favicon')(),
require('metascraper-manifest')(),
require('metascraper-publisher')(),
require('metascraper-title')(),
require('metascraper-url')(),
require('metascraper-readability')()
])

const url = 'https://blog.gardeviance.org/2024/02/a-good-enough-map.html'

test('blogger', async t => {
const html = await readFile(resolve(__dirname, 'input.html'))
const metadata = await metascraper({ html, url })
t.snapshot(metadata)
})
Loading

0 comments on commit a84fff0

Please sign in to comment.