From 0275e406968a2f6d742b0cb6fcf6a0176d11b919 Mon Sep 17 00:00:00 2001 From: Yangshun Date: Wed, 2 Feb 2022 16:37:54 +0800 Subject: [PATCH] website: customize the sidebar content according to the page --- website/docusaurus.config.js | 2 - website/src/components/SidebarAd/index.js | 176 +++++++++++++++++----- 2 files changed, 142 insertions(+), 36 deletions(-) diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index b94b1ef4..954e2eae 100755 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -147,8 +147,6 @@ module.exports = { path: '../contents', routeBasePath: '/', sidebarPath: require.resolve('./sidebars.js'), - editUrl: - 'https://github.com/yangshun/tech-interview-handbook/edit/master/contents/', showLastUpdateAuthor: true, showLastUpdateTime: true, }, diff --git a/website/src/components/SidebarAd/index.js b/website/src/components/SidebarAd/index.js index 22362cd5..228e6b97 100644 --- a/website/src/components/SidebarAd/index.js +++ b/website/src/components/SidebarAd/index.js @@ -13,6 +13,109 @@ const BACKGROUNDS = [ styles.backgroundRed, ]; +function TopResume({className}) { + return ( + { + window.gtag('event', 'topresume.sidebar.click'); + }}> +

+ If you are running low on time, I recommend TopResume's{' '} + resume writing and free resume screening services, which + has helped countless software engineers get interviews at FAANG. +

+
+ ); +} + +function Moonchaser({className}) { + return ( + { + window.gtag('event', 'moonchaser.sidebar.click'); + }}> +

+ Get paid more. Receive risk-free salary negotiation + advice from Moonchaser. You pay nothing unless your offer is + increased. Book a free consultation today! +

+
+ ); +} + +function Educative({className}) { + return ( + { + window.gtag('event', 'educative.sidebar.click'); + }}> +

+ Looking to get hired at FAANG? Educative offers + many great courses to improve your interview game.{' '} + Join today for a 10% discount! +

+
+ ); +} + +function EducativeCoding({className}) { + return ( + { + window.gtag('event', 'educative.coding.sidebar.click'); + }}> +

+ Get the job at FAANG +
+ "Grokking the Coding Interview: Patterns for Coding Questions" by + Educative is the best course for improving your algorithms interview + game. Join today for a 10% discount! +

+
+ ); +} + +function EducativeSystemDesign({className}) { + return ( + { + window.gtag('event', 'educative.coding.sidebar.click'); + }}> +

+ Get the job at FAANG +
+ "Grokking the System Design Interview" by Educative is a highly + recommended course for improving your system design interview game.{' '} + Join today for a 10% discount! +

+
+ ); +} + export default React.memo(function SidebarAd() { const backgroundClass = BACKGROUNDS[Math.floor(Math.random() * BACKGROUNDS.length)]; @@ -21,41 +124,46 @@ export default React.memo(function SidebarAd() { // we'll render this on the browser only. return ( - {() => - Math.random() > 0.5 ? ( - { - window.gtag('event', 'moonchaser.sidebar.click'); - }}> -

- Get paid more. Receive risk-free salary - negotiation advice from Moonchaser. You pay nothing unless - your offer is increased. Book a free consultation today! -

-
+ {() => { + const path = window.location.pathname; + // Ugly hack to show conditional sidebar content. + if (path.startsWith('/resume')) { + return ; + } + + if ( + path.startsWith('/negotiation') || + path.startsWith('/understanding-compensation') + ) { + return ; + } + + if ( + path.includes('coding') || + path.startsWith('/best-practice-questions') || + path.startsWith('/cheatsheet') || + path.startsWith('/algorithms') + ) { + return ( + + ); + } + + if (path.includes('system-design')) { + return ( + + ); + } + + return Math.random() > 0.5 ? ( + ) : ( - { - window.gtag('event', 'educative.sidebar.click'); - }}> -

- Looking to get hired at FAANG? Educative{' '} - offers many great courses to improve your interview game.{' '} - Join today for a 10% discount! -

-
- ) - } + + ); + }}
); });