22import { getCollection , render } from " astro:content" ;
33import BaseLayout from " ../../layouts/BaseLayout.astro" ;
44import BlogPostLayout from " ../../layouts/BlogPostLayout.astro" ;
5+ import RecommendedPosts from " ../../components/RecommendedPosts.astro" ;
56import {
67 DEFAULT_AUTHOR_NAME ,
78 DEFAULT_AVATAR ,
89 formatLongDate ,
910 getAuthorAvatar ,
1011 getAuthorNames ,
1112 getPostSlug ,
13+ getRecommendedPosts ,
1214 SITE_DEFAULT_IMAGE ,
1315} from " ../../lib/posts" ;
1416
@@ -25,12 +27,14 @@ export async function getStaticPaths() {
2527
2628const { post } = Astro .props ;
2729const { title, date, image } = post .data ;
30+ const slug = getPostSlug (post );
2831const formattedDate = formatLongDate (date );
2932const description = ` Escrito em ${formattedDate } ` ;
30- const canonical = ` https://blog.lucis.dev/blog/${getPostSlug ( post ) } ` ;
33+ const canonical = ` https://blog.lucis.dev/blog/${slug } ` ;
3134const hasImage = Boolean (image ?.trim ());
3235
3336const { Content } = await render (post );
37+ const recommended = await getRecommendedPosts (slug , 3 );
3438
3539const authorName = getAuthorNames (post ) || DEFAULT_AUTHOR_NAME ;
3640const authorAvatar = getAuthorAvatar (post ) || DEFAULT_AVATAR ;
@@ -58,6 +62,28 @@ const jsonLd = {
5862>
5963 <article class =" w-full flex flex-col gap-20 container mx-auto px-4 md:px-0 py-12 lg:py-12 bg-white" >
6064 <div class =" w-full flex flex-col gap-12 max-w-3xl lg:mx-auto" >
65+ <a
66+ href =" /"
67+ class =" inline-flex items-center text-sm text-gray-600 hover:text-black transition-colors w-fit"
68+ aria-label =" Voltar para a home"
69+ >
70+ <svg
71+ xmlns =" http://www.w3.org/2000/svg"
72+ class =" h-6 w-6 mr-2"
73+ fill =" none"
74+ viewBox =" 0 0 24 24"
75+ stroke =" currentColor"
76+ aria-hidden =" true"
77+ >
78+ <path
79+ stroke-linecap =" round"
80+ stroke-linejoin =" round"
81+ stroke-width =" 2"
82+ d =" M10 19l-7-7m0 0l7-7m-7 7h18" ></path >
83+ </svg >
84+ <span >Home</span >
85+ </a >
86+
6187 <h1 class =" text-5xl font-bold font-serif" >{ title } </h1 >
6288 <div class =" flex items-center gap-4" >
6389 <img
@@ -90,5 +116,7 @@ const jsonLd = {
90116 <BlogPostLayout >
91117 <Content />
92118 </BlogPostLayout >
119+
120+ <RecommendedPosts posts ={ recommended } />
93121 </article >
94122</BaseLayout >
0 commit comments