[Glitch] Implements tag suggestions for collections topic field

Port 8bce0b99d4 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
diondiondion authored and Claire committed 2026-03-20 18:15:00 +01:00
1 parent 781491e643
commit 784f0169e2
11 files changed
+323 -215

No files matched your search

@@ -28,6 +28,12 @@ export const HASHTAG_PATTERN_REGEX = buildHashtagPatternRegex();
export const HASHTAG_REGEX = buildHashtagRegex();
export const trimHashFromStart = (input: string) => {
return input.startsWith('#') || input.startsWith('#')
? input.slice(1)
: input;
};
/**
* Formats an input string as a hashtag:
* - Prepends `#` unless present
@@ -41,11 +47,7 @@ export const inputToHashtag = (input: string): string => {
const trailingSpace = /\s+$/.exec(input)?.[0] ?? '';
const trimmedInput = input.trimEnd();
const withoutHash =
trimmedInput.startsWith('#') || trimmedInput.startsWith('#')
? trimmedInput.slice(1)
: trimmedInput;
const withoutHash = trimHashFromStart(trimmedInput);
// Split by space, filter empty strings, and capitalise the start of each word but the first
const words = withoutHash