mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
feat: upgrade to astro v3
Upgrade to astro v3. Update dependencies. Fix codes and features due to migration. BREAKING CHANGE: Astro v3 resolve #111
This commit is contained in:
@@ -16,7 +16,7 @@ breadcrumbList[0] === "posts" &&
|
||||
<ul>
|
||||
<li>
|
||||
<a href="/">Home</a>
|
||||
<span aria-hidden="true">></span>
|
||||
<span aria-hidden="true"> > </span>
|
||||
</li>
|
||||
{
|
||||
breadcrumbList.map((breadcrumb, index) =>
|
||||
@@ -33,7 +33,7 @@ breadcrumbList[0] === "posts" &&
|
||||
) : (
|
||||
<li>
|
||||
<a href={`/${breadcrumb}`}>{breadcrumb}</a>
|
||||
<span aria-hidden="true">></span>
|
||||
<span aria-hidden="true"> > </span>
|
||||
</li>
|
||||
)
|
||||
)
|
||||
|
||||
+2
-15
@@ -10,21 +10,8 @@ export interface Props {
|
||||
export default function Card({ href, frontmatter, secHeading = true }: Props) {
|
||||
const { title, pubDatetime, description } = frontmatter;
|
||||
return (
|
||||
<li className="my-6">
|
||||
<a
|
||||
href={href}
|
||||
className="inline-block text-lg font-medium text-skin-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0"
|
||||
>
|
||||
{secHeading ? (
|
||||
<h2 className="text-lg font-medium decoration-dashed hover:underline">
|
||||
{title}
|
||||
</h2>
|
||||
) : (
|
||||
<h3 className="text-lg font-medium decoration-dashed hover:underline">
|
||||
{title}
|
||||
</h3>
|
||||
)}
|
||||
</a>
|
||||
<li className="list-card">
|
||||
<a href={href}>{secHeading ? <h2>{title}</h2> : <h3>{title}</h3>}</a>
|
||||
<Datetime datetime={pubDatetime} />
|
||||
<p>{description}</p>
|
||||
</li>
|
||||
|
||||
@@ -3,9 +3,6 @@ import { LOGO_IMAGE, SITE } from "@config";
|
||||
import Hr from "./Hr.astro";
|
||||
import LinkButton from "./LinkButton.astro";
|
||||
|
||||
import logoPNG from "/assets/logo.png";
|
||||
import logoSVG from "/assets/logo.svg";
|
||||
|
||||
export interface Props {
|
||||
activeNav?: "posts" | "tags" | "about" | "search";
|
||||
}
|
||||
@@ -21,8 +18,8 @@ const { activeNav } = Astro.props;
|
||||
{
|
||||
LOGO_IMAGE.enable ? (
|
||||
<img
|
||||
src={LOGO_IMAGE.svg ? logoSVG : logoPNG}
|
||||
alt="AstroPaper Logo"
|
||||
src={`/assets/${LOGO_IMAGE.svg ? "logo.svg" : "logo.png"}`}
|
||||
alt={SITE.title}
|
||||
width={LOGO_IMAGE.width}
|
||||
height={LOGO_IMAGE.height}
|
||||
/>
|
||||
@@ -78,7 +75,7 @@ const { activeNav } = Astro.props;
|
||||
href="/search"
|
||||
className={`focus-outline p-3 sm:p-1 ${
|
||||
activeNav === "search" ? "active" : ""
|
||||
}`}
|
||||
} flex`}
|
||||
ariaLabel="search"
|
||||
title="Search"
|
||||
>
|
||||
|
||||
@@ -2,9 +2,8 @@ import { getCollection } from "astro:content";
|
||||
import generateOgImage from "@utils/generateOgImage";
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const get: APIRoute = async ({ params }) => ({
|
||||
body: await generateOgImage(params.ogTitle),
|
||||
});
|
||||
export const GET: APIRoute = async ({ params }) =>
|
||||
new Response(await generateOgImage(params.ogTitle));
|
||||
|
||||
const postImportResult = await getCollection("blog", ({ data }) => !data.draft);
|
||||
const posts = Object.values(postImportResult);
|
||||
|
||||
@@ -23,7 +23,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
||||
<Header />
|
||||
<main id="main-content">
|
||||
<section id="hero">
|
||||
<h1>Mingalaba</h1>
|
||||
<h1 class="mr-2">Mingalaba</h1>
|
||||
<a
|
||||
target="_blank"
|
||||
href="/rss.xml"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { CollectionEntry, getCollection } from "astro:content";
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import Posts from "@layouts/Posts.astro";
|
||||
import PostDetails from "@layouts/PostDetails.astro";
|
||||
import getSortedPosts from "@utils/getSortedPosts";
|
||||
|
||||
@@ -4,7 +4,7 @@ import getSortedPosts from "@utils/getSortedPosts";
|
||||
import slugify from "@utils/slugify";
|
||||
import { SITE } from "@config";
|
||||
|
||||
export async function get() {
|
||||
export async function GET() {
|
||||
const posts = await getCollection("blog");
|
||||
const sortedPosts = getSortedPosts(posts);
|
||||
return rss({
|
||||
|
||||
@@ -5,7 +5,7 @@ import Layout from "@layouts/Layout.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
import Footer from "@components/Footer.astro";
|
||||
import Search from "@components/Search";
|
||||
import SearchBar from "@components/Search";
|
||||
|
||||
// Retrieve all articles
|
||||
const posts = await getCollection("blog", ({ data }) => !data.draft);
|
||||
@@ -21,7 +21,7 @@ const searchList = posts.map(({ data }) => ({
|
||||
<Layout title={`Search | ${SITE.title}`}>
|
||||
<Header activeNav="search" />
|
||||
<Main pageTitle="Search" pageDesc="Search any article ...">
|
||||
<Search client:load searchList={searchList} />
|
||||
<SearchBar client:load searchList={searchList} />
|
||||
</Main>
|
||||
<Footer />
|
||||
</Layout>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { CollectionEntry, getCollection } from "astro:content";
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Main from "@layouts/Main.astro";
|
||||
import Header from "@components/Header.astro";
|
||||
|
||||
@@ -128,4 +128,16 @@
|
||||
.focus-outline {
|
||||
@apply outline-2 outline-offset-1 outline-skin-fill focus-visible:no-underline focus-visible:outline-dashed;
|
||||
}
|
||||
|
||||
/* Card */
|
||||
.list-card {
|
||||
@apply my-6;
|
||||
}
|
||||
.list-card > a {
|
||||
@apply inline-block text-lg font-medium text-skin-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0;
|
||||
}
|
||||
.list-card h2,
|
||||
.list-card h3 {
|
||||
@apply text-lg font-medium decoration-dashed hover:underline;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import satori, { SatoriOptions } from "satori";
|
||||
import satori, { type SatoriOptions } from "satori";
|
||||
import { SITE } from "@config";
|
||||
import { writeFile } from "node:fs/promises";
|
||||
import { Resvg } from "@resvg/resvg-js";
|
||||
|
||||
Reference in New Issue
Block a user