Skip to content

Commit 5fb7488

Browse files
committed
feat: ✨ add view transition
1 parent f4a50cf commit 5fb7488

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/components/BaseHead.astro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Import the global.css file here so that it is included on
33
// all pages through the use of the <BaseHead /> component.
44
import { useMiSans } from '@config';
5+
import { ClientRouter } from 'astro:transitions';
56
import '@styles/global.css';
67
import '@styles/prism-tomorrow.min.css';
78
import 'uno.css';
@@ -41,6 +42,8 @@ const { title, description, image = '/头像方.png' } = Astro.props;
4142
<meta property="twitter:description" content={description} />
4243
<meta property="twitter:image" content={new URL(image, Astro.url)} />
4344

45+
<ClientRouter />
46+
4447
{
4548
useMiSans && (
4649
<link

src/components/Comments.astro

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,18 @@
9595
</script> -->
9696

9797
<script>
98-
import { init } from 'sodesu-comment';
98+
import { init as sodesuInit } from 'sodesu-comment';
9999

100-
init({
101-
el: '#comment-container',
102-
serverURL: 'https://waline.penclub.club/',
103-
dark: 'html.dark',
104-
pageview: !import.meta.env.DEV,
105-
commentClassName: 'prose prose-neutral dark:prose-invert min-w-0 max-w-none',
106-
});
100+
function init() {
101+
return sodesuInit({
102+
el: '#comment-container',
103+
serverURL: 'https://waline.penclub.club/',
104+
dark: 'html.dark',
105+
pageview: !import.meta.env.DEV,
106+
commentClassName: 'prose prose-neutral dark:prose-invert min-w-0 max-w-none',
107+
});
108+
}
109+
110+
document.addEventListener('astro:page-load', init);
107111
</script>
108112
</div>

src/layouts/BaseLayout.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const { title = SITE_TITLE, description = SITE_DESCRIPTION, image = '/头像方.
2020
<Header />
2121
<main class="flex flex-col-reverse lg:flex-row">
2222
<SideBarLeft />
23-
<div class="flex-auto min-w-0 mt-4 lg:(mt-0 ml-4)">
23+
<div class="flex-auto min-w-0 mt-4 lg:(mt-0 ml-4)" transition:name="main">
2424
<slot />
2525
<Comments />
2626
</div>

0 commit comments

Comments
 (0)