Skip to content

Commit

Permalink
Merge pull request #1105 from prezly/feature/dev-12530-fix-media-gall…
Browse files Browse the repository at this point in the history
…ery-seo-description

[DEV-12530] Feature - Enrich media gallery page title and description
  • Loading branch information
kudlajz authored Feb 27, 2024
2 parents 4d5047f + 44006e1 commit 95a374b
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { translations } from '@prezly/theme-kit-nextjs';
import classNames from 'classnames';

import { FormattedMessage } from '@/adapters/client';
import { FormattedMessage, useLocale } from '@/adapters/client';
import { IconDownload } from '@/icons';

import styles from './DownloadLink.module.scss';
Expand All @@ -11,9 +11,11 @@ interface Props {
}

export function DownloadLink({ className }: Props) {
const locale = useLocale();

return (
<div className={classNames(styles.link, className)}>
<FormattedMessage for={translations.actions.download} />
<FormattedMessage locale={locale} for={translations.actions.download} />
<IconDownload width={16} height={16} className={styles.icon} />
</div>
);
Expand Down
5 changes: 3 additions & 2 deletions components/StoryLinks/StoryShareUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { translations } from '@prezly/theme-kit-nextjs';
import classNames from 'classnames';
import { Fragment, useState } from 'react';

import { FormattedMessage, useIntl } from '@/adapters/client';
import { FormattedMessage, useIntl, useLocale } from '@/adapters/client';
import { Button } from '@/components/Button';
import { IconLink } from '@/icons';

Expand All @@ -19,6 +19,7 @@ interface Props {
const TOOLTIP_HIDE_DELAY = 3000; // 3 seconds

export function StoryShareUrl({ url, buttonClassName }: Props) {
const locale = useLocale();
const [isTooltipShown, setIsTooltipShown] = useState(false);
const { formatMessage } = useIntl();

Expand Down Expand Up @@ -51,7 +52,7 @@ export function StoryShareUrl({ url, buttonClassName }: Props) {
>
<div className={styles.message}>
<IconLink width={16} height={16} className={styles.messageIcon} />
<FormattedMessage for={translations.misc.shareUrlCopied} />
<FormattedMessage locale={locale} for={translations.misc.shareUrlCopied} />
</div>
</Transition>
</div>
Expand Down
5 changes: 3 additions & 2 deletions modules/Contacts/ui/Contacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { translations } from '@prezly/theme-kit-nextjs';
import { UploadcareImage } from '@prezly/uploadcare-image';
import classNames from 'classnames';

import { FormattedMessage } from '@/adapters/client';
import { FormattedMessage, useLocale } from '@/adapters/client';
import { ContactCard } from '@/components/ContactCard';
import { useDevice } from '@/hooks';

Expand All @@ -19,14 +19,15 @@ interface Props {

export function Contacts({ contacts }: Props) {
const device = useDevice();
const locale = useLocale();

const numberOfColumns = getNumberOfColumns(contacts.length);
const isCompactCard = numberOfColumns === 3 && !device.isTablet;

return (
<div className={styles.contacts}>
<h2 className={styles.title}>
<FormattedMessage for={translations.contacts.title} />
<FormattedMessage locale={locale} for={translations.contacts.title} />
</h2>
<div
className={classNames(styles.grid, {
Expand Down
25 changes: 20 additions & 5 deletions modules/CookieConsent/components/CookieConsentBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { NewsroomCompanyInformation } from '@prezly/sdk';
import { translations } from '@prezly/theme-kit-nextjs';
import classNames from 'classnames';

import { FormattedMessage } from '@/adapters/client';
import { FormattedMessage, useLocale } from '@/adapters/client';
import { Button } from '@/components/Button';

import styles from './CookieConsentBar.module.scss';
Expand All @@ -15,6 +15,8 @@ interface Props {
}

export function CookieConsentBar({ children }: Props) {
const locale = useLocale();

return (
<DefaultCookieConsentBar>
{({ onAccept, onReject }) => (
Expand All @@ -23,7 +25,10 @@ export function CookieConsentBar({ children }: Props) {
<div className={styles.wrapper}>
<div className={styles.content}>
<p className={styles.title}>
<FormattedMessage for={translations.cookieConsent.title} />
<FormattedMessage
locale={locale}
for={translations.cookieConsent.title}
/>
</p>
{children ? (
<div
Expand All @@ -33,6 +38,7 @@ export function CookieConsentBar({ children }: Props) {
) : (
<p className={styles.text}>
<FormattedMessage
locale={locale}
for={translations.cookieConsent.description}
/>
</p>
Expand All @@ -44,17 +50,26 @@ export function CookieConsentBar({ children }: Props) {
onClick={onReject}
variation="secondary"
>
<FormattedMessage for={translations.cookieConsent.reject} />
<FormattedMessage
locale={locale}
for={translations.cookieConsent.reject}
/>
</Button>
<Button
className={styles.button}
onClick={onAccept}
variation="primary"
>
<FormattedMessage for={translations.cookieConsent.accept} />
<FormattedMessage
locale={locale}
for={translations.cookieConsent.accept}
/>
</Button>
<p className={styles.notice}>
<FormattedMessage for={translations.cookieConsent.notice} />
<FormattedMessage
locale={locale}
for={translations.cookieConsent.notice}
/>
</p>
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion modules/Header/Categories.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import type { TranslatedCategory } from '@prezly/sdk';
import type { Locale } from '@prezly/theme-kit-nextjs';

import { CategoriesNav } from './ui';

import styles from './ui/Header.module.scss';

interface Props {
categories: TranslatedCategory[];
localeCode: Locale.Code;
}

export async function Categories({ categories }: Props) {
export async function Categories({ categories, localeCode }: Props) {
if (categories.length === 0) {
return null;
}

return (
<CategoriesNav
localeCode={localeCode}
categories={categories}
buttonClassName={styles.navigationButton}
navigationItemClassName={styles.navigationItem}
Expand Down
2 changes: 1 addition & 1 deletion modules/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function Header({ localeCode }: Props) {
displayedLanguages={displayedLanguages.length}
displayedGalleries={newsroom.public_galleries_number}
>
<Categories categories={displayedCategories} />
<Categories categories={displayedCategories} localeCode={localeCode} />
<Languages localeCode={localeCode} />
</ui.Header>
);
Expand Down
7 changes: 6 additions & 1 deletion modules/Header/ui/CategoriesNav/CategoriesNav.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { TranslatedCategory } from '@prezly/sdk';
import type { Locale } from '@prezly/theme-kit-nextjs';
import { translations } from '@prezly/theme-kit-nextjs';
import classNames from 'classnames';

Expand All @@ -12,6 +13,7 @@ import styles from './CategoriesNav.module.scss';

export function CategoriesNav({
categories,
localeCode,
buttonClassName,
navigationItemClassName,
navigationButtonClassName,
Expand Down Expand Up @@ -41,7 +43,9 @@ export function CategoriesNav({
})}
>
<Dropdown
label={<FormattedMessage for={translations.categories.title} />}
label={
<FormattedMessage locale={localeCode} for={translations.categories.title} />
}
buttonClassName={buttonClassName}
withMobileDisplay
>
Expand All @@ -57,6 +61,7 @@ export function CategoriesNav({
export namespace CategoriesNav {
export interface Props {
categories: TranslatedCategory[];
localeCode: Locale.Code;
buttonClassName?: string;
navigationItemClassName?: string;
navigationButtonClassName?: string;
Expand Down
3 changes: 2 additions & 1 deletion modules/Header/ui/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Header({
displayedLanguages,
children /* hasError */,
}: Props) {
const { formatMessage } = useIntl();
const { locale, formatMessage } = useIntl();
const { isMobile } = useDevice();

const [isMenuOpen, setIsMenuOpen] = useState(false);
Expand Down Expand Up @@ -183,6 +183,7 @@ export function Header({
className={styles.navigationButton}
>
<FormattedMessage
locale={locale}
for={translations.mediaGallery.title}
/>
</ButtonLink>
Expand Down
9 changes: 5 additions & 4 deletions modules/Header/ui/SearchWidget/components/CategoriesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { TranslatedCategory } from '@prezly/sdk';
import { translations } from '@prezly/theme-kit-nextjs';
import { useState } from 'react';

import { FormattedMessage } from '@/adapters/client';
import { FormattedMessage, useLocale } from '@/adapters/client';
import { Button } from '@/components/Button';
import { Link } from '@/components/Link';
import { onPlainLeftClick } from '@/utils';
Expand All @@ -18,6 +18,7 @@ interface Props {
}

export function CategoriesList({ categories, onClose }: Props) {
const locale = useLocale();
const [showAllCategories, setShowAllCategories] = useState(false);

const displayedCategories = showAllCategories
Expand All @@ -31,7 +32,7 @@ export function CategoriesList({ categories, onClose }: Props) {
return (
<>
<p className={mainStyles.title}>
<FormattedMessage for={translations.categories.title} />
<FormattedMessage locale={locale} for={translations.categories.title} />
</p>

<ul className={mainStyles.list}>
Expand All @@ -58,9 +59,9 @@ export function CategoriesList({ categories, onClose }: Props) {
className={mainStyles.link}
>
{showAllCategories ? (
<FormattedMessage for={translations.search.viewLess} />
<FormattedMessage locale={locale} for={translations.search.viewLess} />
) : (
<FormattedMessage for={translations.search.viewMore} />
<FormattedMessage locale={locale} for={translations.search.viewMore} />
)}
</Button>
)}
Expand Down
11 changes: 8 additions & 3 deletions modules/Header/ui/SearchWidget/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export const SearchBar = connectSearchBox(({ currentRefinement, refine }: Props)
>
<div className={styles.inputWrapper}>
<FormInput
label={<FormattedMessage for={translations.search.inputLabel} />}
label={
<FormattedMessage
locale={localeCode}
for={translations.search.inputLabel}
/>
}
type="search"
name="query"
value={currentRefinement}
Expand All @@ -34,12 +39,12 @@ export const SearchBar = connectSearchBox(({ currentRefinement, refine }: Props)
/>
{!currentRefinement.length && (
<span className={styles.inputHint}>
<FormattedMessage for={translations.search.inputHint} />
<FormattedMessage locale={localeCode} for={translations.search.inputHint} />
</span>
)}
</div>
<Button type="submit" variation="secondary" className={styles.button}>
<FormattedMessage for={translations.search.action} />
<FormattedMessage locale={localeCode} for={translations.search.action} />
</Button>
</form>
);
Expand Down
9 changes: 6 additions & 3 deletions modules/Header/ui/SearchWidget/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export function SearchResults({ searchResults, query, isSearchPage, onClose }: P
<>
<p className={classNames(styles.title, { [styles.empty]: !totalResults })}>
{totalResults ? (
<FormattedMessage for={translations.search.resultsTitle} />
<FormattedMessage locale={localeCode} for={translations.search.resultsTitle} />
) : (
<FormattedMessage for={translations.search.noResults} />
<FormattedMessage locale={localeCode} for={translations.search.noResults} />
)}
</p>
<Hits hitComponent={Hit} />
Expand All @@ -50,7 +50,10 @@ export function SearchResults({ searchResults, query, isSearchPage, onClose }: P
className={styles.link}
forceRefresh={isSearchPage}
>
<FormattedMessage for={translations.search.showAllResults} />
<FormattedMessage
locale={localeCode}
for={translations.search.showAllResults}
/>
</ButtonLink>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions modules/InfiniteStories/InfiniteStories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export function InfiniteStories({
className={styles.loadMore}
>
{loading ? (
<FormattedMessage for={translations.misc.stateLoading} />
<FormattedMessage locale={locale} for={translations.misc.stateLoading} />
) : (
<FormattedMessage for={translations.actions.loadMore} />
<FormattedMessage locale={locale} for={translations.actions.loadMore} />
)}
</Button>
)}
Expand Down
7 changes: 5 additions & 2 deletions modules/InfiniteStories/StoriesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { translations } from '@prezly/theme-kit-nextjs';
import { useMemo } from 'react';

import { FormattedMessage } from '@/adapters/client';
import { FormattedMessage, useLocale } from '@/adapters/client';
import { HighlightedStoryCard, StoryCard } from '@/components/StoryCards';
import type { ListStory } from 'types';

Expand All @@ -20,6 +20,8 @@ type Props = {
};

export function StoriesList({ newsoomName, stories, isCategoryList = false }: Props) {
const locale = useLocale();

const [highlightedStories, restStories] = useMemo(() => {
if (isCategoryList) {
return [[], stories];
Expand All @@ -40,12 +42,13 @@ export function StoriesList({ newsoomName, stories, isCategoryList = false }: Pr
<Illustration />
<h1 className={styles.noStoriesTitle}>
<FormattedMessage
locale={locale}
for={translations.noStories.title}
values={{ newsroom: newsoomName }}
/>
</h1>
<p className={styles.noStoriesSubtitle}>
<FormattedMessage for={translations.noStories.subtitle} />
<FormattedMessage locale={locale} for={translations.noStories.subtitle} />
</p>
</div>
);
Expand Down
Loading

0 comments on commit 95a374b

Please sign in to comment.