Skip to content

Commit 7c7e8a2

Browse files
Merge branch 'main' into build/update_latest
# Conflicts: # CHANGELOG.md # package.json # src/config.ts # src/data/blog/_releases/astro-paper-2.md # src/data/blog/_releases/astro-paper-3.md # src/data/blog/_releases/astro-paper-4.md # src/data/blog/_releases/astro-paper-5.md # src/data/blog/adding-new-post.md # src/data/blog/examples/example-draft-post.md # src/data/blog/examples/portfolio-website-development.md # src/data/blog/examples/tailwind-typography.md # src/data/blog/examples/terminal-development.md
2 parents f902d85 + 48f200f commit 7c7e8a2

15 files changed

Lines changed: 291 additions & 384 deletions

File tree

astro.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ export default defineConfig({
3535
experimental: {
3636
svg: true,
3737
responsiveImages: true,
38+
preserveScriptOrder: true,
3839
},
3940
});

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "astro-paper",
33
"type": "module",
4-
"version": "5.0.1",
4+
"version": "5.1.0",
55
"scripts": {
66
"dev": "astro dev",
77
"build": "astro check && astro build && pagefind --site dist && cp -r dist/pagefind public/",
@@ -18,25 +18,25 @@
1818
"@astrojs/sitemap": "^3.2.1",
1919
"@giscus/react": "^3.1.0",
2020
"@resvg/resvg-js": "^2.6.2",
21-
"@tailwindcss/vite": "^4.0.12",
21+
"@tailwindcss/vite": "^4.0.14",
2222
"@types/react": "^19.0.10",
2323
"@types/react-dom": "^19.0.4",
24-
"astro": "^5.4.2",
24+
"astro": "^5.5.2",
2525
"lodash.kebabcase": "^4.1.1",
2626
"react": "^19.0.0",
2727
"react-dom": "^19.0.0",
2828
"remark-collapse": "^0.1.2",
2929
"remark-toc": "^9.0.0",
3030
"satori": "^0.12.1",
3131
"sharp": "^0.33.5",
32-
"tailwindcss": "^4.0.12"
32+
"tailwindcss": "^4.0.14"
3333
},
3434
"devDependencies": {
3535
"@astrojs/check": "^0.9.4",
3636
"@pagefind/default-ui": "^1.3.0",
3737
"@tailwindcss/typography": "^0.5.16",
3838
"@types/lodash.kebabcase": "^4.1.9",
39-
"@typescript-eslint/parser": "^8.26.0",
39+
"@typescript-eslint/parser": "^8.26.1",
4040
"eslint": "^9.22.0",
4141
"eslint-plugin-astro": "^1.3.1",
4242
"globals": "^16.0.0",
@@ -45,6 +45,6 @@
4545
"prettier-plugin-astro": "^0.14.1",
4646
"prettier-plugin-tailwindcss": "^0.6.11",
4747
"typescript": "^5.8.2",
48-
"typescript-eslint": "^8.26.0"
48+
"typescript-eslint": "^8.26.1"
4949
}
50-
}
50+
}

pnpm-lock.yaml

Lines changed: 210 additions & 331 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Card.astro

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
---
22
import { slugifyStr } from "@/utils/slugify";
33
import type { CollectionEntry } from "astro:content";
4+
import { getPath } from "@/utils/getPath";
45
import Datetime from "./Datetime.astro";
56
6-
export interface Props {
7-
href?: string;
8-
frontmatter: CollectionEntry<"blog">["data"];
9-
secHeading?: boolean;
7+
export interface Props extends CollectionEntry<"blog"> {
8+
variant?: "h2" | "h3";
109
}
1110
12-
const { href, frontmatter, secHeading = true } = Astro.props;
11+
const { variant = "h2", data, id, filePath } = Astro.props;
1312
14-
const { title, pubDatetime, modDatetime, description } = frontmatter;
13+
const { title, pubDatetime, modDatetime, description } = data;
1514
1615
const headerProps = {
1716
style: { viewTransitionName: slugifyStr(title) },
@@ -21,17 +20,17 @@ const headerProps = {
2120

2221
<li class="my-6">
2322
<a
24-
href={href}
23+
href={getPath(id, filePath)}
2524
class="inline-block text-lg font-medium text-accent decoration-dashed underline-offset-4 focus-visible:no-underline focus-visible:underline-offset-0"
2625
>
2726
{
28-
secHeading ? (
27+
variant === "h2" ? (
2928
<h2 {...headerProps}>{title}</h2>
3029
) : (
3130
<h3 {...headerProps}>{title}</h3>
3231
)
3332
}
3433
</a>
35-
<Datetime pubDatetime={pubDatetime} modDatetime={modDatetime} />
34+
<Datetime {pubDatetime} {modDatetime} />
3635
<p>{description}</p>
3736
</li>

src/content.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import { defineCollection, z } from "astro:content";
22
import { glob } from "astro/loaders";
33
import { SITE } from "@/config";
44

5+
export const BLOG_PATH = "src/data/blog";
6+
57
const blog = defineCollection({
6-
loader: glob({ pattern: "**/[^_]*.md", base: "./src/data/blog" }),
8+
loader: glob({ pattern: "**/[^_]*.md", base: `./${BLOG_PATH}` }),
79
schema: ({ image }) =>
810
z.object({
911
author: z.string().default(SITE.author),

src/layouts/PostDetails.astro

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Datetime from "@/components/Datetime.astro";
88
import EditPost from "@/components/EditPost.astro";
99
import ShareLinks from "@/components/ShareLinks.astro";
1010
import BackButton from "@/components/BackButton.astro";
11+
import { getPath } from "@/utils/getPath";
1112
import { slugifyStr } from "@/utils/slugify";
1213
import IconChevronLeft from "@/assets/icons/IconChevronLeft.svg";
1314
import IconChevronRight from "@/assets/icons/IconChevronRight.svg";
@@ -46,7 +47,7 @@ if (typeof initOgImage === "string") {
4647
4748
// Use dynamic OG image if enabled and no remote|local ogImage
4849
if (!ogImageUrl && SITE.dynamicOgImage) {
49-
ogImageUrl = `/posts/${slugifyStr(title)}/index.png`;
50+
ogImageUrl = `${getPath(post.id, post.filePath)}/index.png`;
5051
}
5152
5253
// Resolve OG image URL (or fallback to SITE.ogImage / default `og.png`)

src/pages/archives/index.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ const months = [
6969
new Date(a.data.pubDatetime).getTime() / 1000
7070
)
7171
)
72-
.map(({ data, id }) => (
73-
<Card href={`/posts/${id}`} frontmatter={data} />
72+
.map(data => (
73+
<Card {...data} />
7474
))}
7575
</ul>
7676
</div>

src/pages/index.astro

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,8 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
8181
<section id="featured" class="pt-12 pb-6">
8282
<h2 class="text-2xl font-semibold tracking-wide">Featured</h2>
8383
<ul>
84-
{featuredPosts.map(({ data, id }) => (
85-
<Card
86-
href={`/posts/${id}/`}
87-
frontmatter={data}
88-
secHeading={false}
89-
/>
84+
{featuredPosts.map(data => (
85+
<Card variant="h3" {...data} />
9086
))}
9187
</ul>
9288
</section>
@@ -101,14 +97,8 @@ const recentPosts = sortedPosts.filter(({ data }) => !data.featured);
10197
<h2 class="text-2xl font-semibold tracking-wide">Recent Posts</h2>
10298
<ul>
10399
{recentPosts.map(
104-
({ data, id }, index) =>
105-
index < SITE.postPerIndex && (
106-
<Card
107-
href={`/posts/${id}/`}
108-
frontmatter={data}
109-
secHeading={false}
110-
/>
111-
)
100+
(data, index) =>
101+
index < SITE.postPerIndex && <Card variant="h3" {...data} />
112102
)}
113103
</ul>
114104
</section>

src/pages/posts/[...page].astro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ const { page } = Astro.props;
2222
<Header />
2323
<Main pageTitle="Posts" pageDesc="All the articles I've posted.">
2424
<ul>
25-
{
26-
page.data.map(({ data, id }) => (
27-
<Card href={`/posts/${id}`} frontmatter={data} />
28-
))
29-
}
25+
{page.data.map(data => <Card {...data} />)}
3026
</ul>
3127
</Main>
3228

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import { type CollectionEntry, getCollection } from "astro:content";
33
import PostDetails from "@/layouts/PostDetails.astro";
44
import getSortedPosts from "@/utils/getSortedPosts";
5+
import { getPath } from "@/utils/getPath";
56
67
export interface Props {
78
post: CollectionEntry<"blog">;
89
}
910
1011
export async function getStaticPaths() {
1112
const posts = await getCollection("blog", ({ data }) => !data.draft);
12-
1313
const postResult = posts.map(post => ({
14-
params: { slug: post.id },
14+
params: { slug: getPath(post.id, post.filePath, false) },
1515
props: { post },
1616
}));
1717

0 commit comments

Comments
 (0)