Merge pull request #9 from Maarten-Dekker/Astro-2.0

Astro 2.0. Fixes #10
This commit is contained in:
Surjith S M
2023-02-03 11:09:54 +05:30
committed by GitHub
16 changed files with 538 additions and 602 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
# build output # build output
dist/ dist/
.output/ .output/
.astro
# dependencies # dependencies
node_modules/ node_modules/

View File

@@ -11,16 +11,16 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"@astrojs/image": "^0.11.6", "@astrojs/image": "^0.13.0",
"@astrojs/mdx": "^0.11.6", "@astrojs/mdx": "^0.15.0",
"@astrojs/sitemap": "^1.0.0", "@astrojs/sitemap": "^1.0.0",
"@astrojs/tailwind": "^2.1.3", "@astrojs/tailwind": "^3.0.0",
"@fontsource/inter": "^4.5.14", "@fontsource/inter": "^4.5.14",
"astro": "^1.9.1", "astro": "^2.0.1",
"astro-feather-icons": "^1.0.2", "astro-feather-icons": "^1.0.2",
"astro-icon": "^0.8.0", "astro-icon": "^0.8.0",
"astro-navbar": "^1.1.5", "astro-navbar": "^1.1.5",
"astro-seo": "^0.6.1", "astro-seo": "^0.7.0",
"tailwindcss": "^3.2.4" "tailwindcss": "^3.2.4"
}, },
"devDependencies": { "devDependencies": {

829
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,14 @@
--- ---
draft: false
title: "The Complete Guide to Full Stack Web Development" title: "The Complete Guide to Full Stack Web Development"
excerpt: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti." snippet: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti."
publishDate: "2022-11-08T11:39:36.050Z" image: {
image: "https://images.unsplash.com/photo-1593720213428-28a5b9e94613?&fit=crop&w=430&h=240" src: "https://images.unsplash.com/photo-1593720213428-28a5b9e94613?&fit=crop&w=430&h=240",
alt: "full stack web development"
}
publishDate: "2022-11-08 11:39"
category: "Tutorials" category: "Tutorials"
author: "Janette Lynch" author: "Janette Lynch"
layout: "@layouts/BlogLayout.astro"
tags: [webdev, tailwindcss, frontend] tags: [webdev, tailwindcss, frontend]
--- ---

View File

@@ -1,11 +1,14 @@
--- ---
draft: false
title: " Introduction to the Essential Data Structures & Algorithms" title: " Introduction to the Essential Data Structures & Algorithms"
excerpt: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti." snippet: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti."
publishDate: "2022-11-09T16:39:36.050Z" image: {
image: "https://images.unsplash.com/photo-1627163439134-7a8c47e08208?&fit=crop&w=430&h=240" src: "https://images.unsplash.com/photo-1627163439134-7a8c47e08208?&fit=crop&w=430&h=240",
alt: "data structures & algorithms"
}
publishDate: "2022-11-09 16:39"
category: "Courses" category: "Courses"
author: "Marcell Ziemann" author: "Marcell Ziemann"
layout: "@layouts/BlogLayout.astro"
tags: [webdev, tailwindcss, frontend] tags: [webdev, tailwindcss, frontend]
--- ---

View File

@@ -1,11 +1,14 @@
--- ---
draft: false
title: "How to become a Frontend Master" title: "How to become a Frontend Master"
excerpt: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti." snippet: "Ornare cum cursus laoreet sagittis nunc fusce posuere per euismod dis vehicula a, semper fames lacus maecenas dictumst pulvinar neque enim non potenti. Torquent hac sociosqu eleifend potenti."
publishDate: "2022-11-07T15:39:36.050Z" image: {
image: "https://images.unsplash.com/photo-1667372393119-3d4c48d07fc9?&fit=crop&w=430&h=240" src: "https://images.unsplash.com/photo-1667372393119-3d4c48d07fc9?&fit=crop&w=430&h=240",
alt: "frontend master"
}
publishDate: "2022-11-07 15:39"
category: "Tutorials" category: "Tutorials"
author: "Connor Lopez" author: "Connor Lopez"
layout: "@layouts/BlogLayout.astro"
tags: [astro, tailwindcss, frontend] tags: [astro, tailwindcss, frontend]
--- ---

View File

@@ -1,10 +1,13 @@
--- ---
draft: false
title: "Typography Example Post" title: "Typography Example Post"
excerpt: "Sint sit cillum pariatur eiusmod nulla pariatur ipsum. Sit laborum anim qui mollit tempor pariatur nisi minim dolor. Aliquip et adipisicing sit sit fugiat" snippet: "Sint sit cillum pariatur eiusmod nulla pariatur ipsum. Sit laborum anim qui mollit tempor pariatur nisi minim dolor. Aliquip et adipisicing sit sit fugiat"
publishDate: "2022-11-05T15:36:19.399Z" publishDate: "2022-11-05 15:36"
image: {
src: "https://images.unsplash.com/photo-1542393545-10f5cde2c810?&fit=crop&w=430&h=240",
alt: "typography"
}
category: "Technology" category: "Technology"
layout: "@layouts/BlogLayout.astro"
image: "https://images.unsplash.com/photo-1542393545-10f5cde2c810?&fit=crop&w=430&h=240"
author: "Charles North" author: "Charles North"
tags: [mdx, astro, blog] tags: [mdx, astro, blog]
--- ---

39
src/content/config.ts Normal file
View File

@@ -0,0 +1,39 @@
// 1. Import utilities from `astro:content`
import { z, defineCollection } from 'astro:content';
// 2. Define your collection(s)
const blogCollection = defineCollection({
schema: z.object({
draft: z.boolean(),
title: z.string(),
snippet: z.string(),
image: z.object({
src: z.string(),
alt: z.string(),
}),
publishDate: z.string().transform(str => new Date(str)),
author: z.string().default('Astroship'),
category: z.string(),
tags: z.array(z.string()),
}),
});
const teamCollection = defineCollection({
schema: z.object({
draft: z.boolean(),
name: z.string(),
title: z.string(),
avatar: z.object({
src: z.string(),
alt: z.string(),
}),
publishDate: z.string().transform(str => new Date(str)),
}),
});
// 3. Export a single `collections` object to register your collection(s)
// This key should match your collection directory name in "src/content"
export const collections = {
'blog': blogCollection,
'team': teamCollection,
};

View File

@@ -0,0 +1,10 @@
---
draft: false
name: "Janette Lynch"
title: "Senior Director"
avatar: {
src: "https://images.unsplash.com/photo-1580489944761-15a19d654956?&fit=crop&w=280",
alt: "Janette Lynch"
}
publishDate: "2022-11-07 15:39"
---

View File

@@ -0,0 +1,10 @@
---
draft: false
name: "Marcell Ziemann"
title: "Principal Strategist"
avatar: {
src: "https://images.unsplash.com/photo-1633332755192-727a05c4013d?&fit=crop&w=280",
alt: "Marcell Ziemann"
}
publishDate: "2022-11-08 15:39"
---

View File

@@ -0,0 +1,10 @@
---
draft: false
name: "Robert Palmer"
title: "Marketing Engineer"
avatar: {
src: "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?&fit=crop&w=280",
alt: "Robert Palmer"
}
publishDate: "2022-11-09 15:39"
---

3
src/env.d.ts vendored
View File

@@ -1 +1,2 @@
/// <reference types="astro/client" /> /// <reference path="../.astro/types.d.ts" />
/// <reference types="@astrojs/image/client" />

View File

@@ -1,45 +1,14 @@
--- ---
import { getCollection } from "astro:content";
import { Picture } from "@astrojs/image/components";
import Layout from "@layouts/Layout.astro"; import Layout from "@layouts/Layout.astro";
import Container from "@components/container.astro"; import Container from "@components/container.astro";
import Sectionhead from "@components/sectionhead.astro"; import Sectionhead from "@components/sectionhead.astro";
import { Picture } from "@astrojs/image/components";
const TeamImg1 = // Filter team entries with 'draft: false' & date before current date
"https://images.unsplash.com/photo-1580489944761-15a19d654956?&fit=crop&w=280"; const publishedTeamMembers = await getCollection("team", ({ data }) => {
const TeamImg2 = return !data.draft && data.publishDate < new Date();
"https://images.unsplash.com/photo-1633332755192-727a05c4013d?&fit=crop&w=280"; });
const TeamImg3 =
"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?&fit=crop&w=280";
const team = [
{
name: "Janette Lynch",
title: "Senior Director",
avatar: {
src: TeamImg1,
width: 480,
height: 560,
},
},
{
name: "Marcell Ziemann",
title: "Principal Strategist",
avatar: {
src: TeamImg2,
width: 580,
height: 580,
},
},
{
name: "Robert Palmer",
title: "Marketing Engineer",
avatar: {
src: TeamImg3,
width: 580,
height: 580,
},
},
];
--- ---
<Layout title="About"> <Layout title="About">
@@ -61,24 +30,29 @@ const team = [
</div> </div>
<div class="grid md:grid-cols-3 gap-10 mx-auto max-w-4xl mt-12"> <div class="grid md:grid-cols-3 gap-10 mx-auto max-w-4xl mt-12">
{ {
team.map((item) => ( publishedTeamMembers.map((teamMemberEntry) => (
<div class="group"> <div class="group">
<div class="w-full aspect-square"> <div class="w-full aspect-square">
<Picture <Picture
{...item.avatar} src={teamMemberEntry.data.avatar.src}
format="avif" alt={teamMemberEntry.data.avatar.alt}
alt="Team" sizes="(max-width: 800px) 100vw, 400px"
widths={[200, 400]} widths={[200, 400]}
aspectRatio="1:1" aspectRatio="1:1"
sizes="(max-width: 800px) 100vw, 400px" background="#ffffff"
class="w-full h-full object-cover rounded transition group-hover:-translate-y-1 group-hover:shadow-xl" fit="cover"
format="avif" position="center"
class="w-full rounded-md rounded transition group-hover:-translate-y-1 group-hover:shadow-xl"
/> />
</div> </div>
<div class="mt-4 text-center"> <div class="mt-4 text-center">
<h2 class="text-lg text-gray-800"> {item.name}</h2> <h2 class="text-lg text-gray-800">
<h3 class="text-sm text-slate-500"> {item.title}</h3> {teamMemberEntry.data.name}
</h2>
<h3 class="text-sm text-slate-500">
{teamMemberEntry.data.title}
</h3>
</div> </div>
</div> </div>
)) ))

View File

@@ -1,62 +1,67 @@
--- ---
import { getCollection } from "astro:content";
import { Picture } from "@astrojs/image/components"; import { Picture } from "@astrojs/image/components";
import Layout from "@layouts/Layout.astro";
import Container from "@components/container.astro"; import Container from "@components/container.astro";
import Sectionhead from "@components/sectionhead.astro"; import Sectionhead from "@components/sectionhead.astro";
import Layout from "@layouts/Layout.astro";
import { getFormattedDate } from "@utils/all";
import { log } from "astro/dist/core/logger/core";
// Use Astro.glob() to fetch all posts, and then sort them by date. // Filter blog entries with 'draft: false' & date before current date
const posts = (await Astro.glob("./blog/*.{md,mdx}")).sort( const publishedBlogEntries = await getCollection("blog", ({ data }) => {
(a, b) => return !data.draft && data.publishDate < new Date();
new Date(b.frontmatter.publishDate).valueOf() - });
new Date(a.frontmatter.publishDate).valueOf()
); // Sort content entries by publication date
console.log(posts[0].frontmatter.image); publishedBlogEntries.sort(function (a, b) {
return b.data.publishDate.valueOf() - a.data.publishDate.valueOf();
});
--- ---
<Layout title="Blog"> <Layout title="Blog">
<Container> <Container>
<Sectionhead> <Sectionhead>
<Fragment slot="title">Our Blog</Fragment> <Fragment slot="title">Our Blog</Fragment>
<Fragment slot="desc" <Fragment slot="desc">
>We write about building startups and thoughts going on our mind.</Fragment We write about building startups and thoughts going on our mind.
> </Fragment>
</Sectionhead> </Sectionhead>
<main class="mt-16"> <main class="mt-16">
<ul class="grid gap-16 max-w-4xl mx-auto"> <ul class="grid gap-16 max-w-4xl mx-auto">
{ {
posts.map((post, index) => ( publishedBlogEntries.map((blogPostEntry, index) => (
<li> <li>
<a href={post.url}> <a href={`/blog/${blogPostEntry.slug}`}>
<div class="grid md:grid-cols-2 gap-5 md:gap-10 items-center"> <div class="grid md:grid-cols-2 gap-5 md:gap-10 items-center">
<Picture <Picture
src={post.frontmatter.image} src={blogPostEntry.data.image.src}
widths={[200, 400, 800]} alt={blogPostEntry.data.image.alt}
sizes="(max-width: 800px) 100vw, 800px" sizes="(max-width: 800px) 100vw, 800px"
widths={[200, 400, 800]}
aspectRatio="16:9" aspectRatio="16:9"
alt="Thumbnail" background="#ffffff"
loading={index === 0 ? "eager" : "lazy"} fit="cover"
class="w-full rounded-md aspect-video" position="center"
loading={index <= 2 ? "eager" : "lazy"}
decoding={index <= 2 ? "sync" : "async"}
class="w-full rounded-md"
/> />
<div> <div>
<span class="text-blue-400 uppercase tracking-wider text-sm font-medium"> <span class="text-blue-400 uppercase tracking-wider text-sm font-medium">
{post.frontmatter.category} {blogPostEntry.data.category}
</span> </span>
<h2 class="text-3xl font-semibold leading-snug tracking-tight mt-1 "> <h2 class="text-3xl font-semibold leading-snug tracking-tight mt-1 ">
{post.frontmatter.title} {blogPostEntry.data.title}
</h2> </h2>
<div class="flex gap-2 mt-3"> <div class="flex gap-2 mt-3">
<span class="text-gray-400"> <span class="text-gray-400">
{post.frontmatter.author} {blogPostEntry.data.author}
</span> </span>
<span class="text-gray-400">• </span> <span class="text-gray-400">• </span>
<time <time
class="text-gray-400" class="text-gray-400"
datetime={post.frontmatter.publishDate}> datetime={blogPostEntry.data.publishDate.toISOString()}>
{getFormattedDate(post.frontmatter.publishDate)} {blogPostEntry.data.publishDate.toDateString()}
</time> </time>
</div> </div>
</div> </div>

View File

@@ -0,0 +1,62 @@
---
import { getCollection } from "astro:content";
import Layout from "@layouts/Layout.astro";
import Container from "@components/container.astro";
// Generate a new path for every collection entry
export async function getStaticPaths() {
const blogEntries = await getCollection("blog");
return blogEntries.map((entry) => ({
params: { slug: entry.slug },
props: { entry },
}));
}
// Get the entry directly from the prop on render
const { entry } = Astro.props;
const { Content } = await entry.render();
---
<Layout title={entry.data.title}>
<Container>
<div class="mx-auto max-w-[735px] mt-14">
<span class="text-blue-400 uppercase tracking-wider text-sm font-medium">
{entry.data.category}
</span>
<h1
class="text-4xl lg:text-5xl font-bold lg:tracking-tight mt-1 lg:leading-tight">
{entry.data.title}
</h1>
<div class="flex gap-2 mt-3 items-center flex-wrap md:flex-nowrap">
<span class="text-gray-400">
{entry.data.author}
</span>
<span class="text-gray-400">•</span>
<time
class="text-gray-400"
datetime={entry.data.publishDate.toISOString()}>
{entry.data.publishDate.toDateString()}
</time>
<span class="text-gray-400 hidden md:block">•</span>
<div class="w-full md:w-auto flex flex-wrap gap-3">
{
entry.data.tags.map((tag) => (
<span class="text-sm text-gray-500">#{tag}</span>
))
}
</div>
</div>
</div>
<div class="mx-auto prose prose-lg mt-6">
<Content />
</div>
<div class="text-center mt-8">
<a
href="/blog"
class="bg-gray-100 px-5 py-3 rounded-md hover:bg-gray-200 transition"
>← Back to Blog</a
>
</div>
</Container>
</Layout>

View File

@@ -1,6 +1,7 @@
{ {
"extends": "astro/tsconfigs/base", "extends": "astro/tsconfigs/base",
"compilerOptions": { "compilerOptions": {
"strictNullChecks": true,
"baseUrl": "src", "baseUrl": "src",
"paths": { "paths": {
"@lib/*": [ "@lib/*": [