From 01411afdffe82ff7abc270c096db06648507a49d Mon Sep 17 00:00:00 2001 From: Ben Liu Date: Sat, 16 Sep 2023 01:09:04 +0700 Subject: [PATCH] feat(homepage): add customised social media component --- homepage/_data/social_media.json | 12 ++++ homepage/src/components/banner.jsx | 4 +- homepage/src/components/social.jsx | 79 ------------------------ homepage/src/components/socialMedia.jsx | 82 +++++++++++++++++++++++++ homepage/src/layouts/footer.jsx | 4 +- homepage/src/pages/admin/config.json | 36 ++++++----- 6 files changed, 120 insertions(+), 97 deletions(-) create mode 100644 homepage/_data/social_media.json delete mode 100644 homepage/src/components/social.jsx create mode 100644 homepage/src/components/socialMedia.jsx diff --git a/homepage/_data/social_media.json b/homepage/_data/social_media.json new file mode 100644 index 00000000..2dd679da --- /dev/null +++ b/homepage/_data/social_media.json @@ -0,0 +1,12 @@ +{ + "links": [ + { + "type": "github", + "url": "https://github.com/ocftw/open-star-ter-village" + }, + { + "type": "discord", + "url": "https://discord.gg/JnTHGnxwYS" + } + ] +} diff --git a/homepage/src/components/banner.jsx b/homepage/src/components/banner.jsx index 1b9c3eb5..8022bacd 100644 --- a/homepage/src/components/banner.jsx +++ b/homepage/src/components/banner.jsx @@ -1,5 +1,5 @@ import Image from 'next/image'; -import Social from './social'; +import SocialMedia from './socialMedia'; const Banner = ({ heroImage, title, subtitle = '', highlights = [] }) => (
@@ -20,7 +20,7 @@ const Banner = ({ heroImage, title, subtitle = '', highlights = [] }) => (
  • {highlight}
  • ))} - +
    diff --git a/homepage/src/components/social.jsx b/homepage/src/components/social.jsx deleted file mode 100644 index 595370d5..00000000 --- a/homepage/src/components/social.jsx +++ /dev/null @@ -1,79 +0,0 @@ -const Social = ({ - facebook, - twitter, - instagram, - linkedin, - discord, - github, -}) => ( - -); - -Social.defaultProps = { - instagram: `https://instagram.com/openstartervillage/`, - discord: `https://discord.gg/JnTHGnxwYS`, - github: `https://github.com/ocftw/open-star-ter-village`, -}; - -export default Social; diff --git a/homepage/src/components/socialMedia.jsx b/homepage/src/components/socialMedia.jsx new file mode 100644 index 00000000..4a00396f --- /dev/null +++ b/homepage/src/components/socialMedia.jsx @@ -0,0 +1,82 @@ +import Link from 'next/link'; +import socialMedia from '../../_data/social_media.json'; + +const SocialMedia = ({ links = null }) => { + const socialMediaList = links || socialMedia.links || []; + + const socialMediaLinks = socialMediaList.map((link) => { + const { type, url } = link; + switch (type) { + case 'facebook': + return ( +
  • + +
  • + ); + case 'twitter': + return ( +
  • + +
  • + ); + case 'instagram': + return ( +
  • + +
  • + ); + case 'linkedin': + return ( +
  • + +
  • + ); + case 'discord': + return ( +
  • + +
  • + ); + case 'github': + return ( +
  • + +
  • + ); + } + }); + + return ; +}; + +export default SocialMedia; diff --git a/homepage/src/layouts/footer.jsx b/homepage/src/layouts/footer.jsx index bc748d36..1887b915 100644 --- a/homepage/src/layouts/footer.jsx +++ b/homepage/src/layouts/footer.jsx @@ -1,5 +1,5 @@ import Link from 'next/link'; -import Social from '../components/social'; +import SocialMedia from '../components/socialMedia'; import Logo from '../components/logo'; const Footer = ({ siteData }) => ( @@ -19,7 +19,7 @@ const Footer = ({ siteData }) => ( ))} {siteData.title} - +
    /" } ] }