2021-04-02 01:36:11 +00:00
|
|
|
import * as mfm from 'mfm-js';
|
|
|
|
import { unique } from '@/prelude/array';
|
|
|
|
|
2021-04-10 08:50:18 +00:00
|
|
|
export function extractHashtags(nodes: mfm.MfmNode[]): string[] {
|
|
|
|
const hashtags = [] as string[];
|
2021-04-02 01:36:11 +00:00
|
|
|
|
2021-04-10 08:50:18 +00:00
|
|
|
mfm.inspect(nodes, (node) => {
|
|
|
|
if (node.type === 'hashtag') {
|
|
|
|
hashtags.push(node.props.hashtag);
|
2021-04-02 01:36:11 +00:00
|
|
|
}
|
2021-04-10 08:50:18 +00:00
|
|
|
});
|
2021-04-02 01:36:11 +00:00
|
|
|
|
2018-12-20 10:41:04 +00:00
|
|
|
return unique(hashtags);
|
|
|
|
}
|