@-patch
Some checks failed
deploy / test (push) Failing after 14s
deploy / Update templates on Mailgun (push) Has been skipped

This commit is contained in:
Untone 2024-07-16 02:11:01 +03:00
parent 19bae3b2dd
commit 82904bd1da
12 changed files with 79 additions and 79 deletions

View File

@ -354,7 +354,7 @@ export const FullArticle = (props: Props) => {
{(a: Maybe<Author>, index: () => number) => (
<>
<Show when={index() > 0}>, </Show>
<A href={`/author/${a?.slug}`}>{a && getAuthorName(a)}</A>
<A href={`/@${a?.slug}`}>{a && getAuthorName(a)}</A>
</>
)}
</For>

View File

@ -95,7 +95,7 @@ export const AuthorBadge = (props: Props) => {
<ConditionalWrapper
condition={!props.inviteView}
wrapper={(children) => (
<a href={`/author/${props.author.slug}`} class={styles.info}>
<a href={`/@${props.author.slug}`} class={styles.info}>
{children}
</a>
)}

View File

@ -262,7 +262,7 @@ export const AuthorCard = (props: Props) => {
description={props.author.bio || ''}
imageUrl={props.author.pic || ''}
shareUrl={getShareUrl({
pathname: `/author/${props.author.slug}`
pathname: `/@${props.author.slug}`
})}
trigger={<Button variant="secondary" value={t('Share')} />}
/>

View File

@ -30,7 +30,7 @@ export const AuthorLink = (props: Props) => {
[styles.authorLinkFloorImportant]: props.isFloorImportant
})}
>
<a class={styles.link} href={`/author/${props.author.slug}`}>
<a class={styles.link} href={`/@${props.author.slug}`}>
<Userpic size={props.size ?? 'M'} name={name() || ''} userpic={props.author.pic || ''} />
<div class={styles.name}>{name()}</div>
</a>

View File

@ -55,7 +55,7 @@ export const Userpic = (props: Props) => {
<Show when={!props.loading} fallback={<Loading />}>
<ConditionalWrapper
condition={Boolean(props.hasLink)}
wrapper={(children) => <a href={`/author/${props.slug}`}>{children}</a>}
wrapper={(children) => <a href={`/@${props.slug}`}>{children}</a>}
>
<Show keyed={true} when={props.userpic} fallback={<div class={styles.letters}>{letters()}</div>}>
<Image src={props.userpic} width={avatarSize()} height={avatarSize()} alt={props.name} />

View File

@ -96,7 +96,7 @@ export const Sidebar = () => {
<For each={follows.authors}>
{(a: Author) => (
<li>
<a href={`/author/${a.slug}`} classList={{ [styles.unread]: checkAuthorIsSeen(a.slug) }}>
<a href={`/@${a.slug}`} classList={{ [styles.unread]: checkAuthorIsSeen(a.slug) }}>
<div class={styles.sidebarItemName}>
<Userpic name={a.name || ''} userpic={a.pic || ''} size="XS" class={styles.userpic} />
<div class={styles.sidebarItemNameLabel}>{a.name}</div>

View File

@ -20,7 +20,7 @@ export const ProfilePopup = (props: ProfilePopupProps) => {
<Popup {...props} horizontalAnchor="right" popupCssClass={styles.profilePopup}>
<ul class="nodash">
<li>
<A class={styles.action} href={`/author/${author()?.slug || 'anonymous'}`}>
<A class={styles.action} href={`/@${author()?.slug || 'anonymous'}`}>
<Icon name="profile" class={styles.icon} />
{t('Profile')}
</A>
@ -32,7 +32,7 @@ export const ProfilePopup = (props: ProfilePopupProps) => {
</A>
</li>
<li>
<A class={styles.action} href={`/author/${author()?.slug}?m=following`}>
<A class={styles.action} href={`/@${author()?.slug}?m=following`}>
<Icon name="feed-all" class={styles.icon} />
{t('Subscriptions')}
</A>

View File

@ -77,7 +77,7 @@ export const NotificationGroup = (props: NotificationGroupProps) => {
{getTitle(n.shout?.title || '')}
</A>{' '}
{t('from')}{' '}
<A href={`/author/${n.authors?.[0]?.slug || ''}`} onClick={handleLinkClick}>
<A href={`/@${n.authors?.[0]?.slug || ''}`} onClick={handleLinkClick}>
{n.authors?.[0]?.name || ''}
</A>{' '}
</div>

View File

@ -205,7 +205,7 @@ export const AllAuthors = (props: Props) => {
{(author) => (
<div class={clsx(styles.topic, 'topic col-sm-12 col-md-8')}>
<div class="topic-title">
<a href={`/author/${author.slug}`}>{translateAuthor(author, lang())}</a>
<a href={`/@${author.slug}`}>{translateAuthor(author, lang())}</a>
<Show when={author.stat?.shouts || 0}>
<span class={styles.articlesCounter}>{author.stat?.shouts || 0}</span>
</Show>

View File

@ -144,9 +144,10 @@ export const AuthorView = (props: AuthorViewProps) => {
let bioContainerRef: HTMLDivElement
let bioWrapperRef: HTMLDivElement
const checkBioHeight = () => {
console.debug('[AuthorView] mounted, checking bio height...')
if (bioContainerRef) {
setShowExpandBioControl(bioContainerRef.offsetHeight > bioWrapperRef.offsetHeight)
const showExpand = bioContainerRef.offsetHeight > bioWrapperRef.offsetHeight
setShowExpandBioControl(showExpand)
console.debug('[AuthorView] mounted, show expand bio container:', showExpand)
}
}
@ -173,19 +174,19 @@ export const AuthorView = (props: AuthorViewProps) => {
<div class="col-md-16">
<ul class="view-switcher">
<li classList={{ 'view-switcher__item--selected': !props.selectedTab }}>
<A href={`/author/${props.authorSlug}`}>{t('Publications')}</A>
<A href={`/@${props.authorSlug}`}>{t('Publications')}</A>
<Show when={author()?.stat}>
<span class="view-switcher__counter">{author()?.stat?.shouts || 0}</span>
</Show>
</li>
<li classList={{ 'view-switcher__item--selected': props.selectedTab === 'comment' }}>
<A href={`/author/${props.authorSlug}/comments`}>{t('Comments')}</A>
<A href={`/@${props.authorSlug}/comments`}>{t('Comments')}</A>
<Show when={author()?.stat}>
<span class="view-switcher__counter">{author()?.stat?.comments || 0}</span>
</Show>
</li>
<li classList={{ 'view-switcher__item--selected': props.selectedTab === 'about' }}>
<A onClick={() => checkBioHeight()} href={`/author/${props.authorSlug}/about`}>
<A onClick={() => checkBioHeight()} href={`/@${props.authorSlug}/about`}>
{t('About the author')}
</A>
</li>

View File

@ -28,7 +28,7 @@ export const VotersList = (props: Props) => {
userpic={reaction.created_by.pic || ''}
class={styles.userpic}
/>
<a href={`/author/${reaction.created_by.slug}`}>{reaction.created_by.name || ''}</a>
<a href={`/@${reaction.created_by.slug}`}>{reaction.created_by.name || ''}</a>
</div>
{reaction.kind === ReactionKind.Like ? (
<div class={styles.commentRatingPositive}>+1</div>

View File

@ -29,7 +29,40 @@ export const route: RouteDefinition = {
type ArticlePageProps = { article?: Shout; comments?: Reaction[]; votes?: Reaction[]; author?: Author }
export function ArticlePage(props: RouteSectionProps<ArticlePageProps>) {
type SlugPageProps = {
article?: Shout
comments?: Reaction[]
votes?: Reaction[]
author?: Author
topics: Topic[]
}
export default (props: RouteSectionProps<SlugPageProps>) => {
if (props.params.slug.startsWith('@')) {
console.debug('[slug] starts with @, render as author page')
const patchedProps = {
...props,
params: {
...props.params,
slug: props.params.slug.slice(1, props.params.slug.length)
}
} as RouteSectionProps<AuthorPageProps>
return <AuthorPage {...patchedProps} />
}
if (props.params.slug.startsWith('!')) {
console.debug('[slug] starts with !, render as topic page')
const patchedProps = {
...props,
params: {
...props.params,
slug: props.params.slug.slice(1, props.params.slug.length)
}
} as RouteSectionProps<TopicPageProps>
return <TopicPage {...patchedProps} />
}
function ArticlePage(props: RouteSectionProps<ArticlePageProps>) {
const loc = useLocation()
const { t } = useLocalize()
const [scrollToComments, setScrollToComments] = createSignal<boolean>(false)
@ -91,39 +124,5 @@ export function ArticlePage(props: RouteSectionProps<ArticlePageProps>) {
</ErrorBoundary>
)
}
type SlugPageProps = {
article?: Shout
comments?: Reaction[]
votes?: Reaction[]
author?: Author
topics: Topic[]
}
export default (props: RouteSectionProps<SlugPageProps>) => {
if (props.params.slug.startsWith('@')) {
console.debug('[slug] starts with @, render as author page')
const patchedProps = {
...props,
params: {
...props.params,
slug: props.params.slug.slice(1, props.params.slug.length)
}
} as RouteSectionProps<AuthorPageProps>
return <AuthorPage {...patchedProps} />
}
if (props.params.slug.startsWith('!')) {
console.debug('[slug] starts with !, render as topic page')
const patchedProps = {
...props,
params: {
...props.params,
slug: props.params.slug.slice(1, props.params.slug.length)
}
} as RouteSectionProps<TopicPageProps>
return <TopicPage {...patchedProps} />
}
return <ArticlePage {...props} />
}