diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:25:26 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:25:26 +0100 |
| commit | f49dfba86b9ac745ddc374ee0f02f03d7e81d872 (patch) | |
| tree | ea647377926391e9391759d95f95824515b286ca /src | |
| parent | b2686521cf2ca6bb0b5c5164de72d3d39d5c510e (diff) | |
refactor(widgets): move social media websites from config to widget
I only use this config inside the SocialMedia widget so it makes more
sense to gather them. In addition I can translate the website names if
needed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/Widgets/SocialMedia/SocialMedia.tsx | 41 | ||||
| -rw-r--r-- | src/config/social-media.ts | 22 | ||||
| -rw-r--r-- | src/i18n/en.json | 16 | ||||
| -rw-r--r-- | src/i18n/fr.json | 16 |
4 files changed, 71 insertions, 24 deletions
diff --git a/src/components/Widgets/SocialMedia/SocialMedia.tsx b/src/components/Widgets/SocialMedia/SocialMedia.tsx index e4151fc..f96d10f 100644 --- a/src/components/Widgets/SocialMedia/SocialMedia.tsx +++ b/src/components/Widgets/SocialMedia/SocialMedia.tsx @@ -1,10 +1,10 @@ -import { socialWebsites } from '@config/social-media'; import GithubIcon from '@assets/images/social-media/github.svg'; import GitlabIcon from '@assets/images/social-media/gitlab.svg'; import LinkedInIcon from '@assets/images/social-media/linkedin.svg'; import TwitterIcon from '@assets/images/social-media/twitter.svg'; import styles from './SocialMedia.module.scss'; import { ExpandableWidget } from '@components/WidgetParts'; +import { useIntl } from 'react-intl'; const SocialMedia = ({ title, @@ -19,6 +19,43 @@ const SocialMedia = ({ linkedin?: boolean; twitter?: boolean; }) => { + const intl = useIntl(); + + const websites = [ + { + id: 'github', + name: intl.formatMessage({ + defaultMessage: 'Github', + description: 'SocialMedia: Github', + }), + url: 'https://github.com/ArmandPhilippot', + }, + { + id: 'gitlab', + name: intl.formatMessage({ + defaultMessage: 'Gitlab', + description: 'SocialMedia: Gitlab', + }), + url: 'https://gitlab.com/ArmandPhilippot', + }, + { + id: 'linkedin', + name: intl.formatMessage({ + defaultMessage: 'LinkedIn', + description: 'SocialMedia: LinkedIn', + }), + url: 'https://www.linkedin.com/in/armandphilippot', + }, + { + id: 'twitter', + name: intl.formatMessage({ + defaultMessage: 'Twitter', + description: 'SocialMedia: Twitter', + }), + url: 'https://twitter.com/ArmandPhilippot', + }, + ]; + const getIcon = (id: string) => { switch (id) { case 'github': @@ -49,7 +86,7 @@ const SocialMedia = ({ } }; - const items = socialWebsites.map((website) => { + const items = websites.map((website) => { return shouldDisplayLink(website.id) ? ( <li key={website.id}> <a href={website.url} className={styles.link}> diff --git a/src/config/social-media.ts b/src/config/social-media.ts deleted file mode 100644 index a2bb2ed..0000000 --- a/src/config/social-media.ts +++ /dev/null @@ -1,22 +0,0 @@ -export const socialWebsites = [ - { - id: 'github', - name: 'Github', - url: 'https://github.com/ArmandPhilippot', - }, - { - id: 'gitlab', - name: 'Gitlab', - url: 'https://gitlab.com/ArmandPhilippot', - }, - { - id: 'linkedin', - name: 'LinkedIn', - url: 'https://www.linkedin.com/in/armandphilippot', - }, - { - id: 'twitter', - name: 'Twitter', - url: 'https://twitter.com/ArmandPhilippot', - }, -]; diff --git a/src/i18n/en.json b/src/i18n/en.json index 2faabe0..3fa93ca 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -163,6 +163,10 @@ "defaultMessage": "{brandingName} picture", "description": "Branding: branding name picture." }, + "IPs/Ck": { + "defaultMessage": "Twitter", + "description": "SocialMedia: Twitter" + }, "Igx3qp": { "defaultMessage": "Projects", "description": "Breadcrumb: Projects item" @@ -263,6 +267,10 @@ "defaultMessage": "Blog", "description": "BlogPage: breadcrumb item" }, + "SWjj4l": { + "defaultMessage": "Github", + "description": "SocialMedia: Github" + }, "SWq8a4": { "defaultMessage": "Close {type}", "description": "ButtonToolbar: Close button" @@ -295,6 +303,10 @@ "defaultMessage": "Search results for {query}", "description": "SearchPage: search results text" }, + "VbcHZ4": { + "defaultMessage": "LinkedIn", + "description": "SocialMedia: LinkedIn" + }, "W2G95o": { "defaultMessage": "Comments:", "description": "PostMeta: comment count label" @@ -479,6 +491,10 @@ "defaultMessage": "Others thematics", "description": "ThematicPage: thematics list widget title" }, + "obmlFh": { + "defaultMessage": "Gitlab", + "description": "SocialMedia: Gitlab" + }, "ode0YK": { "defaultMessage": "Dark theme", "description": "Icons: Moon icon (dark theme)" diff --git a/src/i18n/fr.json b/src/i18n/fr.json index 6289433..2ac3ff3 100644 --- a/src/i18n/fr.json +++ b/src/i18n/fr.json @@ -163,6 +163,10 @@ "defaultMessage": "Image de {brandingName}", "description": "Branding: branding name picture." }, + "IPs/Ck": { + "defaultMessage": "Twitter", + "description": "SocialMedia: Twitter" + }, "Igx3qp": { "defaultMessage": "Projets", "description": "Breadcrumb: Projects item" @@ -263,6 +267,10 @@ "defaultMessage": "Blog", "description": "BlogPage: breadcrumb item" }, + "SWjj4l": { + "defaultMessage": "Github", + "description": "SocialMedia: Github" + }, "SWq8a4": { "defaultMessage": "Fermer {type}", "description": "ButtonToolbar: Close button" @@ -295,6 +303,10 @@ "defaultMessage": "Résultats de recherche pour {query}", "description": "SearchPage: search results text" }, + "VbcHZ4": { + "defaultMessage": "LinkedIn", + "description": "SocialMedia: LinkedIn" + }, "W2G95o": { "defaultMessage": "Commentaires :", "description": "PostMeta: comment count label" @@ -479,6 +491,10 @@ "defaultMessage": "Autres thématiques", "description": "ThematicPage: thematics list widget title" }, + "obmlFh": { + "defaultMessage": "Gitlab", + "description": "SocialMedia: Gitlab" + }, "ode0YK": { "defaultMessage": "Thème sombre", "description": "Icons: Moon icon (dark theme)" |
