summaryrefslogtreecommitdiff
path: root/packages/backend/src/misc/extract-mentions.ts
blob: 272eb92192a45a5f0cbaf0eb28ba44e36458fc2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/*
 * SPDX-FileCopyrightText: syuilo and other misskey contributors
 * SPDX-License-Identifier: AGPL-3.0-only
 */

// test is located in test/extract-mentions

import * as mfm from 'mfm-js';

export function extractMentions(nodes: mfm.MfmNode[]): mfm.MfmMention['props'][] {
	// TODO: 重複を削除
	const mentionNodes = mfm.extract(nodes, (node) => node.type === 'mention') as mfm.MfmMention[];
	const mentions = mentionNodes.map(x => x.props);

	return mentions;
}