-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(content): show an ad after the main content of the page
- Loading branch information
Showing
5 changed files
with
80 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Box, Link, Text, Tooltip } from '@/TabNewsUI'; | ||
import { LinkExternalIcon } from '@/TabNewsUI/icons'; | ||
import { getDomain, isExternalLink, isTrustedDomain } from 'pages/interface'; | ||
|
||
export default function AdBanner({ ad, ...props }) { | ||
const link = ad.source_url || `/${ad.owner_username}/${ad.slug}`; | ||
const isAdToExternalLink = isExternalLink(link); | ||
const domain = isAdToExternalLink ? `(${getDomain(link)})` : ''; | ||
const title = ad.title.length > 70 ? ad.title.substring(0, 67).trim().concat('...') : ad.title; | ||
|
||
return ( | ||
<Box {...props} as="aside" sx={{ display: 'grid', ...props.sx }}> | ||
<Box> | ||
<Link | ||
sx={{ | ||
overflow: 'auto', | ||
fontWeight: 'semibold', | ||
wordWrap: 'break-word', | ||
':link': { | ||
color: 'success.fg', | ||
}, | ||
':visited': { | ||
color: 'success.fg', | ||
}, | ||
}} | ||
href={link} | ||
rel={isTrustedDomain(link) ? undefined : 'nofollow'}> | ||
<Text sx={{ wordBreak: 'break-word', marginRight: 1 }}> | ||
{title} {domain} | ||
</Text> | ||
{isAdToExternalLink && <LinkExternalIcon verticalAlign="middle" />} | ||
</Link> | ||
</Box> | ||
|
||
<Text sx={{ whiteSpace: 'nowrap', fontSize: 0, color: 'neutral.emphasis' }}> | ||
Contribuindo com{' '} | ||
<Tooltip | ||
aria-label={`Autor: ${ad.owner_username}`} | ||
direction="nw" | ||
sx={{ position: 'absolute', display: 'grid' }}> | ||
<Link | ||
sx={{ overflow: 'hidden', textOverflow: 'ellipsis', color: 'neutral.emphasis', mr: 2 }} | ||
href={`/${ad.owner_username}`}> | ||
{ad.owner_username} | ||
</Link> | ||
</Tooltip> | ||
</Text> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters