From 62060c28f9c005e0d48dc43abe972cdda219ec4e Mon Sep 17 00:00:00 2001 From: John Doe Date: Sun, 14 Jan 2024 12:54:20 +0100 Subject: [PATCH 1/6] fix ai card comments --- .../cards/components/aiCard/ArticleItem.tsx | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/features/cards/components/aiCard/ArticleItem.tsx b/src/features/cards/components/aiCard/ArticleItem.tsx index 8fee50c..ae565d5 100644 --- a/src/features/cards/components/aiCard/ArticleItem.tsx +++ b/src/features/cards/components/aiCard/ArticleItem.tsx @@ -1,7 +1,7 @@ import { BiCommentDetail } from 'react-icons/bi' import { GoDotFill } from 'react-icons/go' import { MdAccessTime } from 'react-icons/md' -import { CardItemWithActions, CardLink, ClickableItem } from 'src/components/Elements' +import { CardItemWithActions, CardLink } from 'src/components/Elements' import { Attributes } from 'src/lib/analytics' import { useUserPreferences } from 'src/stores/preferences' import { Article, BaseItemPropsType } from 'src/types' @@ -36,6 +36,13 @@ const ArticleItem = (props: BaseItemPropsType
) => { {item.title}

+ {listingMode === 'compact' && ( +
+ + {item.source} + +
+ )} {listingMode === 'normal' && (
@@ -44,18 +51,10 @@ const ArticleItem = (props: BaseItemPropsType
) => { {format(new Date(item.published_at))} - - {item.comments} comments - + + + {item.comments} comments +
)} From cafb6344c0130c0af4c7e3748e1ecf2eb8cf512c Mon Sep 17 00:00:00 2001 From: Mohamed Elashri Date: Mon, 4 Mar 2024 08:36:45 +0200 Subject: [PATCH 2/6] Add kagi to list of supported search engines --- src/assets/kagi_logo.svg | 4 ++++ src/config/index.tsx | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 src/assets/kagi_logo.svg diff --git a/src/assets/kagi_logo.svg b/src/assets/kagi_logo.svg new file mode 100644 index 0000000..ce322b2 --- /dev/null +++ b/src/assets/kagi_logo.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/config/index.tsx b/src/config/index.tsx index 85be9f6..96b716e 100644 --- a/src/config/index.tsx +++ b/src/config/index.tsx @@ -6,6 +6,7 @@ import { ReactComponent as PhindLogo } from 'src/assets/phind_logo.svg' import { ReactComponent as StartPageLogo } from 'src/assets/startpage_logo.svg' import { ReactComponent as YahooLogo } from 'src/assets/yahoo_logo.svg' import { ReactComponent as YandexLogo } from 'src/assets/yandex_logo.svg' +import { ReactComponent as KagiLogo} from 'src/assets/kagi_logo.svg' // Keys export const ANALYTICS_ENDPOINT = import.meta.env.VITE_AMPLITUDE_URL as string @@ -70,6 +71,11 @@ export const SUPPORTED_SEARCH_ENGINES = [ logo: PhindLogo, className: 'themeAdaptiveFillColor', }, + { + label: 'Kagi', + url: 'https://kagi.com/search?q=%s', + logo: KagiLogo, + }, ] export const LS_PREFERENCES_KEY = 'hackerTabPrefs' From 63d763541785ec2127ee2eeb45503abddd1eef09 Mon Sep 17 00:00:00 2001 From: MohamedElashri Date: Mon, 4 Mar 2024 09:36:32 +0200 Subject: [PATCH 3/6] remove unnecessary '%s'at the end of kagi url --- src/config/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config/index.tsx b/src/config/index.tsx index 96b716e..e12d777 100644 --- a/src/config/index.tsx +++ b/src/config/index.tsx @@ -73,7 +73,7 @@ export const SUPPORTED_SEARCH_ENGINES = [ }, { label: 'Kagi', - url: 'https://kagi.com/search?q=%s', + url: 'https://kagi.com/search?q=', logo: KagiLogo, }, ] From 5aa38302782046812ebe9c5241c54530743d408a Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 4 Apr 2024 14:22:40 +0000 Subject: [PATCH 4/6] make the ad banner sticky --- src/components/Elements/Card/Card.tsx | 39 ++++++++++++++++++- src/components/List/ListComponent.tsx | 33 +--------------- .../cards/components/aiCard/AICard.tsx | 3 +- .../conferencesCard/ConferencesCard.tsx | 16 +++----- .../cards/components/devtoCard/DevtoCard.tsx | 9 +---- .../freecodecampCard/FreecodecampCard.tsx | 9 +---- .../components/githubCard/GithubCard.tsx | 3 +- .../hackernewsCard/HackernewsCard.tsx | 12 ++---- .../components/hashnodeCard/HashnodeCard.tsx | 9 +---- .../indiehackersCard/IndiehackersCard.tsx | 12 ++---- .../components/lobstersCard/LobstersCard.tsx | 12 ++---- .../components/mediumCard/MediumCard.tsx | 9 +---- .../producthuntCard/ProducthuntCard.tsx | 7 ++-- .../components/redditCard/RedditCard.tsx | 9 +---- .../components/rssCard/CustomRssCard.tsx | 5 ++- 15 files changed, 70 insertions(+), 117 deletions(-) diff --git a/src/components/Elements/Card/Card.tsx b/src/components/Elements/Card/Card.tsx index 26eafbd..b6c47f0 100644 --- a/src/components/Elements/Card/Card.tsx +++ b/src/components/Elements/Card/Card.tsx @@ -1,22 +1,55 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import { isDesktop } from 'react-device-detect' import { SortableKnob } from 'react-easy-sort' import { BsBoxArrowInUpRight } from 'react-icons/bs' import { MdOutlineDragIndicator } from 'react-icons/md' import { ref } from 'src/config' +import { AdvBanner } from 'src/features/adv' +import { useRemoteConfigStore } from 'src/features/remoteConfig' import { useUserPreferences } from 'src/stores/preferences' import { SupportedCardType } from 'src/types' type CardProps = { children: React.ReactNode card: SupportedCardType + withAds?: boolean titleComponent?: React.ReactNode fullBlock?: boolean } -export const Card = ({ card, titleComponent, children, fullBlock = false }: CardProps) => { +export const Card = ({ + card, + titleComponent, + withAds = false, + children, + fullBlock = false, +}: CardProps) => { const { openLinksNewTab } = useUserPreferences() const { link, icon, label, badge } = card + const [canAdsLoad, setCanAdsLoad] = useState(true) + const { adsConfig } = useRemoteConfigStore() + + useEffect(() => { + if (!adsConfig.enabled || !withAds) { + return + } + + const handleClassChange = () => { + if (document.documentElement.classList.contains('dndState')) { + setCanAdsLoad(false) + } else { + setCanAdsLoad(true) + } + } + + const observer = new MutationObserver(handleClassChange) + observer.observe(document.documentElement, { attributes: true }) + + return () => { + observer.disconnect() + } + }, [withAds, adsConfig.enabled]) + const handleHeaderLinkClick = (e: React.MouseEvent) => { e.preventDefault() let url = `${link}?${ref}` @@ -42,6 +75,8 @@ export const Card = ({ card, titleComponent, children, fullBlock = false }: Card {badge && {badge}} + {canAdsLoad && adsConfig.enabled && withAds && } +
{children}
) diff --git a/src/components/List/ListComponent.tsx b/src/components/List/ListComponent.tsx index 7489fe8..e94c481 100644 --- a/src/components/List/ListComponent.tsx +++ b/src/components/List/ListComponent.tsx @@ -1,8 +1,6 @@ -import React, { ReactNode, useEffect } from 'react' +import React, { ReactNode } from 'react' import { Placeholder } from 'src/components/placeholders' import { MAX_ITEMS_PER_CARD } from 'src/config' -import { AdvBanner } from 'src/features/adv' -import { useRemoteConfigStore } from 'src/features/remoteConfig' import { BaseEntry } from 'src/types' type PlaceholdersProps = { @@ -23,7 +21,6 @@ export type ListComponentPropsType = { items: T[] isLoading: boolean renderItem: (item: T, index: number) => React.ReactNode - withAds: boolean placeholder?: React.ReactNode header?: React.ReactNode refresh?: boolean @@ -37,34 +34,10 @@ export function ListComponent(props: ListComponentPropsType isLoading, error, renderItem, - withAds, header, placeholder = , limit = MAX_ITEMS_PER_CARD, } = props - const { adsConfig } = useRemoteConfigStore() - const [canAdsLoad, setCanAdsLoad] = React.useState(true) - - useEffect(() => { - if (!adsConfig.enabled || !withAds) { - return - } - - const handleClassChange = () => { - if (document.documentElement.classList.contains('dndState')) { - setCanAdsLoad(false) - } else { - setCanAdsLoad(true) - } - } - - const observer = new MutationObserver(handleClassChange) - observer.observe(document.documentElement, { attributes: true }) - - return () => { - observer.disconnect() - } - }, [withAds, adsConfig.enabled]) if (error) { return

{error?.message || error}

@@ -81,10 +54,6 @@ export function ListComponent(props: ListComponentPropsType content.unshift(header) } - if (canAdsLoad && adsConfig.enabled && withAds && index === adsConfig.rowPosition) { - content.unshift() - } - return content }) } diff --git a/src/features/cards/components/aiCard/AICard.tsx b/src/features/cards/components/aiCard/AICard.tsx index 875f1b2..c0f67e0 100644 --- a/src/features/cards/components/aiCard/AICard.tsx +++ b/src/features/cards/components/aiCard/AICard.tsx @@ -32,7 +32,7 @@ export function AICard({ meta, withAds }: CardPropsType) { ) return ( - + ) diff --git a/src/features/cards/components/conferencesCard/ConferencesCard.tsx b/src/features/cards/components/conferencesCard/ConferencesCard.tsx index b0af552..fa9d1f6 100644 --- a/src/features/cards/components/conferencesCard/ConferencesCard.tsx +++ b/src/features/cards/components/conferencesCard/ConferencesCard.tsx @@ -1,11 +1,10 @@ import { Card } from 'src/components/Elements' import { ListComponent } from 'src/components/List' -import { useGetConferences } from '../../api/getConferences' -import { Conference, CardPropsType } from 'src/types' import { useUserPreferences } from 'src/stores/preferences' -import { getCardTagsValue } from 'src/utils/DataEnhancement' +import { CardPropsType, Conference } from 'src/types' +import { filterUniqueEntries, getCardTagsValue } from 'src/utils/DataEnhancement' +import { useGetConferences } from '../../api/getConferences' import ConferenceItem from './ConferenceItem' -import { filterUniqueEntries } from 'src/utils/DataEnhancement' export function ConferencesCard({ meta, withAds }: CardPropsType) { const { userSelectedTags } = useUserPreferences() @@ -35,13 +34,8 @@ export function ConferencesCard({ meta, withAds }: CardPropsType) { ) return ( - - + + ) } diff --git a/src/features/cards/components/devtoCard/DevtoCard.tsx b/src/features/cards/components/devtoCard/DevtoCard.tsx index c988f07..69f363a 100644 --- a/src/features/cards/components/devtoCard/DevtoCard.tsx +++ b/src/features/cards/components/devtoCard/DevtoCard.tsx @@ -70,14 +70,9 @@ export function DevtoCard({ withAds, meta }: CardPropsType) { } return ( - }> + } withAds={withAds}> - + ) } diff --git a/src/features/cards/components/freecodecampCard/FreecodecampCard.tsx b/src/features/cards/components/freecodecampCard/FreecodecampCard.tsx index 148e467..26c9313 100644 --- a/src/features/cards/components/freecodecampCard/FreecodecampCard.tsx +++ b/src/features/cards/components/freecodecampCard/FreecodecampCard.tsx @@ -71,14 +71,9 @@ export function FreecodecampCard({ meta, withAds }: CardPropsType) { } return ( - }> + } withAds={withAds}> - + ) } diff --git a/src/features/cards/components/githubCard/GithubCard.tsx b/src/features/cards/components/githubCard/GithubCard.tsx index d8e6acd..932d7f3 100644 --- a/src/features/cards/components/githubCard/GithubCard.tsx +++ b/src/features/cards/components/githubCard/GithubCard.tsx @@ -97,14 +97,13 @@ export function GithubCard({ meta, withAds }: CardPropsType) { } } return ( - }> + } withAds={withAds}> ) diff --git a/src/features/cards/components/hackernewsCard/HackernewsCard.tsx b/src/features/cards/components/hackernewsCard/HackernewsCard.tsx index 311d44e..6e0933b 100644 --- a/src/features/cards/components/hackernewsCard/HackernewsCard.tsx +++ b/src/features/cards/components/hackernewsCard/HackernewsCard.tsx @@ -1,7 +1,7 @@ import { Card } from 'src/components/Elements' import { ListComponent } from 'src/components/List' -import { useGetHackertNewsArticles } from '../../api/getHackerNewsArticles' import { Article, CardPropsType } from 'src/types' +import { useGetHackertNewsArticles } from '../../api/getHackerNewsArticles' import ArticleItem from './ArticleItem' export function HackernewsCard({ meta, withAds }: CardPropsType) { @@ -12,14 +12,8 @@ export function HackernewsCard({ meta, withAds }: CardPropsType) { ) return ( - - + + ) } diff --git a/src/features/cards/components/hashnodeCard/HashnodeCard.tsx b/src/features/cards/components/hashnodeCard/HashnodeCard.tsx index aa4a56e..e0e9286 100644 --- a/src/features/cards/components/hashnodeCard/HashnodeCard.tsx +++ b/src/features/cards/components/hashnodeCard/HashnodeCard.tsx @@ -71,14 +71,9 @@ export function HashnodeCard({ withAds, meta }: CardPropsType) { } return ( - }> + } withAds={withAds}> - + ) } diff --git a/src/features/cards/components/indiehackersCard/IndiehackersCard.tsx b/src/features/cards/components/indiehackersCard/IndiehackersCard.tsx index 44a13be..3a14c80 100644 --- a/src/features/cards/components/indiehackersCard/IndiehackersCard.tsx +++ b/src/features/cards/components/indiehackersCard/IndiehackersCard.tsx @@ -1,7 +1,7 @@ import { Card } from 'src/components/Elements' import { ListComponent } from 'src/components/List' -import { useGetIndieHackersArticles } from '../../api/getIndieHackersArticles' import { Article, CardPropsType } from 'src/types' +import { useGetIndieHackersArticles } from '../../api/getIndieHackersArticles' import { ArticleItem } from './ArticleItem' export function IndiehackersCard({ meta, withAds }: CardPropsType) { @@ -12,14 +12,8 @@ export function IndiehackersCard({ meta, withAds }: CardPropsType) { ) return ( - - + + ) } diff --git a/src/features/cards/components/lobstersCard/LobstersCard.tsx b/src/features/cards/components/lobstersCard/LobstersCard.tsx index ac9d1a6..657aa17 100644 --- a/src/features/cards/components/lobstersCard/LobstersCard.tsx +++ b/src/features/cards/components/lobstersCard/LobstersCard.tsx @@ -1,7 +1,7 @@ import { Card } from 'src/components/Elements' import { ListComponent } from 'src/components/List' -import { useGetLobstersArticles } from '../../api/getLobstersArticles' import { Article, CardPropsType } from 'src/types' +import { useGetLobstersArticles } from '../../api/getLobstersArticles' import ArticleItem from './ArticleItem' export function LobstersCard({ withAds, meta }: CardPropsType) { @@ -12,14 +12,8 @@ export function LobstersCard({ withAds, meta }: CardPropsType) { ) return ( - - + + ) } diff --git a/src/features/cards/components/mediumCard/MediumCard.tsx b/src/features/cards/components/mediumCard/MediumCard.tsx index d97cc10..dfffb43 100644 --- a/src/features/cards/components/mediumCard/MediumCard.tsx +++ b/src/features/cards/components/mediumCard/MediumCard.tsx @@ -69,14 +69,9 @@ export function MediumCard({ meta, withAds }: CardPropsType) { } return ( - }> + } withAds={withAds}> - + ) } diff --git a/src/features/cards/components/producthuntCard/ProducthuntCard.tsx b/src/features/cards/components/producthuntCard/ProducthuntCard.tsx index 6efb646..54c6c12 100644 --- a/src/features/cards/components/producthuntCard/ProducthuntCard.tsx +++ b/src/features/cards/components/producthuntCard/ProducthuntCard.tsx @@ -1,8 +1,8 @@ import { Card } from 'src/components/Elements' import { ListComponent } from 'src/components/List' -import { useGeProductHuntProducts } from '../../api/getProductHuntProducts' -import { Article, CardPropsType } from 'src/types' import { ProductHuntPlaceholder } from 'src/components/placeholders' +import { Article, CardPropsType } from 'src/types' +import { useGeProductHuntProducts } from '../../api/getProductHuntProducts' import ArticleItem from './ArticleItem' export function ProductHuntCard({ meta, withAds }: CardPropsType) { @@ -22,13 +22,12 @@ export function ProductHuntCard({ meta, withAds }: CardPropsType) { ) return ( - + } /> diff --git a/src/features/cards/components/redditCard/RedditCard.tsx b/src/features/cards/components/redditCard/RedditCard.tsx index 2fe6706..ededc35 100644 --- a/src/features/cards/components/redditCard/RedditCard.tsx +++ b/src/features/cards/components/redditCard/RedditCard.tsx @@ -71,14 +71,9 @@ export function RedditCard({ withAds, meta }: CardPropsType) { } return ( - }> + } withAds={withAds}> - + ) } diff --git a/src/features/cards/components/rssCard/CustomRssCard.tsx b/src/features/cards/components/rssCard/CustomRssCard.tsx index a91d55c..e9776e0 100644 --- a/src/features/cards/components/rssCard/CustomRssCard.tsx +++ b/src/features/cards/components/rssCard/CustomRssCard.tsx @@ -23,8 +23,9 @@ export function CustomRssCard({ meta, withAds }: CardPropsType) { return ( }} - titleComponent={}> - + titleComponent={} + withAds={withAds}> + ) } From 87191a49e83c815a590dea82f73b3142c763f268 Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 4 Apr 2024 22:11:44 +0000 Subject: [PATCH 5/6] handle multiple viewUrls --- src/features/adv/components/AdvBanner.tsx | 5 ++++- src/features/adv/types/index.ts | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/features/adv/components/AdvBanner.tsx b/src/features/adv/components/AdvBanner.tsx index 41ec23d..0734cbe 100644 --- a/src/features/adv/components/AdvBanner.tsx +++ b/src/features/adv/components/AdvBanner.tsx @@ -73,7 +73,10 @@ export const AdvBanner = () => { - {ad.viewUrl && } + {ad.viewUrl && + ad.viewUrl + .split('||') + .map((viewUrl, i) => )} ) } diff --git a/src/features/adv/types/index.ts b/src/features/adv/types/index.ts index 66e3b3e..ac5cc8a 100644 --- a/src/features/adv/types/index.ts +++ b/src/features/adv/types/index.ts @@ -1,7 +1,7 @@ type AdProvider = { - name: string, - title: string, - link?: string, + name: string + title: string + link?: string } type NextAdType = { @@ -18,4 +18,4 @@ export type Ad = { backgroundColor?: string provider: AdProvider nextAd?: NextAdType -} \ No newline at end of file +} From 16e55a948a646ae927401d55f28c1c7c28471faa Mon Sep 17 00:00:00 2001 From: John Doe Date: Thu, 4 Apr 2024 22:14:43 +0000 Subject: [PATCH 6/6] prevent excluding favicon --- script/build-chrome.sh | 2 +- script/build-firefox.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/build-chrome.sh b/script/build-chrome.sh index ff6cb15..941bea3 100755 --- a/script/build-chrome.sh +++ b/script/build-chrome.sh @@ -22,4 +22,4 @@ yarn build:ext # Zip the distribution folder echo 'Zip the extension' -cd dist/ && zip -r ../chrome_extension.zip * -x "*.DS_Store" "web_manifest.json" "screenshots/*" "images/*" "favicon.ico" "robots.txt" "base.manifest.json" "chrome.manifest.json" "firefox.manifest.json" && cd .. \ No newline at end of file +cd dist/ && zip -r ../chrome_extension.zip * -x "*.DS_Store" "web_manifest.json" "screenshots/*" "images/*" "robots.txt" "base.manifest.json" "chrome.manifest.json" "firefox.manifest.json" && cd .. \ No newline at end of file diff --git a/script/build-firefox.sh b/script/build-firefox.sh index f6b06f8..5798d50 100755 --- a/script/build-firefox.sh +++ b/script/build-firefox.sh @@ -27,7 +27,7 @@ yarn build:ext # Zip the distribution folder echo 'Zip the extension' -cd dist/ && zip -r ../firefox_extension.zip * -x "*.DS_Store" "web_manifest.json" "screenshots/*" "images/*" "favicon.ico" "robots.txt" "base.manifest.json" "chrome.manifest.json" "firefox.manifest.json" && cd .. +cd dist/ && zip -r ../firefox_extension.zip * -x "*.DS_Store" "web_manifest.json" "screenshots/*" "images/*" "robots.txt" "base.manifest.json" "chrome.manifest.json" "firefox.manifest.json" && cd .. # echo 'Zip the source code'