From 4b3f9bd9a624793b467e9b07afdf58b86cf40d17 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 17 Nov 2023 15:44:36 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20MFM=E3=81=AEunixtime?= =?UTF-8?q?=E3=82=92ISO=E5=BD=A2=E5=BC=8F=E3=81=A7=E9=80=A3=E5=90=88?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/backend/src/core/MfmService.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts index b275d1b142..af602168d4 100644 --- a/packages/backend/src/core/MfmService.ts +++ b/packages/backend/src/core/MfmService.ts @@ -276,9 +276,18 @@ export class MfmService { }, fn: (node) => { - const el = doc.createElement('i'); - appendChildren(node.children, el); - return el; + if (node.props.name === 'unixtime') { + const text = node.children[0]!.type === 'text' ? node.children[0].props.text : ''; + const date = new Date(parseInt(text, 10) * 1000); + const el = doc.createElement('time'); + el.setAttribute('datetime', date.toISOString()); + el.textContent = date.toISOString(); + return el; + } else { + const el = doc.createElement('i'); + appendChildren(node.children, el); + return el; + } }, blockCode: (node) => {