parent
14e59690bc
commit
879902fd75
|
@ -76,7 +76,7 @@ export const FullArticle = (props: Props) => {
|
||||||
const main_topic_slug = props.article.topics.length > 0 ? props.article.main_topic : null
|
const main_topic_slug = props.article.topics.length > 0 ? props.article.main_topic : null
|
||||||
const mt = props.article.topics.find((tpc: Topic) => tpc.slug === main_topic_slug)
|
const mt = props.article.topics.find((tpc: Topic) => tpc.slug === main_topic_slug)
|
||||||
if (mt) {
|
if (mt) {
|
||||||
mt.title = lang() === 'en' ? capitalize(mt.slug.replace('-', ' ')) : mt.title
|
mt.title = lang() === 'en' ? capitalize(mt.slug.replace(/-/, ' ')) : mt.title
|
||||||
return mt
|
return mt
|
||||||
} else {
|
} else {
|
||||||
return props.article.topics[0]
|
return props.article.topics[0]
|
||||||
|
|
|
@ -89,7 +89,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
const mainTopicSlug = props.article.main_topic || ''
|
const mainTopicSlug = props.article.main_topic || ''
|
||||||
const mainTopic = props.article.topics?.find((tpc: Topic) => tpc.slug === mainTopicSlug)
|
const mainTopic = props.article.topics?.find((tpc: Topic) => tpc.slug === mainTopicSlug)
|
||||||
const mainTopicTitle =
|
const mainTopicTitle =
|
||||||
mainTopicSlug && lang() === 'en' ? mainTopicSlug.replace('-', ' ') : mainTopic?.title || ''
|
mainTopicSlug && lang() === 'en' ? mainTopicSlug.replace(/-/, ' ') : mainTopic?.title || ''
|
||||||
|
|
||||||
const formattedDate = createMemo<string>(() => {
|
const formattedDate = createMemo<string>(() => {
|
||||||
let r = ''
|
let r = ''
|
||||||
|
|
|
@ -17,6 +17,7 @@ import { AuthorBadge } from '../Author/AuthorBadge'
|
||||||
import styles from './AllAuthors.module.scss'
|
import styles from './AllAuthors.module.scss'
|
||||||
import { isCyrillic } from '../../utils/cyrillic'
|
import { isCyrillic } from '../../utils/cyrillic'
|
||||||
import { capitalize } from '../../utils/capitalize'
|
import { capitalize } from '../../utils/capitalize'
|
||||||
|
import { translit } from '../../utils/ru2en'
|
||||||
|
|
||||||
type AllAuthorsPageSearchParams = {
|
type AllAuthorsPageSearchParams = {
|
||||||
by: '' | 'name' | 'shouts' | 'followers'
|
by: '' | 'name' | 'shouts' | 'followers'
|
||||||
|
@ -78,7 +79,7 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
}[searchParams().by]()
|
}[searchParams().by]()
|
||||||
const translate = (author: Author) =>
|
const translate = (author: Author) =>
|
||||||
lang() === 'en' && isCyrillic(author.name)
|
lang() === 'en' && isCyrillic(author.name)
|
||||||
? capitalize(author.slug.replace(/-/, ' '), true)
|
? capitalize(translit(author.name.replace(/ё/, 'e').replace(/ь/, '')).replace(/-/, ' '), true)
|
||||||
: author.name
|
: author.name
|
||||||
const byLetter = createMemo<{ [letter: string]: Author[] }>(() => {
|
const byLetter = createMemo<{ [letter: string]: Author[] }>(() => {
|
||||||
return sortedAuthors().reduce(
|
return sortedAuthors().reduce(
|
||||||
|
@ -86,6 +87,8 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
let letter = ''
|
let letter = ''
|
||||||
if (!letter && author && author.name) {
|
if (!letter && author && author.name) {
|
||||||
const name = translate(author)
|
const name = translate(author)
|
||||||
|
.replace(/[^A-zА-я0-9]/, ' ')
|
||||||
|
.trim()
|
||||||
const nameParts = name.trim().split(' ')
|
const nameParts = name.trim().split(' ')
|
||||||
const found = nameParts.filter(Boolean).pop()
|
const found = nameParts.filter(Boolean).pop()
|
||||||
if (found && found.length > 0) {
|
if (found && found.length > 0) {
|
||||||
|
@ -96,8 +99,12 @@ export const AllAuthorsView = (props: Props) => {
|
||||||
if (/[^A-z]/.test(letter) && lang() === 'en') letter = '@'
|
if (/[^A-z]/.test(letter) && lang() === 'en') letter = '@'
|
||||||
|
|
||||||
if (!acc[letter]) acc[letter] = []
|
if (!acc[letter]) acc[letter] = []
|
||||||
|
author.name = translate(author)
|
||||||
acc[letter].push(author)
|
acc[letter].push(author)
|
||||||
|
|
||||||
|
// Sort authors within each letter group alphabetically by name
|
||||||
|
acc[letter].sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
|
||||||
return acc
|
return acc
|
||||||
},
|
},
|
||||||
{} as { [letter: string]: Author[] },
|
{} as { [letter: string]: Author[] },
|
||||||
|
|
Loading…
Reference in New Issue
Block a user