diff --git a/.gitignore b/.gitignore
index b08221d..d788d29 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,4 +22,4 @@ pnpm-debug.log*
package-lock.json
pnpm-lock.yaml
-src/content/types.generated.d.ts
\ No newline at end of file
+.astro
\ No newline at end of file
diff --git a/astro.config.mjs b/astro.config.mjs
index 8a62d91..680c0c2 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -58,7 +58,6 @@ export default defineConfig({
markdown: {
remarkPlugins: [remarkReadingTime],
- extendDefaultPlugins: true,
},
vite: {
@@ -68,8 +67,4 @@ export default defineConfig({
},
},
},
-
- experimental: {
- contentCollections: true,
- },
});
diff --git a/package.json b/package.json
index 86a6f98..aa729ec 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@onwidget/astrowind",
"description": "A template to make your website using Astro + Tailwind CSS.",
- "version": "0.9.7",
+ "version": "0.9.8",
"private": true,
"scripts": {
"dev": "astro dev",
@@ -14,23 +14,23 @@
"subfont": "subfont -ir --no-fallbacks --silent --root dist"
},
"devDependencies": {
- "@astrojs/image": "^0.12.1",
- "@astrojs/mdx": "^0.14.0",
- "@astrojs/partytown": "^1.0.2",
+ "@astrojs/image": "^1.0.0-beta.2",
+ "@astrojs/mdx": "^1.0.0-beta.2",
+ "@astrojs/partytown": "^1.0.3-beta.0",
"@astrojs/rss": "^2.0.0",
"@astrojs/sitemap": "^1.0.0",
- "@astrojs/tailwind": "^2.1.3",
+ "@astrojs/tailwind": "^3.0.0-beta.1",
"@astrolib/analytics": "^0.3.0",
"@astrolib/seo": "^0.3.0",
"@fontsource/inter": "^4.5.15",
"@tailwindcss/typography": "^0.5.9",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
- "astro": "^1.9.2",
- "astro-compress": "1.1.27",
+ "astro": "^2.0.0-beta.3",
+ "astro-compress": "1.1.28",
"astro-icon": "^0.8.0",
"eslint": "^8.32.0",
- "eslint-plugin-astro": "^0.22.0",
+ "eslint-plugin-astro": "^0.23.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"limax": "^2.1.0",
"mdast-util-to-string": "^3.1.0",
diff --git a/public/_headers b/public/_headers
index 1892f57..806338c 100644
--- a/public/_headers
+++ b/public/_headers
@@ -1,2 +1,2 @@
-/assets/*
+/_astro/*
Cache-Control: public, max-age=31536000, immutable
\ No newline at end of file
diff --git a/src/content/config.ts b/src/content/config.ts
index 3cd43f7..9cd1142 100644
--- a/src/content/config.ts
+++ b/src/content/config.ts
@@ -1,7 +1,7 @@
import { z, defineCollection } from 'astro:content';
const blog = defineCollection({
- schema: {
+ schema: z.object({
title: z.string(),
description: z.string().optional(),
image: z.string().optional(),
@@ -16,7 +16,7 @@ const blog = defineCollection({
category: z.string().optional(),
tags: z.array(z.string()).optional(),
author: z.string().optional(),
- },
+ }),
slug: ({ defaultSlug, data }) => {
return data.permalink || defaultSlug;
},
diff --git a/src/env.d.ts b/src/env.d.ts
index 9231795..22be149 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -1 +1,2 @@
+///
///
diff --git a/src/utils/blog.ts b/src/utils/blog.ts
index af54638..05cb8f2 100644
--- a/src/utils/blog.ts
+++ b/src/utils/blog.ts
@@ -1,11 +1,11 @@
-import { getCollection, getEntry } from 'astro:content';
+import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content';
import type { Post } from '~/types';
import { cleanSlug } from './permalinks';
const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise => {
const { id, slug = '', data } = post;
- const { Content, injectedFrontmatter } = await post.render();
+ const { Content, remarkPluginFrontmatter } = await post.render();
const { tags = [], category = 'default', author = 'Anonymous', publishDate = new Date(), ...rest } = data;
@@ -23,7 +23,7 @@ const getNormalizedPost = async (post: CollectionEntry<'blog'>): Promise =
Content: Content,
// or 'body' in case you consume from API
- readingTime: injectedFrontmatter.readingTime,
+ readingTime: remarkPluginFrontmatter?.readingTime,
};
};
@@ -67,12 +67,14 @@ export const findPostsBySlugs = async (slugs: Array): Promise): Promise> => {
if (!Array.isArray(ids)) return [];
- return await Promise.all(
- ids.map(async (id: never) => {
- const post = await getEntry('blog', id);
- return await getNormalizedPost(post);
- })
- );
+ const posts = await fetchPosts();
+
+ return ids.reduce(function (r: Array, id: string) {
+ posts.some(function (post: Post) {
+ return id === post.id && r.push(post);
+ });
+ return r;
+ }, []);
};
/** */
diff --git a/src/utils/frontmatter.mjs b/src/utils/frontmatter.mjs
index 3867f82..67c1c1c 100644
--- a/src/utils/frontmatter.mjs
+++ b/src/utils/frontmatter.mjs
@@ -2,10 +2,11 @@ import getReadingTime from 'reading-time';
import { toString } from 'mdast-util-to-string';
export function remarkReadingTime() {
- return function (tree, { data }) {
+ return function (tree, file) {
const text = toString(tree);
const readingTime = Math.ceil(getReadingTime(text).minutes);
- data.astro.frontmatter.readingTime = readingTime;
+ const { frontmatter } = file.data.astro;
+ frontmatter.readingTime = readingTime;
};
}
diff --git a/vercel.json b/vercel.json
index 722680c..3526282 100644
--- a/vercel.json
+++ b/vercel.json
@@ -3,7 +3,7 @@
"trailingSlash": false,
"headers": [
{
- "source": "/assets/(.*)",
+ "source": "/_astro/(.*)",
"headers": [
{
"key": "Cache-Control",