Skip to content

Commit

Permalink
feat: upgrade to astro v3
Browse files Browse the repository at this point in the history
Upgrade to astro v3. Update dependencies. Fix codes and features due to migration.

BREAKING CHANGE: Astro v3

resolve #111
  • Loading branch information
satnaing committed Sep 25, 2023
1 parent 6204463 commit e486687
Show file tree
Hide file tree
Showing 16 changed files with 2,697 additions and 9,237 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ All commands are run from the root of the project, from a terminal:
| Command | Action |
| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:3000` |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run format:check` | Check code format with Prettier |
Expand Down
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ export default defineConfig({
exclude: ["@resvg/resvg-js"],
},
},
scopedStyleStrategy: "where",
});
11,833 changes: 2,647 additions & 9,186 deletions package-lock.json

Large diffs are not rendered by default.

36 changes: 19 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,37 @@
"lint": "eslint ."
},
"dependencies": {
"@astrojs/rss": "^2.4.1",
"@astrojs/check": "^0.2.0",
"@astrojs/rss": "^3.0.0",
"@resvg/resvg-js": "^2.4.1",
"astro": "^2.4.5",
"astro": "^3.0.13",
"fuse.js": "^6.6.2",
"github-slugger": "^2.0.0",
"remark-collapse": "^0.1.2",
"remark-toc": "^8.0.1",
"satori": "^0.8.1",
"tailwindcss": "^3.3.2"
"satori": "^0.10.4",
"tailwindcss": "^3.3.3",
"typescript": "^5.2.2"
},
"devDependencies": {
"@astrojs/react": "^2.1.3",
"@astrojs/sitemap": "^1.3.1",
"@astrojs/tailwind": "^3.1.2",
"@divriots/jampack": "^0.11.2",
"@tailwindcss/typography": "^0.5.9",
"@astrojs/react": "^3.0.2",
"@astrojs/sitemap": "^3.0.0",
"@astrojs/tailwind": "^5.0.0",
"@divriots/jampack": "^0.20.1",
"@tailwindcss/typography": "^0.5.10",
"@types/github-slugger": "^1.3.0",
"@types/react": "^18.2.6",
"@typescript-eslint/parser": "^5.59.5",
"astro-eslint-parser": "^0.14.0",
"@types/react": "^18.2.21",
"@typescript-eslint/parser": "^6.7.0",
"astro-eslint-parser": "^0.15.0",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.40.0",
"eslint-plugin-astro": "^0.27.0",
"eslint": "^8.49.0",
"eslint-plugin-astro": "^0.29.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"prettier": "^2.8.8",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"prettier-plugin-astro": "^0.12.0",
"prettier-plugin-tailwindcss": "^0.2.8",
"prettier-plugin-tailwindcss": "^0.5.4",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
1 change: 1 addition & 0 deletions remark-collapse.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'remark-collapse';
4 changes: 2 additions & 2 deletions src/components/Breadcrumbs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ breadcrumbList[0] === "posts" &&
<ul>
<li>
<a href="/">Home</a>
<span aria-hidden="true">&#62;</span>
<span aria-hidden="true">&nbsp;&gt;&nbsp;</span>
</li>
{
breadcrumbList.map((breadcrumb, index) =>
Expand All @@ -33,7 +33,7 @@ breadcrumbList[0] === "posts" &&
) : (
<li>
<a href={`/${breadcrumb}`}>{breadcrumb}</a>
<span aria-hidden="true">&#62;</span>
<span aria-hidden="true">&nbsp;&gt;&nbsp;</span>
</li>
)
)
Expand Down
17 changes: 2 additions & 15 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 3 additions & 6 deletions src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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}
/>
Expand Down Expand Up @@ -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"
>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/[ogTitle].svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/pages/rss.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/search.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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>
2 changes: 1 addition & 1 deletion src/pages/tags/[tag].astro
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
12 changes: 12 additions & 0 deletions src/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/utils/generateOgImage.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down

0 comments on commit e486687

Please sign in to comment.