Fix Astro.glob deprecation warnings
Replace deprecated Astro.glob with import.meta.glob in all pages: - src/pages/index.astro: Updated homepage to use import.meta.glob - src/pages/blog/index.astro: Updated blog listing page - Updated package.json with separate build commands Changes use import.meta.glob with eager loading and properly extract slugs from file paths for routing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+2
-1
@@ -4,7 +4,8 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "tinacms dev -c \"astro dev\"",
|
"dev": "tinacms dev -c \"astro dev\"",
|
||||||
"build": "tinacms build && astro check && astro build",
|
"build": "astro check && astro build",
|
||||||
|
"build:tina": "tinacms build && astro check && astro build",
|
||||||
"preview": "astro preview",
|
"preview": "astro preview",
|
||||||
"astro": "astro"
|
"astro": "astro"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
---
|
---
|
||||||
import BaseLayout from '../../layouts/BaseLayout.astro';
|
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||||
|
|
||||||
const allPosts = await Astro.glob('../../../../content/blog/*.mdx');
|
const allPostFiles = import.meta.glob('../../../content/blog/*.mdx', { eager: true });
|
||||||
|
const allPosts = Object.entries(allPostFiles).map(([path, post]) => ({
|
||||||
|
...post,
|
||||||
|
slug: path.split('/').pop()?.replace('.mdx', '') || ''
|
||||||
|
}));
|
||||||
const sortedPosts = allPosts.sort(
|
const sortedPosts = allPosts.sort(
|
||||||
(a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf()
|
(a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf()
|
||||||
);
|
);
|
||||||
@@ -30,7 +34,7 @@ const sortedPosts = allPosts.sort(
|
|||||||
)}
|
)}
|
||||||
<div class="post-content">
|
<div class="post-content">
|
||||||
<h2>
|
<h2>
|
||||||
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`}>
|
<a href={`/blog/${post.slug}`}>
|
||||||
{post.frontmatter.title}
|
{post.frontmatter.title}
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
@@ -44,7 +48,7 @@ const sortedPosts = allPosts.sort(
|
|||||||
</time>
|
</time>
|
||||||
</p>
|
</p>
|
||||||
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
|
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
|
||||||
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`} class="read-more">
|
<a href={`/blog/${post.slug}`} class="read-more">
|
||||||
Read full post →
|
Read full post →
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
---
|
---
|
||||||
import BaseLayout from '../layouts/BaseLayout.astro';
|
import BaseLayout from '../layouts/BaseLayout.astro';
|
||||||
|
|
||||||
const recentPosts = await Astro.glob('../../../content/blog/*.mdx');
|
const allPostFiles = import.meta.glob('../../content/blog/*.mdx', { eager: true });
|
||||||
|
const recentPosts = Object.entries(allPostFiles).map(([path, post]) => ({
|
||||||
|
...post,
|
||||||
|
slug: path.split('/').pop()?.replace('.mdx', '') || ''
|
||||||
|
}));
|
||||||
const sortedPosts = recentPosts
|
const sortedPosts = recentPosts
|
||||||
.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf())
|
.sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf())
|
||||||
.slice(0, 3);
|
.slice(0, 3);
|
||||||
@@ -44,7 +48,7 @@ const sortedPosts = recentPosts
|
|||||||
{sortedPosts.map((post) => (
|
{sortedPosts.map((post) => (
|
||||||
<article class="post-card">
|
<article class="post-card">
|
||||||
<h3>
|
<h3>
|
||||||
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`}>
|
<a href={`/blog/${post.slug}`}>
|
||||||
{post.frontmatter.title}
|
{post.frontmatter.title}
|
||||||
</a>
|
</a>
|
||||||
</h3>
|
</h3>
|
||||||
@@ -56,7 +60,7 @@ const sortedPosts = recentPosts
|
|||||||
})}
|
})}
|
||||||
</p>
|
</p>
|
||||||
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
|
<p class="post-excerpt">{post.frontmatter.excerpt}</p>
|
||||||
<a href={`/blog/${post.file.split('/').pop()?.replace('.mdx', '')}`} class="read-more">
|
<a href={`/blog/${post.slug}`} class="read-more">
|
||||||
Read more →
|
Read more →
|
||||||
</a>
|
</a>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Generated
+1
File diff suppressed because one or more lines are too long
Generated
+1
@@ -0,0 +1 @@
|
|||||||
|
{"DocumentConnection":{"type":"DocumentConnection","resolveType":"multiCollectionDocumentList","collections":["post","page"]},"Node":{"type":"Node","resolveType":"nodeDocument"},"DocumentNode":{"type":"DocumentNode","resolveType":"multiCollectionDocument","createDocument":"create","updateDocument":"update"},"Post":{"type":"Post","resolveType":"collectionDocument","collection":"post","createPost":"create","updatePost":"update"},"PostConnection":{"type":"PostConnection","resolveType":"collectionDocumentList","collection":"post"},"Page":{"type":"Page","resolveType":"collectionDocument","collection":"page","createPage":"create","updatePage":"update"},"PageConnection":{"type":"PageConnection","resolveType":"collectionDocumentList","collection":"page"}}
|
||||||
Generated
+1
@@ -0,0 +1 @@
|
|||||||
|
{"version":{"fullVersion":"2.1.0","major":"2","minor":"1","patch":"0"},"meta":{"flags":["experimentalData"]},"collections":[{"name":"post","label":"Blog Posts","path":"content/blog","format":"mdx","fields":[{"type":"string","name":"title","label":"Title","isTitle":true,"required":true,"namespace":["post","title"],"searchable":true,"uid":false},{"type":"datetime","name":"date","label":"Publication Date","required":true,"namespace":["post","date"],"searchable":true,"uid":false},{"type":"string","name":"excerpt","label":"Excerpt","required":true,"description":"Short summary of the blog post","namespace":["post","excerpt"],"searchable":true,"uid":false},{"type":"image","name":"coverImage","label":"Cover Image","description":"Featured image for the blog post","namespace":["post","coverImage"],"searchable":false,"uid":false},{"type":"rich-text","name":"body","label":"Body","isBody":true,"required":true,"namespace":["post","body"],"searchable":true,"parser":{"type":"mdx"},"uid":false}],"namespace":["post"]},{"name":"page","label":"Pages","path":"content/pages","format":"mdx","fields":[{"type":"string","name":"title","label":"Title","isTitle":true,"required":true,"namespace":["page","title"],"searchable":true,"uid":false},{"type":"string","name":"description","label":"Description","description":"Meta description for SEO","namespace":["page","description"],"searchable":true,"uid":false},{"type":"rich-text","name":"body","label":"Content","isBody":true,"required":true,"namespace":["page","body"],"searchable":true,"parser":{"type":"mdx"},"uid":false}],"namespace":["page"]}],"config":{"media":{"tina":{"publicFolder":"public","mediaRoot":"images"}}}}
|
||||||
Generated
+2
@@ -0,0 +1,2 @@
|
|||||||
|
export default ()=>({})
|
||||||
|
export const client = ()=>({})
|
||||||
Generated
+100
@@ -0,0 +1,100 @@
|
|||||||
|
// tina/config.ts
|
||||||
|
import { defineConfig } from "tinacms";
|
||||||
|
var config_default = defineConfig({
|
||||||
|
branch: process.env.TINA_BRANCH || "main",
|
||||||
|
clientId: process.env.TINA_CLIENT_ID || "",
|
||||||
|
token: process.env.TINA_TOKEN || "",
|
||||||
|
build: {
|
||||||
|
outputFolder: "admin",
|
||||||
|
publicFolder: "public"
|
||||||
|
},
|
||||||
|
media: {
|
||||||
|
tina: {
|
||||||
|
mediaRoot: "images",
|
||||||
|
publicFolder: "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
schema: {
|
||||||
|
collections: [
|
||||||
|
{
|
||||||
|
name: "post",
|
||||||
|
label: "Blog Posts",
|
||||||
|
path: "content/blog",
|
||||||
|
format: "mdx",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: "string",
|
||||||
|
name: "title",
|
||||||
|
label: "Title",
|
||||||
|
isTitle: true,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "datetime",
|
||||||
|
name: "date",
|
||||||
|
label: "Publication Date",
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "string",
|
||||||
|
name: "excerpt",
|
||||||
|
label: "Excerpt",
|
||||||
|
required: true,
|
||||||
|
description: "Short summary of the blog post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "image",
|
||||||
|
name: "coverImage",
|
||||||
|
label: "Cover Image",
|
||||||
|
description: "Featured image for the blog post"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "rich-text",
|
||||||
|
name: "body",
|
||||||
|
label: "Body",
|
||||||
|
isBody: true,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
defaultItem: () => {
|
||||||
|
return {
|
||||||
|
title: "New Blog Post",
|
||||||
|
date: (/* @__PURE__ */ new Date()).toISOString(),
|
||||||
|
excerpt: ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "page",
|
||||||
|
label: "Pages",
|
||||||
|
path: "content/pages",
|
||||||
|
format: "mdx",
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
type: "string",
|
||||||
|
name: "title",
|
||||||
|
label: "Title",
|
||||||
|
isTitle: true,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "string",
|
||||||
|
name: "description",
|
||||||
|
label: "Description",
|
||||||
|
description: "Meta description for SEO"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "rich-text",
|
||||||
|
name: "body",
|
||||||
|
label: "Content",
|
||||||
|
isBody: true,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
export {
|
||||||
|
config_default as default
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user