Skip to content

Commit aa2d4d1

Browse files
authored
Merge pull request #25 from oriverk/feat/#23-astro5
feat: upgrate to Astro v5-beta
2 parents cf38eaf + 4ae1382 commit aa2d4d1

File tree

13 files changed

+423
-1045
lines changed

13 files changed

+423
-1045
lines changed

astro.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ import {
1616
export default defineConfig({
1717
site: "https://oriverk.dev",
1818
publicDir: "./public",
19-
// add data-astro-prefetch to anchor element
20-
prefetch: true,
19+
output: 'static',
20+
prefetch: {
21+
prefetchAll: true
22+
},
2123
integrations: [
2224
svelte(),
2325
// NOTE: expressiveCode must be before mdx

package-lock.json

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

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
"prepare": "husky"
4242
},
4343
"dependencies": {
44-
"@astrojs/mdx": "^3.1.6",
44+
"@astrojs/mdx": "^4.0.0-beta.1",
4545
"@astrojs/rss": "^4.0.7",
46-
"@astrojs/svelte": "^5.7.0",
47-
"@expressive-code/plugin-line-numbers": "^0.36.1",
46+
"@astrojs/svelte": "^6.0.0-beta.0",
47+
"@expressive-code/plugin-line-numbers": "^0.37.0",
4848
"@octokit/graphql": "^8.1.1",
49-
"astro": "^4.15.5",
50-
"astro-expressive-code": "^0.36.1",
49+
"astro": "^5.0.0-beta.2",
50+
"astro-expressive-code": "^0.37.0",
5151
"clsx": "^2.1.1",
5252
"date-fns": "^4.1.0",
5353
"dotenv": "^16.4.5",
@@ -61,28 +61,28 @@
6161
"remark-comment": "^1.0.0",
6262
"remark-github-alerts": "^0.1.0-beta.3",
6363
"rss-parser": "^3.13.0",
64-
"satori": "^0.11.0",
64+
"satori": "^0.11.1",
6565
"sharp": "^0.33.5",
6666
"strip-markdown": "^6.0.0",
67-
"svelte": "^5.0.0-next.247",
67+
"svelte": "^5.0.0-next.259",
6868
"unified": "^11.0.5",
6969
"unist-util-inspect": "^8.1.0",
7070
"unist-util-is": "^6.0.0",
7171
"unist-util-visit": "^5.0.0",
7272
"url-join": "^5.0.0"
7373
},
7474
"devDependencies": {
75-
"@biomejs/biome": "1.9.1",
75+
"@biomejs/biome": "1.9.2",
7676
"@commitlint/cli": "^19.5.0",
7777
"@commitlint/config-conventional": "^19.5.0",
7878
"@octokit/graphql-schema": "^15.25.0",
7979
"@proofdict/textlint-rule-proofdict": "^3.1.2",
8080
"@textlint/textlint-plugin-markdown": "^14.2.0",
8181
"@types/fs-extra": "^11.0.4",
82-
"@types/node": "^22.5.5",
82+
"@types/node": "^22.7.0",
8383
"fs-extra": "^11.2.0",
8484
"husky": "^9.1.6",
85-
"markdownlint-cli": "^0.41.0",
85+
"markdownlint-cli": "^0.42.0",
8686
"npm-run-all2": "^6.2.3",
8787
"textlint": "^14.2.0",
8888
"textlint-filter-rule-allowlist": "^4.0.0",

src/components/Hero.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { github, zenn, x } = siteConfig;
1010
<h1>oriverk.dev</h1>
1111
<p><span class="text-gradient">Agr.</span> → ? / Bicycle</p>
1212
<div class="links">
13-
<a href="/blog" title="Blog" data-astro-prefetch>
13+
<a href="/blog" title="Blog">
1414
<Icon type="pencil" size="medium" />
1515
<span class="sr-only">Blog link</span>
1616
</a>

src/components/PostPagination.astro

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ const tab = (index: number) => (index === currentPage ? -1 : 0);
1313
{!!prev && (
1414
<>
1515
<li>
16-
<a href="/blog" data-astro-prefetch>&lt;&lt;</a>
16+
<a href="/blog">&lt;&lt;</a>
1717
</li>
1818
<li>
19-
<a href={prev} data-astro-prefetch>&lt;</a>
19+
<a href={prev}>&lt;</a>
2020
</li>
2121
</>
2222
)}
2323
{size < total && (
2424
<li>
25-
<a href="/blog" aria-current={curr(1)} tabindex={tab(1)} data-astro-prefetch>1</a>
25+
<a href="/blog" aria-current={curr(1)} tabindex={tab(1)}>1</a>
2626
</li>
2727
)}
2828
{[...Array(maxPage - 1)].map((_, index) => (
2929
<li>
30-
<a href={`/blog/${index+2}`} aria-current={curr(index+2)} tabindex={tab(index+2)} data-astro-prefetch>{index+2}</a>
30+
<a href={`/blog/${index+2}`} aria-current={curr(index+2)} tabindex={tab(index+2)}>{index+2}</a>
3131
</li>
3232
))}
3333
{!!next && (
3434
<ol>
3535
<li>
36-
<a href={next} data-astro-prefetch>&gt;</a>
36+
<a href={next}>&gt;</a>
3737
</li>
3838
<li>
39-
<a href={`/blog/${lastPage}`} data-astro-prefetch>&gt;&gt;</a>
39+
<a href={`/blog/${lastPage}`}>&gt;&gt;</a>
4040
</li>
4141
</ol>
4242
)}

src/components/Search/Hit.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const { title, date } = meta;
2121
>
2222
<div>
2323
<p class="title">{title}</p>
24-
<time class="date" datetime={date}>{date.split("T")[0]}</time>
24+
<time class="date" datetime={date}>{date?.split("T")[0]}</time>
2525
</div>
2626
</a>
2727
<!-- {#if !!sub_results.length}

src/content/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { defineCollection, z } from "astro:content";
2+
import { glob } from 'astro/loaders';
23

34
const staticCollection = defineCollection({
4-
type: "content",
5+
loader: glob({ pattern: '**\/[^_]*.mdx?', base: "./src/content/static" }),
56
schema: z.object({
67
title: z.string(),
78
description: z.string().optional(),
@@ -13,7 +14,7 @@ const staticCollection = defineCollection({
1314
});
1415

1516
const blogCollection = defineCollection({
16-
type: "content",
17+
loader: glob({ pattern: '**\/[^_]*.mdx?', base: "./src/content/blog" }),
1718
schema: z.object({
1819
title: z.string(),
1920
description: z.string().optional(),

src/env.d.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
/// <reference path="../.astro/types.d.ts" />
22
/// <reference types="astro/client" />
3-
4-
interface ImportMetaEnv {
5-
readonly SECRET_GITHUB_PERSONAL_ACCESS_TOKEN: string;
6-
7-
readonly SECRET_ALGOLIA_ADMIN_KEY: string;
8-
}
9-
10-
// eslint-disable-next-line no-unused-vars
11-
interface ImportMeta {
12-
readonly env: ImportMetaEnv;
13-
}

src/layouts/Header.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const isActive = (href: string) =>
1818
<HeaderSearch client:only="svelte" />
1919
</li>
2020
<li>
21-
<a href="/blog" class:list={[{acitve: isActive("/blog")}]} data-astro-prefetch>Blog</a>
21+
<a href="/blog" class:list={[{acitve: isActive("/blog")}]}>Blog</a>
2222
</li>
2323
<li>
2424
<a href="https://oriverk.github.io/" target="_blank" rel="noopener noreferrer" title="GitHub Page">

src/layouts/Layout.astro

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { ViewTransitions } from "astro:transitions";
2+
import { ClientRouter } from 'astro:transitions';
33
import defaultOgImage from "@/assets/images/og.png";
44
import ContentWrapper from "@/components/ui/ContentWrapper.astro";
55
import urlJoin from "url-join";
@@ -50,7 +50,7 @@ const rssHref = Astro.site
5050
<meta name="twitter:card" content="summary_large_image" />
5151
<meta property="og:image" content={ogImage} />
5252
<meta content="ja_JP" property="og:locale" />
53-
<ViewTransitions />
53+
<ClientRouter />
5454
</head>
5555
<body>
5656
<div id="astro">
@@ -59,9 +59,15 @@ const rssHref = Astro.site
5959
<Header />
6060
</ContentWrapper>
6161
</header>
62-
<main data-pagefind-body={!!pagefind && !noindex}>
63-
<slot />
64-
</main>
62+
{!!pagefind && !noindex ? (
63+
<main data-pagefind-body={true}>
64+
<slot />
65+
</main>
66+
) : (
67+
<main>
68+
<slot />
69+
</main>
70+
)}
6571
<footer>
6672
<ContentWrapper>
6773
<Footer />

src/pages/[...slug].astro

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
import { getCollection } from "astro:content";
2+
import { getCollection, render } from "astro:content";
33
import AstroLink from "@/components/markdown/AstroLink.astro";
44
import ContentWrapper from "@/components/ui/ContentWrapper.astro";
55
import Markdown from "@/components/ui/Markdown.astro";
@@ -19,10 +19,9 @@ export const getStaticPaths = (async () => {
1919
2020
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
2121
const { post } = Astro.props as Props;
22-
const { render, data } = post;
22+
const { data } = post;
2323
const { title, create, description, update, noindex } = data;
24-
25-
const { Content } = await render();
24+
const { Content } = await render(post);
2625
2726
export const components = {
2827
a: AstroLink,

src/pages/blog/[...slug].astro

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import { render } from 'astro:content';
23
import PostTag from "@/components/PostTag.astro";
34
import AstroLink from "@/components/markdown/AstroLink.astro";
45
import ContentWrapper from "@/components/ui/ContentWrapper.astro";
@@ -23,7 +24,7 @@ export const getStaticPaths = (async () => {
2324
2425
type Props = InferGetStaticPropsType<typeof getStaticPaths>;
2526
const { post } = Astro.props as Props;
26-
const { render, data } = post;
27+
const { data } = post;
2728
const { title, description, tags, create, update, image, noindex } = data;
2829
const lastModified = update || create;
2930
const date = lastModified.toLocaleDateString("ja-JP", {
@@ -32,7 +33,7 @@ const date = lastModified.toLocaleDateString("ja-JP", {
3233
day: "numeric",
3334
});
3435
const isoDate = lastModified.toISOString();
35-
const { Content, headings } = await render();
36+
const { Content, headings } = await render(post);
3637
const toc = getTocHierarchy(headings);
3738
const { origin, pathname } = Astro.url;
3839
const ogImage = getOgImageSrc(origin, pathname);

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
]
1313
}
1414
},
15+
"include": [".astro/types.d.ts", "**/*"],
1516
"exclude": [
1617
"./node_modules",
1718
"./dist"

0 commit comments

Comments
 (0)