chore(utils): getWebSiteInfo -> getSiteInfo
This commit is contained in:
parent
d5c3847f94
commit
2253e8293f
3 changed files with 12 additions and 12 deletions
|
@ -3,15 +3,15 @@ import { Globe2Icon } from 'lucide-react'
|
|||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/Avatar'
|
||||
import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/HoverCard'
|
||||
import { Button } from '@/components/ui/Button'
|
||||
import { getWebSiteInfo } from '@/utils'
|
||||
import { getSiteInfo } from '@/utils'
|
||||
|
||||
const Header: FC = () => {
|
||||
const websiteInfo = getWebSiteInfo()
|
||||
const siteInfo = getSiteInfo()
|
||||
|
||||
return (
|
||||
<div className="z-10 grid h-12 grid-flow-col items-center justify-between gap-x-4 rounded-t-xl bg-white px-4 backdrop-blur-lg">
|
||||
<Avatar className="h-8 w-8">
|
||||
<AvatarImage src={websiteInfo.icon} alt="favicon" />
|
||||
<AvatarImage src={siteInfo.icon} alt="favicon" />
|
||||
<AvatarFallback>
|
||||
<Globe2Icon size="100%" className="text-gray-400" />
|
||||
</AvatarFallback>
|
||||
|
@ -20,22 +20,22 @@ const Header: FC = () => {
|
|||
<HoverCardTrigger asChild>
|
||||
<Button className="overflow-hidden" variant="link">
|
||||
<span className="truncate text-lg font-medium text-slate-600">
|
||||
{websiteInfo.hostname.replace(/^www\./i, '')}
|
||||
{siteInfo.hostname.replace(/^www\./i, '')}
|
||||
</span>
|
||||
</Button>
|
||||
</HoverCardTrigger>
|
||||
<HoverCardContent className="w-80">
|
||||
<div className="grid grid-cols-[auto_1fr] gap-x-4">
|
||||
<Avatar className="h-14 w-14">
|
||||
<AvatarImage src={websiteInfo.icon} alt="favicon" />
|
||||
<AvatarImage src={siteInfo.icon} alt="favicon" />
|
||||
<AvatarFallback>
|
||||
<Globe2Icon size="100%" className="text-gray-400" />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="grid items-center">
|
||||
<h4 className="truncate text-sm font-semibold">{websiteInfo.title}</h4>
|
||||
{websiteInfo.description && (
|
||||
<p className="line-clamp-2 max-h-8 text-xs text-slate-500">{websiteInfo.description}</p>
|
||||
<h4 className="truncate text-sm font-semibold">{siteInfo.title}</h4>
|
||||
{siteInfo.description && (
|
||||
<p className="line-clamp-2 max-h-8 text-xs text-slate-500">{siteInfo.description}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export interface WebSiteInfo {
|
||||
export interface SiteInfo {
|
||||
host: string
|
||||
hostname: string
|
||||
href: string
|
||||
|
@ -8,7 +8,7 @@ export interface WebSiteInfo {
|
|||
description: string
|
||||
}
|
||||
|
||||
const getWebSiteInfo = (): WebSiteInfo => {
|
||||
const getSiteInfo = (): SiteInfo => {
|
||||
return {
|
||||
host: document.location.host,
|
||||
hostname: document.location.hostname,
|
||||
|
@ -31,4 +31,4 @@ const getWebSiteInfo = (): WebSiteInfo => {
|
|||
}
|
||||
}
|
||||
|
||||
export default getWebSiteInfo
|
||||
export default getSiteInfo
|
|
@ -2,6 +2,6 @@ export { default as cn } from './cn'
|
|||
export { default as isInRange } from './isInRange'
|
||||
export { default as clamp } from './clamp'
|
||||
export { default as createElement } from './createElement'
|
||||
export { default as getWebSiteInfo } from './getWebSiteInfo'
|
||||
export { default as getSiteInfo } from './getSiteInfo'
|
||||
export { default as chunk } from './chunk'
|
||||
export { default as compressImage } from './compressImage'
|
||||
|
|
Loading…
Reference in a new issue