Skip to content

Commit

Permalink
feat: add view transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
valcosmos committed Oct 9, 2024
1 parent e920373 commit 118a935
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 46 deletions.
94 changes: 49 additions & 45 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from 'next'
import type { AnalyticsConfig } from 'pliny/analytics'
import type { SearchConfig } from 'pliny/search'
import { ViewTransitions } from 'next-view-transitions'

// import process from 'node:process'
import Footer from '@/components/Footer'
Expand Down Expand Up @@ -66,50 +67,53 @@ export default function RootLayout({ children }: { children: React.ReactNode })
const basePath = process.env.BASE_PATH || ''

return (
<html
lang={siteMetadata.language}
className={`${space_grotesk.variable} scroll-smooth`}
suppressHydrationWarning
>
<link
rel="apple-touch-icon"
sizes="76x76"
href={`${basePath}/static/favicons/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href={`${basePath}/static/favicons/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href={`${basePath}/static/favicons/favicon-16x16.png`}
/>
<link rel="manifest" href={`${basePath}/static/favicons/site.webmanifest`} />
<link
rel="mask-icon"
href={`${basePath}/static/favicons/safari-pinned-tab.svg`}
color="#5bbad5"
/>
<meta name="msapplication-TileColor" content="#000000" />
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fff" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000" />
<link rel="alternate" type="application/rss+xml" href={`${basePath}/feed.xml`} />
<body className="bg-white pl-[calc(100vw-100%)] text-black antialiased dark:bg-gray-950 dark:text-white">
<ThemeProviders>
<Analytics analyticsConfig={siteMetadata.analytics as AnalyticsConfig} />
<SectionContainer>
<SearchProvider searchConfig={siteMetadata.search as SearchConfig}>
<Header />
<main className="mb-auto">{children}</main>
</SearchProvider>
<Footer />
</SectionContainer>
</ThemeProviders>
</body>
</html>
<ViewTransitions>

<html
lang={siteMetadata.language}
className={`${space_grotesk.variable} scroll-smooth`}
suppressHydrationWarning
>
<link
rel="apple-touch-icon"
sizes="76x76"
href={`${basePath}/static/favicons/apple-touch-icon.png`}
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href={`${basePath}/static/favicons/favicon-32x32.png`}
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href={`${basePath}/static/favicons/favicon-16x16.png`}
/>
<link rel="manifest" href={`${basePath}/static/favicons/site.webmanifest`} />
<link
rel="mask-icon"
href={`${basePath}/static/favicons/safari-pinned-tab.svg`}
color="#5bbad5"
/>
<meta name="msapplication-TileColor" content="#000000" />
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#fff" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#000" />
<link rel="alternate" type="application/rss+xml" href={`${basePath}/feed.xml`} />
<body className="bg-white pl-[calc(100vw-100%)] text-black antialiased dark:bg-gray-950 dark:text-white">
<ThemeProviders>
<Analytics analyticsConfig={siteMetadata.analytics as AnalyticsConfig} />
<SectionContainer>
<SearchProvider searchConfig={siteMetadata.search as SearchConfig}>
<Header />
<main className="mb-auto">{children}</main>
</SearchProvider>
<Footer />
</SectionContainer>
</ThemeProviders>
</body>
</html>
</ViewTransitions>
)
}
3 changes: 2 additions & 1 deletion components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { LinkProps } from 'next/link'
import type { AnchorHTMLAttributes } from 'react'
import Link from 'next/link'
// import Link from 'next/link'
import { Link } from 'next-view-transitions'

function CustomLink({ href, ...rest }: LinkProps & AnchorHTMLAttributes<HTMLAnchorElement>) {
const isInternalLink = href && href.startsWith('/')
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"next": "14.2.14",
"next-contentlayer2": "0.5.1",
"next-themes": "^0.3.0",
"next-view-transitions": "^0.3.2",
"pliny": "0.3.2",
"postcss": "^8.4.47",
"react": "18.3.1",
Expand Down
16 changes: 16 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 118a935

Please sign in to comment.