website: add Carbon
This commit is contained in:
parent
1fe3e48bb1
commit
ae93196d7b
|
|
@ -128,9 +128,6 @@ module.exports = {
|
|||
apiKey: '6c13c369e8d9809cebb5c51330c914c3',
|
||||
indexName: 'frontendinterviewhandbook',
|
||||
},
|
||||
metadata: [
|
||||
{name: 'fo-verify', content: '2cc93525-ece8-402e-a4b8-d1d0853175e8'},
|
||||
],
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
import React, {useEffect, useRef} from 'react';
|
||||
|
||||
// Credits: https://github.com/tannerlinsley/react-query/blob/master/docs/src/components/CarbonAds.js
|
||||
function buildScript(src, attrs = {}) {
|
||||
if (typeof document !== 'undefined') {
|
||||
const script = document.createElement('script');
|
||||
script.async = true;
|
||||
script.defer = true;
|
||||
script.src = src;
|
||||
Object.keys(attrs).forEach((attr) =>
|
||||
script.setAttribute(attr, attrs[attr]),
|
||||
);
|
||||
|
||||
return script;
|
||||
}
|
||||
}
|
||||
|
||||
export default React.memo(() => {
|
||||
const ref = useRef();
|
||||
|
||||
useEffect(() => {
|
||||
const script = buildScript(
|
||||
'//cdn.carbonads.com/carbon.js?serve=CEAI4537&placement=wwwtechinterviewhandbookorg',
|
||||
{
|
||||
type: 'text/javascript',
|
||||
id: '_carbonads_js',
|
||||
},
|
||||
);
|
||||
|
||||
ref.current.appendChild(script);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const interval = setInterval(() => {
|
||||
[...ref.current.children].forEach((child) => {
|
||||
if (child.id.startsWith('carbonads_')) {
|
||||
ref.current.removeChild(child);
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
|
||||
return () => {
|
||||
clearInterval(interval);
|
||||
};
|
||||
});
|
||||
|
||||
return <div ref={ref} />;
|
||||
});
|
||||
|
|
@ -74,6 +74,10 @@ div[class^='announcementBar_'] {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.menu {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.navbar__item.dropdown.dropdown--hoverable {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
|
@ -117,3 +121,71 @@ html[data-theme='dark'] .navbar-icon-facebook:before {
|
|||
height: 28px;
|
||||
width: 28px;
|
||||
}
|
||||
|
||||
#carbonads * {
|
||||
margin: initial;
|
||||
padding: initial;
|
||||
}
|
||||
#carbonads {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
|
||||
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', Helvetica, Arial,
|
||||
sans-serif;
|
||||
display: flex;
|
||||
background-color: hsl(0, 0%, 98%);
|
||||
box-shadow: 0 1px 4px 1px hsla(0, 0%, 0%, 0.1);
|
||||
z-index: 100;
|
||||
margin: 1rem auto;
|
||||
}
|
||||
html[data-theme='dark'] #carbonads {
|
||||
background-color: hsl(0, 0%, 15%);
|
||||
box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.085), 0 0 2px hsl(0deg 0% 0% / 0.085),
|
||||
0 0 4px hsl(0deg 0% 0% / 0.085), 0 0 8px hsl(0deg 0% 0% / 0.085);
|
||||
}
|
||||
#carbonads a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
#carbonads a:hover {
|
||||
color: inherit;
|
||||
}
|
||||
#carbonads span {
|
||||
position: relative;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
#carbonads .carbon-wrap {
|
||||
display: flex;
|
||||
}
|
||||
#carbonads .carbon-img {
|
||||
display: block;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
#carbonads .carbon-img img {
|
||||
display: block;
|
||||
}
|
||||
#carbonads .carbon-text {
|
||||
font-size: 13px;
|
||||
padding: 10px;
|
||||
margin-bottom: 16px;
|
||||
line-height: 1.5;
|
||||
text-align: left;
|
||||
}
|
||||
#carbonads .carbon-poweredby {
|
||||
display: block;
|
||||
padding: 6px 8px;
|
||||
background: #f1f1f2;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-weight: 600;
|
||||
font-size: 8px;
|
||||
line-height: 1;
|
||||
border-top-left-radius: 3px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
}
|
||||
html[data-theme='dark'] #carbonads .carbon-poweredby {
|
||||
background: #1e2021;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
|||
import styles from './styles.module.css';
|
||||
|
||||
import successStories from '@site/src/data/successStories';
|
||||
import CarbonAd from '../components/CarbonAd';
|
||||
|
||||
export default function Home() {
|
||||
const {siteConfig = {}} = useDocusaurusContext();
|
||||
|
|
@ -18,9 +19,10 @@ export default function Home() {
|
|||
<div>
|
||||
<HeroSection />
|
||||
<EducativeSection />
|
||||
<CarbonAdSection />
|
||||
<FeaturesSection />
|
||||
<MoonchaserSection />
|
||||
<TweetsSection />
|
||||
<MoonchaserSection />
|
||||
<SuccessStoriesSection />
|
||||
<SponsorshipSection />
|
||||
</div>
|
||||
|
|
@ -73,6 +75,20 @@ function HeroSection() {
|
|||
);
|
||||
}
|
||||
|
||||
function CarbonAdSection() {
|
||||
return (
|
||||
<div className={classnames('padding-vert--lg', styles.sectionAlt)}>
|
||||
<div className="container">
|
||||
<div className="row">
|
||||
<div className="col col--8 col--offset-2">
|
||||
<CarbonAd />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function MoonchaserSection() {
|
||||
/* Because the SSR and client output can differ and hydration doesn't patch attribute differences,
|
||||
we'll render this on the browser only. */
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import {translate} from '@docusaurus/Translate';
|
|||
import {DocSidebarItems} from '@theme/DocSidebarItem';
|
||||
import styles from './styles.module.css';
|
||||
import SidebarAd from '../../components/SidebarAd';
|
||||
import CarbonAd from '../../components/CarbonAd';
|
||||
|
||||
function useShowAnnouncementBar() {
|
||||
const {isActive} = useAnnouncementBar();
|
||||
|
|
@ -73,8 +74,8 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}) {
|
|||
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
|
||||
<DocSidebarItems items={sidebar} activePath={path} level={1} />
|
||||
</ul>
|
||||
<div className="margin--md">
|
||||
<SidebarAd position="left_sidebar" />
|
||||
<div className="margin-vert--md">
|
||||
<CarbonAd key={path} />
|
||||
</div>
|
||||
</nav>
|
||||
{hideableSidebar && <HideableSidebarButton onClick={onCollapse} />}
|
||||
|
|
|
|||
Loading…
Reference in New Issue