mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
13 lines
457 B
TypeScript
13 lines
457 B
TypeScript
import { ITag } from '~/redux/types';
|
|
|
|
export const separateTags = (tags: Partial<ITag>[]): Partial<ITag>[][] =>
|
|
(tags || []).reduce(
|
|
(obj, tag) =>
|
|
tag.title.substr(0, 1) === '/' ? [[...obj[0], tag], obj[1]] : [obj[0], [...obj[1], tag]],
|
|
[[], []]
|
|
);
|
|
|
|
export const separateTagOptions = (options: string[]): string[][] =>
|
|
separateTags(options.map((title): Partial<ITag> => ({ title }))).map(item =>
|
|
item.map(({ title }) => title)
|
|
);
|