From 290243df0adc2f7dbc25db2bbadef78cc542ec86 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 30 Oct 2023 18:04:17 +0800 Subject: [PATCH] Make document titles better --- src/pages/account-statuses.jsx | 23 ++++++++++++++++++++--- src/pages/hashtag.jsx | 5 ++++- src/pages/mentions.jsx | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/pages/account-statuses.jsx b/src/pages/account-statuses.jsx index a45aedd1..4829375d 100644 --- a/src/pages/account-statuses.jsx +++ b/src/pages/account-statuses.jsx @@ -195,9 +195,26 @@ function AccountStatuses() { const [featuredTags, setFeaturedTags] = useState([]); useTitle( - `${account?.displayName ? account.displayName + ' ' : ''}@${ - account?.acct ? account.acct : 'Account posts' - }`, + account?.acct + ? `${account?.displayName ? account.displayName + ' ' : ''}@${ + account.acct + }${ + !excludeReplies + ? ' (+ Replies)' + : excludeBoosts + ? ' (- Boosts)' + : tagged + ? ` (#${tagged})` + : media + ? ' (Media)' + : month + ? ` (${new Date(month).toLocaleString('default', { + month: 'long', + year: 'numeric', + })})` + : '' + }` + : 'Account posts', '/:instance?/a/:id', ); useEffect(() => { diff --git a/src/pages/hashtag.jsx b/src/pages/hashtag.jsx index ade10c9e..e05a3f85 100644 --- a/src/pages/hashtag.jsx +++ b/src/pages/hashtag.jsx @@ -42,7 +42,10 @@ function Hashtags({ media: mediaView, columnMode, ...props }) { }); const { authenticated: currentAuthenticated } = api(); const hashtagTitle = hashtags.map((t) => `#${t}`).join(' '); - const title = instance ? `${hashtagTitle} on ${instance}` : hashtagTitle; + const hashtagPostTitle = media ? ` (Media only)` : ''; + const title = instance + ? `${hashtagTitle}${hashtagPostTitle} on ${instance}` + : `${hashtagTitle}${hashtagPostTitle}`; useTitle(title, `/:instance?/t/:hashtag`); const latestItem = useRef(); diff --git a/src/pages/mentions.jsx b/src/pages/mentions.jsx index 6403d188..da6e5ae0 100644 --- a/src/pages/mentions.jsx +++ b/src/pages/mentions.jsx @@ -11,11 +11,11 @@ const LIMIT = 20; const emptySearchParams = new URLSearchParams(); function Mentions({ columnMode, ...props }) { - useTitle('Mentions', '/mentions'); const { masto, instance } = api(); const [searchParams] = columnMode ? [emptySearchParams] : useSearchParams(); const [stateType, setStateType] = useState(null); const type = props?.type || searchParams.get('type') || stateType; + useTitle(`Mentions${type === 'private' ? ' (Private)' : ''}`, '/mentions'); const mentionsIterator = useRef(); const latestItem = useRef();