Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

suthesh/social-sharing-blog #1868

Merged
5 commits merged into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/components/containers/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ const SEO = ({ description, meta, title, no_index, has_organization_schema, meta
},
...(no_index || no_index_staging || is_ach_page
? [
{
name: 'robots',
content: 'noindex',
},
]
{
name: 'robots',
content: 'noindex',
},
]
: []),
].concat(meta)}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/localization/withIntl.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const WithIntl = () => (WrappedComponent) => {
}
return (
<I18nextProvider i18n={i18next}>
<WrappedComponent {...props} language={i18next.language} />
<WrappedComponent {...props} language={i18next.language} pageContext={pageContext} />
</I18nextProvider>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/images/svg/blog/facebook.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/images/svg/blog/instagram.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/images/svg/blog/pinterest.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/images/svg/blog/twitter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions src/pages/blog/_social-sharing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react'
import styled from 'styled-components'
import PropTypes from 'prop-types'
import { SectionContainer, Container, Flex } from 'components/containers'
import { LocalizedLink } from 'components/localization'
import { Header } from 'components/elements/typography'
import device from 'themes/device'
import FacebookIcon from 'images/svg/blog/facebook.svg'
import PinterestIcon from 'images/svg/blog/pinterest.svg'
import TwitterIcon from 'images/svg/blog/twitter.svg'
import LinkedInIcon from 'images/svg/footer-linkedin.svg'

const IconWrapper = styled.div`
width: 120px;
`

const HeaderWrapper = styled.span`
margin-right: 16px;

@media ${device.tablet}{
margin: 0 auto 8px;
}
`

const StyledFlex = styled(Flex)`
@media ${device.tablet}{
width: 120px;
margin-left: auto;
}
`

const SocialSharing = ({ pathname }) => {
return (
<SectionContainer>
<Container>
<StyledFlex jc="flex-end" ai="center" tablet_direction="column" tablet_jc="flex-end" tablet_ai="flex-end">
<HeaderWrapper>
<Header type="paragraph-2" weight="normal">
Share this post
</Header>
</HeaderWrapper>
<IconWrapper>
<Flex jc="space-between">
<LocalizedLink external to={"https://www.facebook.com/sharer/sharer.php?u=https://deriv.com" + pathname} target="_blank" rel="noopener noreferrer">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<LocalizedLink external to={"https://www.facebook.com/sharer/sharer.php?u=https://deriv.com" + pathname} target="_blank" rel="noopener noreferrer">
<LocalizedLink external to={`https://www.facebook.com/sharer/sharer.php?u=https://deriv.com${pathname}`} target="_blank" rel="noopener noreferrer">

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use template literals for this.

<img src={FacebookIcon} width="24px" height="24px" />
</LocalizedLink>
<LocalizedLink external to={"http://www.linkedin.com/shareArticle?mini=true&url=https://deriv.com" + pathname} target="_blank" rel="noopener noreferrer">
<img src={LinkedInIcon} width="24px" height="24px" />
</LocalizedLink>
<LocalizedLink external to={"https://www.twitter.com/share?url=https://deriv.com" + pathname} target="_blank" rel="noopener noreferrer">
<img src={TwitterIcon} width="24px" height="24px" />
</LocalizedLink>
<LocalizedLink external to={"https://pinterest.com/pin/create/button/?url=https://deriv.com" + pathname + "&media=&description="} target="_blank" rel="noopener noreferrer">
<img src={PinterestIcon} width="24px" height="24px" />
</LocalizedLink>
</Flex>
</IconWrapper>
</StyledFlex>
</Container>
</SectionContainer>
)
}

SocialSharing.propTypes = {
pathname: PropTypes.string,
}

export default SocialSharing
20 changes: 20 additions & 0 deletions src/pages/blog/social-sharing/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import SocialSharing from '../_social-sharing'
import { WithIntl } from 'components/localization'
import Layout from 'components/layout/layout'

const Index = (props) => {
const pathname = props.pageContext.pathname
return (
<Layout>
<SocialSharing pathname={pathname} />
</Layout>
)
}

Index.propTypes = {
pageContext: PropTypes.object,
}

export default WithIntl()(Index)