diff --git a/src/components/Views/AllAuthors.tsx b/src/components/Views/AllAuthors.tsx index 487ee161..be42b8ff 100644 --- a/src/components/Views/AllAuthors.tsx +++ b/src/components/Views/AllAuthors.tsx @@ -8,6 +8,7 @@ import { useRouter } from '../../stores/router' import styles from '../../styles/AllTopics.module.scss' import { clsx } from 'clsx' import { useSession } from '../../context/session' +import { locale } from '../../stores/ui' type AllAuthorsPageSearchParams = { by: '' | 'name' | 'shouts' | 'rating' @@ -35,18 +36,10 @@ export const AllAuthorsView = (props: Props) => { const byLetter = createMemo<{ [letter: string]: Author[] }>(() => { return sortedAuthors().reduce((acc, author) => { - if (!author.name) { - // name === null for new users - return acc - } - - const letter = author.name[0].toUpperCase() - if (!acc[letter]) { - acc[letter] = [] - } - + let letter = author.name.trim().split(' ').pop().at(0).toUpperCase() + if (!/[а-яА-Я]/i.test(letter) && locale() == 'ru') letter = '#' + if (!acc[letter]) acc[letter] = [] acc[letter].push(author) - return acc }, {} as { [letter: string]: Author[] }) }) diff --git a/src/components/Views/AllTopics.tsx b/src/components/Views/AllTopics.tsx index 57e8b6ca..f015d772 100644 --- a/src/components/Views/AllTopics.tsx +++ b/src/components/Views/AllTopics.tsx @@ -8,6 +8,7 @@ import { TopicCard } from '../Topic/Card' import styles from '../../styles/AllTopics.module.scss' import { clsx } from 'clsx' import { useSession } from '../../context/session' +import { locale } from '../../stores/ui' type AllTopicsPageSearchParams = { by: 'shouts' | 'authors' | 'title' | '' @@ -37,13 +38,10 @@ export const AllTopicsView = (props: AllTopicsViewProps) => { const byLetter = createMemo<{ [letter: string]: Topic[] }>(() => { return sortedTopics().reduce((acc, topic) => { - const letter = topic.title[0].toUpperCase() - if (!acc[letter]) { - acc[letter] = [] - } - + let letter = topic.title[0].toUpperCase() + if (!/[а-яА-Я]/i.test(letter) && locale() == 'ru') letter = '#' + if (!acc[letter]) acc[letter] = [] acc[letter].push(topic) - return acc }, {} as { [letter: string]: Topic[] }) })