Skip to content

Commit

Permalink
feat: discord timestamp parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzDerock committed Sep 29, 2022
1 parent 33cb64d commit 7c0a5a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"typescript": "^4.8.4"
},
"dependencies": {
"@derockdev/discord-components-core": "^3.4.4",
"@derockdev/discord-components-react": "^3.4.2",
"@derockdev/discord-components-core": "^3.5.0",
"@derockdev/discord-components-react": "^3.5.0",
"discord-markdown-parser": "~1.1.0",
"html-minifier": "^4.0.0",
"react": "^18.2.0",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/generator/renderers/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DiscordMention,
DiscordQuote,
DiscordSpoiler,
DiscordTime,
DiscordUnderlined,
} from '@derockdev/discord-components-react';
import parse, { type RuleTypesExtended } from 'discord-markdown-parser';
Expand Down Expand Up @@ -173,6 +174,9 @@ export async function renderASTNode(node: SingleASTNode, context: RenderContentC
/>
);

case 'timestamp':
return <DiscordTime timestamp={parseInt(node.timestamp) * 1000} format={node.format} />;

default: {
console.log(`Unknown node type: ${type}`, node);
return typeof node.content === 'string' ? node.content : await renderNodes(node.content, context);
Expand Down

0 comments on commit 7c0a5a3

Please sign in to comment.