Make document titles better

This commit is contained in:
Lim Chee Aun 2023-10-30 18:04:17 +08:00
parent 5fae5d8cf5
commit 290243df0a
3 changed files with 25 additions and 5 deletions

View file

@ -195,9 +195,26 @@ function AccountStatuses() {
const [featuredTags, setFeaturedTags] = useState([]); const [featuredTags, setFeaturedTags] = useState([]);
useTitle( useTitle(
`${account?.displayName ? account.displayName + ' ' : ''}@${ account?.acct
account?.acct ? account.acct : 'Account posts' ? `${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', '/:instance?/a/:id',
); );
useEffect(() => { useEffect(() => {

View file

@ -42,7 +42,10 @@ function Hashtags({ media: mediaView, columnMode, ...props }) {
}); });
const { authenticated: currentAuthenticated } = api(); const { authenticated: currentAuthenticated } = api();
const hashtagTitle = hashtags.map((t) => `#${t}`).join(' '); 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`); useTitle(title, `/:instance?/t/:hashtag`);
const latestItem = useRef(); const latestItem = useRef();

View file

@ -11,11 +11,11 @@ const LIMIT = 20;
const emptySearchParams = new URLSearchParams(); const emptySearchParams = new URLSearchParams();
function Mentions({ columnMode, ...props }) { function Mentions({ columnMode, ...props }) {
useTitle('Mentions', '/mentions');
const { masto, instance } = api(); const { masto, instance } = api();
const [searchParams] = columnMode ? [emptySearchParams] : useSearchParams(); const [searchParams] = columnMode ? [emptySearchParams] : useSearchParams();
const [stateType, setStateType] = useState(null); const [stateType, setStateType] = useState(null);
const type = props?.type || searchParams.get('type') || stateType; const type = props?.type || searchParams.get('type') || stateType;
useTitle(`Mentions${type === 'private' ? ' (Private)' : ''}`, '/mentions');
const mentionsIterator = useRef(); const mentionsIterator = useRef();
const latestItem = useRef(); const latestItem = useRef();