feat(blog): add additional frontmatter fields for dates, authors, image, draft
Add additional frontmatter fields and display the data on the blog page and the individual blogposts
7
.astro/types.d.ts
vendored
@ -206,6 +206,13 @@ declare module 'astro:content' {
|
||||
collection: "blog";
|
||||
data: InferEntrySchema<"blog">
|
||||
} & { render(): Render[".mdx"] };
|
||||
"this-is-a-draft.mdx": {
|
||||
id: "this-is-a-draft.mdx";
|
||||
slug: "this-is-a-draft";
|
||||
body: string;
|
||||
collection: "blog";
|
||||
data: InferEntrySchema<"blog">
|
||||
} & { render(): Render[".mdx"] };
|
||||
"top-10-ides-for-astrojs.mdx": {
|
||||
id: "top-10-ides-for-astrojs.mdx";
|
||||
slug: "top-10-ides-for-astrojs";
|
||||
|
||||
@ -1 +1 @@
|
||||
{ "src": { "assets": { "images": {} } } }
|
||||
{ "src": { "assets": { "images": {} }, "pages": { "blog": {} } } }
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
---
|
||||
title: '10 Essential Web Development Tools'
|
||||
description: 'Discover the must-have tools that will take your web development skills to the next level and help you create websites that shine in the digital landscape.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-03'
|
||||
dateModified: '2024-03-04'
|
||||
image: './10-essential-web-development-tools-for-building-stunning-websites.png'
|
||||
---
|
||||
|
||||
Are you ready to elevate your web development game and build stunning websites that captivate your audience? In this blog post, we're diving into the world of web development tools that are essential for creating top-notch websites. From front-end tools that help you craft interactive user interfaces to backend tools that ensure seamless functionality, we've got you covered. Discover how optimization tools can boost your website's performance, visual design tools can make your site stand out, and collaborative tools can streamline your projects for maximum efficiency. Stay tuned as we unveil the must-have tools that will take your web development skills to the next level and help you create websites that shine in the digital landscape
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Benefits of Headless CMS: Development with Directus'
|
||||
description: 'Discover how Directus flexibility, scalability, and omnichannel content delivery can enhance your web projects.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-08'
|
||||
image: './benefits-of-headless-cms-development-with-directus.png'
|
||||
---
|
||||
|
||||
In the ever-evolving world of web development, finding the right tools to streamline content management while delivering a seamless user experience is paramount. Enter the realm of Headless Content Management Systems (CMS), where Directus stands out as a beacon of flexibility and efficiency. This blog post delves into the myriad benefits of adopting Directus for your headless CMS needs.
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Comparing MVC Frameworks'
|
||||
description: 'A detailed comparison of popular MVC frameworks and their use cases in web development.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-04'
|
||||
image: './comparing-mvc-frameworks.png'
|
||||
---
|
||||
|
||||
When it comes to web development, choosing the right framework can make all the difference. MVC (Model-View-Controller) frameworks have become a popular choice due to their structured approach to building applications. This blog post dives into some of the most popular MVC frameworks, comparing their features, performance, and use cases to help you make an informed decision.
|
||||
|
||||
BIN
src/content/blog/comparing-mvc-frameworks.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: Debugging Tips for Astro.js Applications
|
||||
description: 'Learn efficient debugging techniques tailored for Astro.js apps.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-10'
|
||||
image: './debugging-tips-for-astrojs.png'
|
||||
---
|
||||
|
||||
Debugging is an essential skill for developers, and when working with Astro.js applications, having efficient debugging techniques can save you time and frustration. In this blog post, we will explore some valuable tips to help you debug your Astro.js projects effectively.
|
||||
|
||||
BIN
src/content/blog/debugging-tips-for-astrojs.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Dockerizing Front-End Development'
|
||||
description: 'A comprehensive guide on Dockerizing front-end development environments for consistent and portable setups.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-04'
|
||||
image: './dockerizing-front-end-development.png'
|
||||
---
|
||||
|
||||
In the dynamic world of front-end development, ensuring consistency and portability across different environments can often be a challenge. Docker, a powerful tool for creating, deploying, and running applications by using containers, offers a solution to this problem. This blog post delves into the nitty-gritty of dockerizing your front-end development environment to enhance productivity and ensure a seamless workflow.
|
||||
|
||||
BIN
src/content/blog/dockerizing-front-end-development.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,10 @@
|
||||
---
|
||||
title: 'Essential Frontend Tools for Astro.js Developers'
|
||||
description: 'Discover the essential frontend tools every Astro.js developer should consider integrating into their development process.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-03'
|
||||
dateModified: '2024-03-04'
|
||||
image: './essential-frontend-tools-for-astro-js-developers.png'
|
||||
---
|
||||
|
||||
Astro.js has rapidly become a favorite among developers for building fast, modern web applications. Its unique approach to loading only the necessary JavaScript has paved the way for optimized performance and better user experiences. As an Astro.js developer, having a toolkit filled with essential frontend tools can significantly streamline your workflow and enhance your project's quality. In this blog post, we'll explore those indispensable tools every Astro.js developer should consider integrating into their development process.
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,10 @@
|
||||
---
|
||||
title: 'Exploring the Latest Node.js Development Trends in 2024'
|
||||
description: 'Explore the latest trends in Node.js development that are shaping the future of web and application development.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-03'
|
||||
dateModified: '2024-03-04'
|
||||
image: './exploring-nodejs-development-trends-2024.png'
|
||||
---
|
||||
|
||||
The landscape of Node.js development is always evolving, with each year bringing new trends, tools, and best practices. As we delve into 2024, it's crucial for developers and businesses alike to stay ahead of the curve. In this blog post, we'll explore the latest trends in Node.js development that are shaping the future of web and application development.
|
||||
|
||||
BIN
src/content/blog/exploring-nodejs-development-trends-2024.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: Getting Started with Astro.js
|
||||
description: An introductory guide to Astro.js, setting up your development environment.
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-10'
|
||||
image: './getting-started-with-astrojs.png'
|
||||
---
|
||||
|
||||
Welcome to the world of Astro.js, where building fast, modern websites is more accessible than ever before! Whether you're a seasoned web developer or just dipping your toes into web development, Astro.js offers a unique approach to building websites that are performant, SEO-friendly, and enjoyable to create. In this beginner's guide, we'll walk you through the basics of Astro.js, setting up your development environment, and crafting your first page. Let's dive in!
|
||||
|
||||
BIN
src/content/blog/getting-started-with-astrojs.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Mastering Markdown: A Guide to Essential Elements'
|
||||
description: 'Master the essential Markdown elements to create engaging, well-structured content. Learn headings, emphasis, lists, links, and more.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-04-07'
|
||||
image: './mastering-markdown.png'
|
||||
---
|
||||
|
||||
Markdown is a lightweight markup language that allows you to format text easily and quickly. It's widely used for creating web content, documentation, and even books. In this blog post, we'll explore some of the essential Markdown elements that you can use to create engaging and well-structured content.
|
||||
|
||||
BIN
src/content/blog/mastering-markdown.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Introduction to Modern Web Frameworks'
|
||||
description: "A beginner's guide to understanding the purpose and advantages of modern web frameworks."
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-04'
|
||||
image: './modern-web-frameworks-introduction.png'
|
||||
---
|
||||
|
||||
Welcome to the world of web development, where the landscape is constantly evolving, and the tools at a developer's disposal are more powerful than ever. If you're just starting out, or if you're curious about what modern web frameworks have to offer, you've come to the right place.
|
||||
|
||||
BIN
src/content/blog/modern-web-frameworks-introduction.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
10
src/content/blog/this-is-a-draft.mdx
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
title: 'Untitled'
|
||||
description: 'Untitled'
|
||||
datePublished: '2024-04-11'
|
||||
isDraft: true
|
||||
---
|
||||
|
||||
# Untitled
|
||||
|
||||
The `isDraft` field is a boolean field that you can use to mark a post as a draft. When set to `true` , the post won't be rendered in production. This is useful when you're working on a post and you don't want it to be published yet.
|
||||
@ -1,6 +1,9 @@
|
||||
---
|
||||
title: 'Top 10 IDEs for Astro.js Development'
|
||||
description: 'Explore the best integrated development environments for Astro.js projects.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-10'
|
||||
image: './top-10-ides-for-astrojs.png'
|
||||
---
|
||||
|
||||
When working on Astro.js projects, having the right Integrated Development Environment (IDE) can significantly boost productivity and streamline the development process. In this blog post, we will explore the top 10 IDEs that are well-suited for Astro.js development.
|
||||
|
||||
BIN
src/content/blog/top-10-ides-for-astrojs.png
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -1,44 +1,97 @@
|
||||
---
|
||||
title: 'Unleashing the Power of Astro.js'
|
||||
description: 'Explore the wonders of Astro.js, a transformative tool reshaping web development.'
|
||||
author: [{ type: 'Person', name: 'Jewgeni', url: 'https://deployn.de' }]
|
||||
datePublished: '2024-03-03'
|
||||
dateModified: '2024-04-11'
|
||||
image: './unleasing-the-power-of-astro-js-for-better-web-development.png'
|
||||
---
|
||||
|
||||
Welcome to an exciting exploration of Astro.js, a transformative tool reshaping web development. This blog post takes you through the wonders of Astro.js, showcasing its ability to boost website performance and introduce unparalleled versatility in modern applications.
|
||||
## Introduction
|
||||
|
||||
Whether you're deep into development or just starting, this guide illuminates Astro.js's potential to refine your web development process.
|
||||
Welcome to an exciting and immersive exploration of Astro.js, a transformative tool that is revolutionizing the world of web development. In this comprehensive blog post, we will take you on a deep dive into the wonders of Astro.js, showcasing its remarkable ability to supercharge website performance and introduce unparalleled versatility in modern applications.
|
||||
|
||||
Whether you're a seasoned developer with years of experience under your belt or just embarking on your web development journey, this guide will illuminate the incredible potential of Astro.js and how it can streamline and enhance your development process.
|
||||
|
||||
## Understanding the Magic Behind Astro.js
|
||||
|
||||
Astro.js stands out by merging static and dynamic content, enabling instant loading with dynamic capabilities. This blend not only optimizes performance but simplifies development, focusing on user interface excellence without sacrificing speed.
|
||||
What sets Astro.js apart from other web development tools is its unique ability to seamlessly merge static and dynamic content, enabling instant loading while still providing dynamic capabilities. This powerful blend not only optimizes performance but also simplifies the development process, allowing you to focus on crafting exceptional user interfaces without compromising on speed.
|
||||
|
||||
By pre-rendering pages server-side, Astro reduces client-side load, offering swift, responsive websites. Its flexible architecture supports various front-end frameworks, allowing for creative freedom while leveraging Astro.js’s benefits.
|
||||
By leveraging server-side pre-rendering, Astro.js significantly reduces the burden on the client-side, resulting in lightning-fast, responsive websites. Its flexible architecture supports a wide range of front-end frameworks, giving you the freedom to unleash your creativity while still harnessing the benefits of Astro.js.
|
||||
|
||||
Here's a simple example of how you can create a basic Astro.js component:
|
||||
|
||||
```astro
|
||||
---
|
||||
const name = 'John Doe';
|
||||
---
|
||||
|
||||
<h1>Hello, {name}!</h1>
|
||||
```
|
||||
|
||||
## Optimizing Website Performance with Astro.js
|
||||
|
||||
Astro.js excels in speeding up loading times by pre-rendering pages and serving static assets. This approach minimizes server load and bandwidth, enhancing user experience.
|
||||
One of the key strengths of Astro.js lies in its ability to dramatically improve website loading times by pre-rendering pages and efficiently serving static assets. This approach minimizes server load and bandwidth usage, ultimately enhancing the user experience and ensuring a smooth, seamless browsing experience.
|
||||
|
||||
Its component-based architecture ensures modularity and reusability, streamlining development and boosting performance. The hybrid rendering model strikes a balance between speed and interactivity, providing users with a seamless browsing experience.
|
||||
Astro.js's component-based architecture promotes modularity and reusability, streamlining the development process and boosting overall performance. The hybrid rendering model strikes the perfect balance between speed and interactivity, delivering users a fast and engaging experience across all devices.
|
||||
|
||||
## Harnessing the Benefits of Astro.js for Web Development
|
||||
|
||||
Astro.js optimizes workflows with its focus on performance. It avoids the pitfalls of heavy JavaScript frameworks, ensuring quick loads and smooth operation across devices.
|
||||
Astro.js is a game-changer when it comes to optimizing workflows and maximizing performance. By avoiding the pitfalls of heavy JavaScript frameworks, Astro.js ensures quick loading times and smooth operation across a wide range of devices, from desktop computers to mobile phones.
|
||||
|
||||
Its modular, component-based design encourages reusability and consistency, simplifying maintenance. Astro.js also offers a unified build system, reducing complexity and potential errors from disparate technologies.
|
||||
The modular, component-based design of Astro.js encourages code reusability and maintains consistency throughout your projects, simplifying maintenance and reducing development time. Additionally, Astro.js offers a unified build system that reduces complexity and minimizes potential errors arising from disparate technologies.
|
||||
|
||||
Here's an example of how you can import and use components in Astro.js:
|
||||
|
||||
```astro
|
||||
---
|
||||
import Header from '../components/Header.astro';
|
||||
import Footer from '../components/Footer.astro';
|
||||
---
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<Header />
|
||||
<main>
|
||||
<!-- Page content goes here -->
|
||||
</main>
|
||||
<Footer />
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Exploring the Versatility of Astro.js in Modern Applications
|
||||
|
||||
Astro.js's modular architecture fits various projects and adapts to different use cases, from web applications to mobile apps. Its rich feature set supports a broad range of functionalities, enhanced by a well-documented API and plugin library.
|
||||
One of the standout features of Astro.js is its incredible versatility. Its modular architecture allows it to seamlessly adapt to various project requirements and use cases, whether you're building web applications, mobile apps, or anything in between. With a rich set of features and a well-documented API, Astro.js empowers developers to create highly functional and interactive applications.
|
||||
|
||||
Performance and optimization are central to Astro.js, ensuring applications are fast, responsive, and lightweight.
|
||||
Performance and optimization are at the core of Astro.js, ensuring that your applications are fast, responsive, and lightweight. The extensive plugin library further expands the capabilities of Astro.js, enabling you to integrate additional functionalities and tailor your projects to specific needs.
|
||||
|
||||
Here's an example of how you can use Astro.js with a popular front-end framework like React:
|
||||
|
||||
```astro
|
||||
---
|
||||
import { ReactComponent } from '../components/ReactComponent.jsx';
|
||||
---
|
||||
|
||||
<html>
|
||||
<body>
|
||||
<ReactComponent client:load />
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Pro Tips for Maximizing the Potential of Astro.js
|
||||
|
||||
- **Optimize Your Build Process**: Utilize partial hydration and code splitting for efficient builds.
|
||||
- **Utilize Static Site Generation**: Leverage static generation for performance optimization in content-heavy sites.
|
||||
- **Experiment with Component Composition**: Mix components from different libraries to meet project needs.
|
||||
- **Implement Server-Side Rendering**: Use server-side rendering for SEO and interactive components.
|
||||
- **Stay Updated with the Latest Features**: Keep abreast of Astro.js updates to fully utilize its capabilities.
|
||||
- **Optimize Your Build Process**: Utilize partial hydration and code splitting techniques to create efficient builds that load only the necessary components, reducing overall bundle size and improving performance.
|
||||
- **Utilize Static Site Generation**: For content-heavy websites, take advantage of Astro.js's static site generation capabilities. By pre-rendering pages at build time, you can achieve lightning-fast loading speeds and optimize performance.
|
||||
- **Experiment with Component Composition**: Astro.js allows you to mix and match components from different libraries and frameworks. Don't be afraid to experiment with component composition to find the perfect combination that meets your project's unique requirements.
|
||||
- **Implement Server-Side Rendering**: When dealing with dynamic content or components that require server-side rendering for SEO purposes, Astro.js has you covered. Utilize server-side rendering to ensure that your pages are properly indexed by search engines and provide a seamless user experience.
|
||||
- **Stay Updated with the Latest Features**: Astro.js is constantly evolving, with new features and improvements being added regularly. Keep yourself informed about the latest updates and explore how you can leverage them to enhance your projects and stay ahead of the curve.
|
||||
|
||||
## Conclusion
|
||||
|
||||
Astro.js is a transformative tool for web developers, enhancing performance and offering versatile solutions for modern applications. This exploration has shown how Astro.js can streamline your development process, encouraging you to leverage its full potential for greater project success.
|
||||
Astro.js is a transformative tool that is revolutionizing the world of web development. By enhancing performance, offering versatile solutions for modern applications, and simplifying the development process, Astro.js empowers developers to create exceptional digital experiences.
|
||||
|
||||
Through this immersive exploration, we have shed light on the incredible potential of Astro.js and how it can streamline your workflow, boost website speed, and introduce unparalleled flexibility in your projects. Armed with this knowledge and the pro tips provided, you are now equipped to leverage the full power of Astro.js and take your web development skills to new heights.
|
||||
|
||||
Embrace the future of web development with Astro.js and embark on a journey of innovation, performance optimization, and boundless creativity. The possibilities are endless, and the impact you can make is truly remarkable.
|
||||
|
||||
|
After Width: | Height: | Size: 3.0 MiB |
@ -2,9 +2,29 @@ import { z, defineCollection } from 'astro:content';
|
||||
|
||||
const blogCollection = defineCollection({
|
||||
type: 'content',
|
||||
schema: z.object({
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
isDraft: z.boolean().optional(),
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
author: z
|
||||
.array(
|
||||
z.object({
|
||||
type: z.string().default('Person'),
|
||||
name: z.string(),
|
||||
url: z.string().url().optional(),
|
||||
})
|
||||
)
|
||||
.optional(),
|
||||
datePublished: z
|
||||
.string()
|
||||
.transform((str) => new Date(str))
|
||||
.optional(),
|
||||
dateModified: z
|
||||
.string()
|
||||
.transform((str) => new Date(str))
|
||||
.optional(),
|
||||
image: image().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@ -11,20 +11,47 @@ import {
|
||||
PaginationNext,
|
||||
PaginationPrevious,
|
||||
} from '@/components/ui/pagination';
|
||||
import { Image } from 'astro:assets';
|
||||
|
||||
interface BlogPost {
|
||||
data: {
|
||||
title: string;
|
||||
description: string;
|
||||
datePublished?: string;
|
||||
dateModified?: string;
|
||||
author?: [
|
||||
{
|
||||
type?: string;
|
||||
name: string;
|
||||
url?: string;
|
||||
},
|
||||
];
|
||||
image?: string;
|
||||
isDraft?: boolean;
|
||||
};
|
||||
slug: string;
|
||||
}
|
||||
|
||||
export async function getStaticPaths({ paginate }: { paginate: Function }) {
|
||||
const allBlogposts = await getCollection('blog');
|
||||
const postsPerPage = 4;
|
||||
const publishedBlogPosts: any = (post: BlogPost) => !post.data.isDraft;
|
||||
const sortedPosts = allBlogposts.filter(publishedBlogPosts).sort((a, b) => {
|
||||
const dateA = a.data.dateModified
|
||||
? new Date(a.data.dateModified)
|
||||
: a.data.datePublished
|
||||
? new Date(a.data.datePublished)
|
||||
: new Date(0);
|
||||
const dateB = b.data.dateModified
|
||||
? new Date(b.data.dateModified)
|
||||
: b.data.datePublished
|
||||
? new Date(b.data.datePublished)
|
||||
: new Date(0);
|
||||
return dateB.getTime() - dateA.getTime();
|
||||
});
|
||||
|
||||
return paginate(allBlogposts, {
|
||||
const postsPerPage = 6;
|
||||
|
||||
return paginate(sortedPosts, {
|
||||
pageSize: postsPerPage,
|
||||
});
|
||||
}
|
||||
@ -44,30 +71,89 @@ const {
|
||||
<BaseLayout
|
||||
title={`Blog Page ${page.currentPage} | Astro Deploy`}
|
||||
description="Explore insightful articles on our Blog: Dive into a world of knowledge through posts crafted with expertise. Discover, learn, and grow with us.">
|
||||
<div class="container mx-auto px-4 py-8 sm:py-12 lg:px-8 lg:py-16 xl:max-w-7xl">
|
||||
<div class="text-center text-zinc-800 dark:text-zinc-200">
|
||||
<div class="container mx-auto max-w-6xl px-4 py-12 sm:px-6 lg:px-8 lg:py-16">
|
||||
<div class="mb-12 text-center">
|
||||
<Heading level={1}>Blog</Heading>
|
||||
<Search />
|
||||
<p class="text-lg leading-relaxed text-zinc-600 dark:text-zinc-400">
|
||||
<p class="mt-4 text-xl text-zinc-600 dark:text-zinc-400">
|
||||
Here are some blogposts, they are located in the repository as mdx files.
|
||||
</p>
|
||||
</div>
|
||||
<hr class="my-8 border-t border-zinc-300 dark:border-zinc-700" />
|
||||
<div class="grid grid-cols-1 gap-8 md:grid-cols-2">
|
||||
<div class="grid grid-cols-1 gap-8 md:grid-cols-2 xl:grid-cols-3">
|
||||
{
|
||||
page.data.map((post) => (
|
||||
<div class="rotate-1 transform rounded-lg bg-white p-6 shadow-md transition-transform duration-300 hover:rotate-0 dark:bg-zinc-800">
|
||||
<div class="overflow-hidden rounded-lg bg-white p-6 shadow-lg transition duration-500 ease-in-out hover:-translate-y-1 hover:shadow-2xl dark:bg-zinc-800">
|
||||
{post.data.image && (
|
||||
<a href={`/blog/${post.slug}/`}>
|
||||
<Image
|
||||
src={post.data.image}
|
||||
alt={post.data.title}
|
||||
inferSize
|
||||
class="h-48 w-full object-cover transition duration-500 ease-in-out hover:scale-105"
|
||||
/>
|
||||
</a>
|
||||
)}
|
||||
<div class="p-6">
|
||||
<h2
|
||||
transition:name={post.data.title}
|
||||
class="mb-2 text-xl font-semibold text-zinc-800 hover:text-zinc-600 dark:text-zinc-200 dark:hover:text-zinc-400">
|
||||
class="mb-3 text-2xl font-bold leading-tight text-zinc-800 transition duration-300 ease-in-out hover:text-primary-600 dark:text-zinc-100 dark:hover:text-primary-400">
|
||||
<a href={`/blog/${post.slug}/`}>{post.data.title}</a>
|
||||
</h2>
|
||||
<p class="mb-4 text-sm text-zinc-600 dark:text-zinc-400">{post.data.description}</p>
|
||||
<div class="mb-4 text-sm text-zinc-600 dark:text-zinc-400">
|
||||
<div class="mb-2 flex flex-wrap items-center">
|
||||
{post.data.author && (
|
||||
<>
|
||||
<span class="mr-2">By</span>
|
||||
{post.data.author.map((author, index) => (
|
||||
<span class="mr-2">
|
||||
{author.url ? (
|
||||
<a
|
||||
class="text-primary-600 hover:text-primary-400 dark:text-primary-400 dark:hover:text-primary-300"
|
||||
href={`/blog/${post.slug}/`}>
|
||||
Read more
|
||||
href={author.url}
|
||||
class="font-medium text-primary-600 underline
|
||||
hover:text-primary-500 dark:text-primary-400 dark:hover:text-primary-300">
|
||||
{author.name}
|
||||
</a>
|
||||
) : (
|
||||
<span
|
||||
class="font-medium text-primary-600
|
||||
dark:text-primary-400 ">
|
||||
{author.name}
|
||||
</span>
|
||||
)}
|
||||
{post.data.author && index < post.data.author.length - 1 && (
|
||||
<span>, </span>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center">
|
||||
{post.data.datePublished && (
|
||||
<time datetime={post.data.datePublished} class="mr-4">
|
||||
<span class="mr-1">Published:</span>
|
||||
{new Date(post.data.datePublished).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
)}
|
||||
{post.data.dateModified && (
|
||||
<time datetime={post.data.dateModified}>
|
||||
<span class="mr-1">Updated:</span>
|
||||
{new Date(post.data.dateModified).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})}
|
||||
</time>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-zinc-600 dark:text-zinc-400">{post.data.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
}
|
||||
|
||||
@ -4,10 +4,13 @@ import type { CollectionEntry } from 'astro:content';
|
||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||
import Table from '@/components/blog/Table.astro';
|
||||
import '@/styles/prose.css';
|
||||
import { Image } from 'astro:assets';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getCollection('blog');
|
||||
return blogEntries.map((entry) => ({
|
||||
return blogEntries
|
||||
.filter((entry) => !entry.data.isDraft)
|
||||
.map((entry) => ({
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
}));
|
||||
@ -20,7 +23,23 @@ interface Props {
|
||||
const { entry } = Astro.props as Props;
|
||||
const { Content } = await entry.render();
|
||||
const components = { table: Table };
|
||||
const { title, description } = entry.data;
|
||||
const {
|
||||
title = '',
|
||||
description = '',
|
||||
author = [],
|
||||
datePublished = '',
|
||||
dateModified = '',
|
||||
image = '',
|
||||
} = entry.data;
|
||||
|
||||
const formatDate = (dateString: string) => {
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
});
|
||||
};
|
||||
|
||||
const descriptionMeta =
|
||||
description.length > 158 ? description.substring(0, 155) + '...' : description;
|
||||
@ -30,7 +49,51 @@ const descriptionMeta =
|
||||
<div
|
||||
class="container prose mx-auto px-4 py-16 dark:prose-invert lg:px-8 lg:py-32 xl:max-w-7xl"
|
||||
data-pagefind-body>
|
||||
<h1 transition:name={title} class="text-4xl font-bold">{title}</h1>
|
||||
<h1 class="text-4xl font-bold">{title}</h1>
|
||||
<div class="mt-2 text-sm text-gray-600">
|
||||
{
|
||||
author.length > 0 && (
|
||||
<span>
|
||||
By{' '}
|
||||
{author.map((a, index) => (
|
||||
<span>
|
||||
{a.url ? (
|
||||
<a href={a.url} target="_blank" rel="noopener noreferrer">
|
||||
{a.name}
|
||||
</a>
|
||||
) : (
|
||||
a.name
|
||||
)}
|
||||
{index < author.length - 1 ? ', ' : ''}
|
||||
</span>
|
||||
))}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
datePublished && (
|
||||
<span class="ml-2">Published on {formatDate(datePublished.toString())}</span>
|
||||
)
|
||||
}
|
||||
{
|
||||
dateModified && (
|
||||
<span class="ml-2">Last updated on {formatDate(dateModified.toString())}</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
{
|
||||
image && (
|
||||
<Image
|
||||
src={image as unknown as string}
|
||||
alt={title}
|
||||
inferSize
|
||||
class="mt-8 h-96 w-full rounded-lg object-cover"
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
<div class="mt-8">
|
||||
<Content components={components} />
|
||||
</div>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
|
||||