mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added tag autocomplete
This commit is contained in:
parent
1414245a1a
commit
359cfaee7a
18 changed files with 375 additions and 80 deletions
13
src/utils/tag.ts
Normal file
13
src/utils/tag.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
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)
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue