Merge pull request #590 from omnivore-app/clean-domain-name

Remove www. from the siteName
This commit is contained in:
Hongbo Wu
2022-05-12 11:03:19 +08:00
committed by GitHub
5 changed files with 11 additions and 3 deletions

View File

@ -1384,6 +1384,7 @@ export type SearchItem = {
readingProgressAnchorIndex?: Maybe<Scalars['Int']>;
readingProgressPercent?: Maybe<Scalars['Float']>;
shortId?: Maybe<Scalars['String']>;
siteName?: Maybe<Scalars['String']>;
slug: Scalars['String'];
state?: Maybe<ArticleSavingRequestStatus>;
subscription?: Maybe<Scalars['String']>;
@ -3384,6 +3385,7 @@ export type SearchItemResolvers<ContextType = ResolverContext, ParentType extend
readingProgressAnchorIndex?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
readingProgressPercent?: Resolver<Maybe<ResolversTypes['Float']>, ParentType, ContextType>;
shortId?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
siteName?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
slug?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
state?: Resolver<Maybe<ResolversTypes['ArticleSavingRequestStatus']>, ParentType, ContextType>;
subscription?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;

View File

@ -991,6 +991,7 @@ type SearchItem {
readingProgressAnchorIndex: Int
readingProgressPercent: Float
shortId: String
siteName: String
slug: String!
state: ArticleSavingRequestStatus
subscription: String

View File

@ -1438,6 +1438,7 @@ const schema = gql`
unsubMailTo: String
unsubHttpUrl: String
state: ArticleSavingRequestStatus
siteName: String
}
type SearchItemEdge {

View File

@ -6,16 +6,18 @@ import { PageType } from '../../../lib/networking/fragments/articleFragment'
const siteName = (originalArticleUrl: string, itemUrl: string): string => {
try {
return new URL(originalArticleUrl).hostname
return new URL(originalArticleUrl).hostname.replace(/^www\./, '')
} catch {}
try {
return new URL(itemUrl).hostname
return new URL(itemUrl).hostname.replace(/^www\./, '')
} catch {}
return ''
}
export function LinkedItemCard(props: LinkedItemCardProps): JSX.Element {
const originText = siteName(props.item.originalArticleUrl, props.item.url)
const originText =
props.item.siteName ||
siteName(props.item.originalArticleUrl, props.item.url)
if (props.item.pageType === PageType.HIGHLIGHTS) {
return <HighlightItemCard {...props} />

View File

@ -75,6 +75,7 @@ export type LibraryItemNode = {
annotation: string
state: State
pageType: PageType
siteName?: string
}
export type PageInfo = {
@ -125,6 +126,7 @@ export function useGetLibraryItemsQuery({
quote
annotation
state
siteName
}
}
pageInfo {