view transition updates #18
|
@ -20,16 +20,24 @@ const { post } = Astro.props;
|
|||
height={50}
|
||||
class="rounded-3xl mr-3"
|
||||
loading="eager"
|
||||
transition:animate={"fade"}
|
||||
transition:name={'author:' + post.author.profilePicture}
|
||||
/>
|
||||
<div class="mt-3 flex">
|
||||
<span>{post.author.name}</span>
|
||||
<span transition:animate={"fade"}
|
||||
transition:name={'author:' + post.author.name}
|
||||
>{post.author.name}</span>
|
||||
<span class="mx-3 block font-bold text-slate-500">.</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-5 flex w-full flex-row items-center justify-center md:mb-0 md:w-auto md:justify-start" >
|
||||
<span>{getFormattedDate(post.publishedAt)}</span>
|
||||
<span transition:animate={"fade"}
|
||||
transition:name={'hero:' + post.publishedAt}
|
||||
>{getFormattedDate(post.publishedAt)}</span>
|
||||
<span class="mx-3 block font-bold text-slate-500">.</span>
|
||||
<span>{post.readTimeInMinutes} min read</span>
|
||||
<span transition:animate={"fade"}
|
||||
transition:name={'hero:' + post.readTimeInMinutes}
|
||||
>{post.readTimeInMinutes} min read</span>
|
||||
</div>
|
||||
</div>
|
|
@ -7,6 +7,27 @@ const aboutPageData = await getAboutPage();
|
|||
|
||||
const baseURL = import.meta.env.BASE_URL;
|
||||
|
||||
const pathname = new URL(Astro.request.url).pathname;
|
||||
|
||||
// remove leading and trailing slash
|
||||
const removeTrailingAndLeadingSlash = (str:string) => {
|
||||
// define checked string as the original string
|
||||
let checkedStr = str;
|
||||
|
||||
// remove leading slash
|
||||
if (str.startsWith("/")) {
|
||||
checkedStr = str.slice(1);
|
||||
}
|
||||
// remove trailing slash
|
||||
if (str.endsWith("/")) {
|
||||
checkedStr = str.slice(0, -1);
|
||||
}
|
||||
// return checked string
|
||||
return checkedStr;
|
||||
}
|
||||
|
||||
const currentPath = removeTrailingAndLeadingSlash(pathname);
|
||||
|
||||
---
|
||||
<header class="flex bg-blue-200 w-full p-3">
|
||||
<h1 class="text-2xl">
|
||||
|
@ -35,8 +56,22 @@ const baseURL = import.meta.env.BASE_URL;
|
|||
</a>
|
||||
</h1>
|
||||
<div class="ml-5 pt-0.5 text-lg">
|
||||
<a class="mr-3" href={baseURL}>Home</a>
|
||||
<a class="mr-3" href={`${baseURL}blog`}>Blog</a>
|
||||
{aboutPageData && <a href={`${baseURL}blog/about/`}>About</a>}
|
||||
<a
|
||||
class=`mr-3 ${currentPath === "" ? "font-bold" : ""}`
|
||||
href={baseURL}
|
||||
>Home
|
||||
</a>
|
||||
<a
|
||||
class=`mr-3 ${currentPath === "blog" ? "font-bold" : ""}`
|
||||
href={`${baseURL}blog`}
|
||||
>Blog
|
||||
</a>
|
||||
{ aboutPageData && (
|
||||
<a
|
||||
class=`mr-3 ${currentPath === "blog/about" ? "font-bold" : ""}`
|
||||
href={`${baseURL}blog/about`}
|
||||
>About
|
||||
</a>
|
||||
) }
|
||||
</div>
|
||||
</header>
|
||||
|
|
|
@ -26,6 +26,7 @@ const p = await getPost(post.slug);
|
|||
src={p.coverImage.url}
|
||||
alt={post.title}
|
||||
inferSize={true}
|
||||
transition:name={'hero:' + p.coverImage.url}
|
||||
/>
|
||||
<div class="flex flex-col m-4">
|
||||
<p class="mb-2 text-lg">{post.brief}</p>
|
||||
|
|
|
@ -62,7 +62,7 @@ const { pageTitle, hideFooter, hideHeader, ogImage } = Astro.props as AstroHashn
|
|||
</head>
|
||||
<body>
|
||||
<div class="flex flex-col">
|
||||
{!hideHeader && <Header />}
|
||||
{!hideHeader && <Header transition:animate="none" />}
|
||||
<div class="flex flex-wrap flex-col mt-0 mr-auto mb-0 ml-auto lg:w-[60%]">
|
||||
<slot />
|
||||
</div>
|
||||
|
|
|
@ -28,6 +28,7 @@ const post = await getPost(slug);
|
|||
alt={post.title}
|
||||
inferSize={true}
|
||||
loading="eager"
|
||||
transition:name={'hero:' + post.coverImage.url}
|
||||
/>
|
||||
<h1 class="text-4xl font-bold pt-5">{post.title}</h1>
|
||||
<h2 class="text-xl pt-3 pb-3" aria-label="CoverPhoto Subtitle">{post.subtitle}</h2>
|
||||
|
|
|
@ -27,6 +27,7 @@ const post = await getPost(checkSlug(slug));
|
|||
alt={post.title}
|
||||
inferSize={true}
|
||||
loading="eager"
|
||||
transition:name={'hero:' + post.coverImage.url}
|
||||
/>
|
||||
<h1 class="text-4xl font-bold pt-5">{post.title}</h1>
|
||||
<h2 class="text-xl pt-3 pb-3" aria-label="CoverPhoto Subtitle">{post.subtitle}</h2>
|
||||
|
|
Loading…
Reference in New Issue