diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:17:49 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-01-29 23:21:14 +0100 |
| commit | b2686521cf2ca6bb0b5c5164de72d3d39d5c510e (patch) | |
| tree | ba18ca4612460017ec7dae1f0471d0972457681c | |
| parent | 657d11ce72c905832b9b169354352f521f42207a (diff) | |
refactor(widgets): move sharing websites from config to sharing widget
I only use these websites inside the sharing widget so it makes more
sense to gather them. In addition, I can translate the website name if
needed.
| -rw-r--r-- | src/components/Widgets/Sharing/Sharing.tsx | 91 | ||||
| -rw-r--r-- | src/config/sharing.ts | 70 | ||||
| -rw-r--r-- | src/i18n/en.json | 24 | ||||
| -rw-r--r-- | src/i18n/fr.json | 24 |
4 files changed, 136 insertions, 73 deletions
diff --git a/src/components/Widgets/Sharing/Sharing.tsx b/src/components/Widgets/Sharing/Sharing.tsx index 1025717..dd2d2a0 100644 --- a/src/components/Widgets/Sharing/Sharing.tsx +++ b/src/components/Widgets/Sharing/Sharing.tsx @@ -1,5 +1,5 @@ import { ExpandableWidget } from '@components/WidgetParts'; -import sharingMedia from '@config/sharing'; +import { getIntlInstance } from '@utils/helpers/i18n'; import { useRouter } from 'next/router'; import { useEffect, useState } from 'react'; import { useIntl } from 'react-intl'; @@ -95,9 +95,94 @@ const Sharing = ({ excerpt, title }: { excerpt: string; title: string }) => { return sharingUrl; }; - const getItems = () => { - const websites: Website[] = sharingMedia; + const websites = [ + { + id: 'diaspora', + name: intl.formatMessage({ + defaultMessage: 'Diaspora', + description: 'Sharing: Diaspora', + }), + parameters: { + content: '', + image: '', + title: 'title', + url: 'url', + }, + url: 'https://share.diasporafoundation.org/', + }, + { + id: 'facebook', + name: intl.formatMessage({ + defaultMessage: 'Facebook', + description: 'Sharing: Facebook', + }), + parameters: { + content: '', + image: '', + title: '', + url: 'u', + }, + url: 'https://www.facebook.com/sharer/sharer.php', + }, + { + id: 'linkedin', + name: intl.formatMessage({ + defaultMessage: 'LinkedIn', + description: 'Sharing: LinkedIn', + }), + parameters: { + content: '', + image: '', + title: '', + url: 'url', + }, + url: 'https://www.linkedin.com/sharing/share-offsite/', + }, + { + id: 'twitter', + name: intl.formatMessage({ + defaultMessage: 'Twitter', + description: 'Sharing: Twitter', + }), + parameters: { + content: '', + image: '', + title: 'text', + url: 'url', + }, + url: 'https://twitter.com/intent/tweet', + }, + { + id: 'journal-du-hacker', + name: intl.formatMessage({ + defaultMessage: 'Journal du hacker', + description: 'Sharing: Journal du hacker', + }), + parameters: { + content: '', + image: '', + title: 'title', + url: 'url', + }, + url: 'https://www.journalduhacker.net/stories/new', + }, + { + id: 'email', + name: intl.formatMessage({ + defaultMessage: 'Email', + description: 'Sharing: Email', + }), + parameters: { + content: 'body', + image: '', + title: 'subject', + url: '', + }, + url: 'mailto:', + }, + ]; + const getItems = () => { return websites.map((website) => { const { id, name } = website; const sharingUrl = getSharingUrl(website); diff --git a/src/config/sharing.ts b/src/config/sharing.ts deleted file mode 100644 index 9e84801..0000000 --- a/src/config/sharing.ts +++ /dev/null @@ -1,70 +0,0 @@ -const sharingMedia = [ - { - id: 'diaspora', - name: 'Diaspora', - parameters: { - content: '', - image: '', - title: 'title', - url: 'url', - }, - url: 'https://share.diasporafoundation.org/', - }, - { - id: 'facebook', - name: 'Facebook', - parameters: { - content: '', - image: '', - title: '', - url: 'u', - }, - url: 'https://www.facebook.com/sharer/sharer.php', - }, - { - id: 'linkedin', - name: 'LinkedIn', - parameters: { - content: '', - image: '', - title: '', - url: 'url', - }, - url: 'https://www.linkedin.com/sharing/share-offsite/', - }, - { - id: 'twitter', - name: 'Twitter', - parameters: { - content: '', - image: '', - title: 'text', - url: 'url', - }, - url: 'https://twitter.com/intent/tweet', - }, - { - id: 'journal-du-hacker', - name: 'Journal du Hacker', - parameters: { - content: '', - image: '', - title: 'title', - url: 'url', - }, - url: 'https://www.journalduhacker.net/stories/new', - }, - { - id: 'email', - name: 'Email', - parameters: { - content: 'body', - image: '', - title: 'subject', - url: '', - }, - url: 'mailto:', - }, -]; - -export default sharingMedia; diff --git a/src/i18n/en.json b/src/i18n/en.json index 23f5278..2faabe0 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -67,6 +67,10 @@ "defaultMessage": "Blog", "description": "BlogPage: page title" }, + "7iiaRx": { + "defaultMessage": "Facebook", + "description": "Sharing: Facebook" + }, "8Ls2mD": { "defaultMessage": "Please fill the form to contact me.", "description": "ContactPage: page introduction" @@ -107,6 +111,10 @@ "defaultMessage": "Contact", "description": "ContactPage: breadcrumb item" }, + "Dhow1m": { + "defaultMessage": "Diaspora", + "description": "Sharing: Diaspora" + }, "Dq6+WH": { "defaultMessage": "Thematics", "description": "SearchPage: thematics list widget title" @@ -227,6 +235,10 @@ "defaultMessage": "{commentCount, plural, =0 {No comments} one {# comment} other {# comments}}", "description": "PostMeta: comment count value" }, + "P0I+Xm": { + "defaultMessage": "Journal du hacker", + "description": "Sharing: Journal du hacker" + }, "P7fxX2": { "defaultMessage": "All posts in {name}", "description": "ThematicPage: posts list title" @@ -295,6 +307,10 @@ "defaultMessage": "Collapse", "description": "ExpandableWidget: collapse text" }, + "WjVBnY": { + "defaultMessage": "Twitter", + "description": "Sharing: Twitter" + }, "X3PDXO": { "defaultMessage": "Animations:", "description": "ReduceMotion: toggle label" @@ -363,6 +379,10 @@ "defaultMessage": "Subject", "description": "ContactPage: subject field label" }, + "csCQQk": { + "defaultMessage": "LinkedIn", + "description": "Sharing: LinkedIn" + }, "dE8xxV": { "defaultMessage": "Close menu", "description": "MainNav: close button" @@ -439,6 +459,10 @@ "defaultMessage": "{thematicsCount, plural, =0 {Thematics:} one {Thematic:} other {Thematics:}}", "description": "PostMeta: thematics list label" }, + "lKZm9t": { + "defaultMessage": "Email", + "description": "Sharing: Email" + }, "mC21ht": { "defaultMessage": "Number of articles loaded out of the total available.", "description": "PaginationCursor: loaded articles count aria-label" diff --git a/src/i18n/fr.json b/src/i18n/fr.json index a3f5756..6289433 100644 --- a/src/i18n/fr.json +++ b/src/i18n/fr.json @@ -67,6 +67,10 @@ "defaultMessage": "Blog", "description": "BlogPage: page title" }, + "7iiaRx": { + "defaultMessage": "Facebook", + "description": "Sharing: Facebook" + }, "8Ls2mD": { "defaultMessage": "Veuillez remplir le formulaire pour me contacter.", "description": "ContactPage: page introduction" @@ -107,6 +111,10 @@ "defaultMessage": "Contact", "description": "ContactPage: breadcrumb item" }, + "Dhow1m": { + "defaultMessage": "Diaspora", + "description": "Sharing: Diaspora" + }, "Dq6+WH": { "defaultMessage": "Thématiques", "description": "SearchPage: thematics list widget title" @@ -227,6 +235,10 @@ "defaultMessage": "{commentCount, plural, =0 {Aucun commentaire} one {# commentaire} other {# commentaires}}", "description": "PostMeta: comment count value" }, + "P0I+Xm": { + "defaultMessage": "Journal du hacker", + "description": "Sharing: Journal du hacker" + }, "P7fxX2": { "defaultMessage": "Tous les articles dans {name}", "description": "ThematicPage: posts list title" @@ -295,6 +307,10 @@ "defaultMessage": "Replier", "description": "ExpandableWidget: collapse text" }, + "WjVBnY": { + "defaultMessage": "Twitter", + "description": "Sharing: Twitter" + }, "X3PDXO": { "defaultMessage": "Animations :", "description": "ReduceMotion: toggle label" @@ -363,6 +379,10 @@ "defaultMessage": "Sujet", "description": "ContactPage: subject field label" }, + "csCQQk": { + "defaultMessage": "LinkedIn", + "description": "Sharing: LinkedIn" + }, "dE8xxV": { "defaultMessage": "Fermer le menu", "description": "MainNav: close button" @@ -439,6 +459,10 @@ "defaultMessage": "{thematicsCount, plural, =0 {Thématiques :} one {Thématique :} other {Thématiques :}}", "description": "PostMeta: thematics list label" }, + "lKZm9t": { + "defaultMessage": "Email", + "description": "Sharing: Email" + }, "mC21ht": { "defaultMessage": "Nombre d'articles chargés sur le total disponible.", "description": "PaginationCursor: loaded articles count aria-label" |
