mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
fix: missing published date in some wechat articles
* some wechat articles do not have `create_time` in the dom javascript so use the `publish_time` node in the dom content
This commit is contained in:
parent
fe450ffe20
commit
e06f833e21
1 changed files with 10 additions and 5 deletions
|
|
@ -17,11 +17,16 @@ export class WeixinQqHandler extends ContentHandler {
|
|||
if (publishTime) {
|
||||
const dateTimeFormat = 'yyyy-LL-dd HH:mm'
|
||||
// convert the publish time to a string in the format of "2023-01-01 00:00" in GMT+8
|
||||
const publishTimeInGMT8 = DateTime.fromFormat(publishTime, dateTimeFormat)
|
||||
.setZone('Asia/Shanghai')
|
||||
.toFormat(dateTimeFormat)
|
||||
// replace the publish time in the dom
|
||||
dom.querySelector('#publish_time')?.replaceWith(publishTimeInGMT8)
|
||||
const publishTimeISO = DateTime.fromFormat(
|
||||
publishTime,
|
||||
dateTimeFormat
|
||||
).toISO()
|
||||
|
||||
// create a meta node to store the publish time with timezone
|
||||
const metaNode = dom.createElement('meta')
|
||||
metaNode.setAttribute('name', 'date')
|
||||
metaNode.setAttribute('content', publishTimeISO)
|
||||
dom.querySelector('head')?.appendChild(metaNode)
|
||||
}
|
||||
// This replace the class name of the article info to preserve the block
|
||||
dom
|
||||
|
|
|
|||
Loading…
Reference in a new issue