Skip to content

Commit

Permalink
refactor: format on biome 1.6 for astro
Browse files Browse the repository at this point in the history
  • Loading branch information
korosuke613 authored and kiba-renovate[bot] committed Mar 12, 2024
1 parent cb7c33c commit 237ab40
Show file tree
Hide file tree
Showing 16 changed files with 262 additions and 281 deletions.
19 changes: 9 additions & 10 deletions .eslintrc
Expand Up @@ -2,19 +2,10 @@
// Configuration for JavaScript files
"extends": [
"airbnb-base",
"plugin:prettier/recommended",
"plugin:astro/recommended",
"plugin:storybook/recommended"
],
"rules": {
"prettier/prettier": [
"error",
{
"singleQuote": true,
"endOfLine": "auto"
}
]
},
"rules": {},
"ignorePatterns": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.mjs"],
"overrides": [
// Configuration for Astro
Expand All @@ -34,6 +25,14 @@
"ignore": ["@/*", "astro:content", "astro:assets"]
}
],
"import/order": "off",
"quotes": "off",
"indent": "off",
"max-len": "off",
"object-curly-newline": "off",
"operator-linebreak": "off",
"implicit-arrow-linebreak": "off",
"function-paren-newline": "off",
"import/extensions": [
"error",
"ignorePackages",
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Expand Up @@ -24,7 +24,7 @@
},
"[astro]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
"editor.defaultFormatter": "astro-build.astro-vscode",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
Expand Down
13 changes: 5 additions & 8 deletions src/pages/blogs/[...page].astro
@@ -1,13 +1,10 @@
---
import Blogs from '@/templates/Blogs.astro';
import type { BlogPage } from '@/types/IBlogPage';
import { getSortedBlogData } from '@/utils/Blog';
import Blogs from "@/templates/Blogs.astro";
import type { BlogPage } from "@/types/IBlogPage";
import { getSortedBlogData } from "@/utils/Blog";
import type { GetStaticPathsOptions } from "astro";
type GetStaticPaths = {
paginate: any;
}; // Overrides `GetStaticPathsOptions` types from Astro
export async function getStaticPaths({ paginate }: GetStaticPaths) {
export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
const sortedBlogs = await getSortedBlogData();
return paginate(sortedBlogs, { pageSize: 9 });
Expand Down
19 changes: 8 additions & 11 deletions src/pages/blogs/tag/[tag]/[...page].astro
@@ -1,19 +1,16 @@
---
import Blogs from '@/templates/Blogs.astro';
import type { BlogPage } from '@/types/IBlogPage';
import { getSortedBlogData } from '@/utils/Blog';
import { escapeTag, readTags } from '@/utils/Tag';
import Blogs from "@/templates/Blogs.astro";
import type { BlogPage } from "@/types/IBlogPage";
import { getSortedBlogData } from "@/utils/Blog";
import { escapeTag, readTags } from "@/utils/Tag";
import type { GetStaticPathsOptions } from "astro";
type GetStaticPaths = {
paginate: any;
}; // Overrides `GetStaticPathsOptions` types from Astro
export async function getStaticPaths({ paginate }: GetStaticPaths) {
export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
const sorteBlogs = await getSortedBlogData();
const tags = (await readTags()).blogs;
if (tags === undefined) {
throw new Error('readed tags is undefined');
throw new Error("readed tags is undefined");
}
return Object.keys(tags).flatMap((tagName) => {
Expand All @@ -36,7 +33,7 @@ interface Props {
const { page } = Astro.props as Props;
const { tag } = Astro.params;
const originTag = (tag as string).replace('_', '/');
const originTag = (tag as string).replace("_", "/");
---

<meta name="robots" content="noindex" />
Expand Down
15 changes: 6 additions & 9 deletions src/pages/blogs/year/[year]/[...page].astro
@@ -1,14 +1,11 @@
---
import Blogs from '@/templates/Blogs.astro';
import type { BlogPage } from '@/types/IBlogPage';
import { getSortedBlogData } from '@/utils/Blog';
import { readYears } from '@/utils/Year';
import Blogs from "@/templates/Blogs.astro";
import type { BlogPage } from "@/types/IBlogPage";
import { getSortedBlogData } from "@/utils/Blog";
import { readYears } from "@/utils/Year";
import type { GetStaticPathsOptions } from "astro";
type GetStaticPaths = {
paginate: any;
}; // Overrides `GetStaticPathsOptions` types from Astro
export async function getStaticPaths({ paginate }: GetStaticPaths) {
export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
const sortedBlogs = await getSortedBlogData();
const years = await readYears();
Expand Down
33 changes: 17 additions & 16 deletions src/pages/index.astro
@@ -1,32 +1,33 @@
---
import { getCollection } from 'astro:content';
import { getCollection } from "astro:content";
import { RecentBlogs } from '@/partials/RecentBlogs';
import { RecentPickup } from '@/partials/RecentPickup';
import { RecentPosts } from '@/partials/RecentPosts';
import Base from '@/templates/Base.astro';
import { RecentBlogs } from "@/partials/RecentBlogs";
import { RecentPickup } from "@/partials/RecentPickup";
import { RecentPosts } from "@/partials/RecentPosts";
import Base from "@/templates/Base.astro";
import SelfIntroduction from '@/templates/SelfIntroduction.astro';
import type { IPost } from '@/types/IArticleFrontmatter';
import { AppConfig } from '@/utils/AppConfig';
import { getSortedBlogData } from '@/utils/Blog';
import { sortByDate, sortByOrder } from '@/utils/Posts';
import { DormitoryIntroduction } from '@/utils/StaticPages';
import { readTags } from '@/utils/Tag';
import SelfIntroduction from "@/templates/SelfIntroduction.astro";
import type { IPost } from "@/types/IArticleFrontmatter";
import { AppConfig } from "@/utils/AppConfig";
import { getSortedBlogData } from "@/utils/Blog";
import { sortByDate, sortByOrder } from "@/utils/Posts";
import { DormitoryIntroduction } from "@/utils/StaticPages";
import { readTags } from "@/utils/Tag";
const tags = await readTags();
const allPosts: IPost[] = await getCollection('posts', ({ data }) => {
return data.draft !== true;
});
const allPosts: IPost[] = await getCollection(
"posts",
({ data }) => data.draft !== true,
);
allPosts.push(DormitoryIntroduction);
const nonDraftPosts = allPosts.filter((post) => !post.data.draft);
const sortedPosts = sortByDate(nonDraftPosts);
const lastThreePosts = sortedPosts.slice(0, 3);
const nonDraftPickup = allPosts.filter(
(post) => post.data.tags.includes('Pickup ⭐️') && !post.data.draft,
(post) => post.data.tags.includes("Pickup ⭐️") && !post.data.draft,
);
const sortedPickup = sortByOrder(nonDraftPickup);
const lastThreePickup = sortedPickup.slice(0, 3);
Expand Down
24 changes: 11 additions & 13 deletions src/pages/posts/[...page].astro
@@ -1,29 +1,27 @@
---
// import type { CollectionEntry } from 'astro:content';
import { getCollection } from 'astro:content';
import { getCollection } from "astro:content";
import Content from '@/templates/Content.astro';
import Content from "@/templates/Content.astro";
import type {
ArticleFrontmatterPage,
IPost,
} from '@/types/IArticleFrontmatter';
import { sortByDate } from '@/utils/Posts';
import { DormitoryIntroduction } from '@/utils/StaticPages';
type GetStaticPaths = {
paginate: any;
}; // Overrides `GetStaticPathsOptions` types from Astro
} from "@/types/IArticleFrontmatter";
import { sortByDate } from "@/utils/Posts";
import { DormitoryIntroduction } from "@/utils/StaticPages";
import type { GetStaticPathsOptions } from "astro";
export async function getNonDraftPosts() {
const allPosts: IPost[] = await getCollection('posts', ({ data }) => {
return data.draft !== true;
});
const allPosts: IPost[] = await getCollection(
"posts",
({ data }) => data.draft !== true,
);
allPosts.push(DormitoryIntroduction);
return allPosts;
}
export async function getStaticPaths({ paginate }: GetStaticPaths) {
export async function getStaticPaths({ paginate }: GetStaticPathsOptions) {
const nonDraftPosts = await getNonDraftPosts();
const sortedPosts = sortByDate(nonDraftPosts);
Expand Down
37 changes: 18 additions & 19 deletions src/pages/posts/[...slug].astro
@@ -1,19 +1,20 @@
---
import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content';
import { getCollection } from "astro:content";
import type { CollectionEntry } from "astro:content";
import { ContentPost } from '@/partials/ContentPost';
import Base from '@/templates/Base.astro';
import { AppConfig } from '@/utils/AppConfig';
import { readTags } from '@/utils/Tag';
import { getSimilarPosts } from '@/utils/TextSimilarity';
import { getCommitHistories } from '@/utils/CommitHistories';
import { DormitoryIntroduction } from '@/utils/StaticPages';
import { ContentPost } from "@/partials/ContentPost";
import Base from "@/templates/Base.astro";
import { AppConfig } from "@/utils/AppConfig";
import { getCommitHistories } from "@/utils/CommitHistories";
import { DormitoryIntroduction } from "@/utils/StaticPages";
import { readTags } from "@/utils/Tag";
import { getSimilarPosts } from "@/utils/TextSimilarity";
export async function getStaticPaths() {
const blogEntries = await getCollection('posts', ({ data }) => {
return data.draft !== true;
});
const blogEntries = await getCollection(
"posts",
({ data }) => data.draft !== true,
);
return blogEntries.map((entry) => ({
params: { slug: entry.slug },
props: { entry },
Expand All @@ -26,22 +27,20 @@ const { Content, headings } = await entry.render();
const title = `${entry.data.title} - ${AppConfig.site_name}`;
const tags = await readTags();
const entries = await getCollection('posts', ({ data }) => {
return data.draft !== true;
});
const entries = await getCollection("posts", ({ data }) => data.draft !== true);
// 国際交流宿舎の紹介用の特別措置
entries.push(DormitoryIntroduction as unknown as CollectionEntry<'posts'>);
entries.push(DormitoryIntroduction as unknown as CollectionEntry<"posts">);
const similars = getSimilarPosts(entry, entries);
const filePath = `src/content/posts/${entry.id}`;
const histories = await getCommitHistories(filePath);
const ogpUrl = entry.data.imgSrc
? new URL(entry.data.imgSrc, 'https://korosuke613.dev/').toString()
? new URL(entry.data.imgSrc, "https://korosuke613.dev/").toString()
: undefined;
const description = entry.data.description || '';
const description = entry.data.description || "";
---

<Base
Expand All @@ -53,7 +52,7 @@ const description = entry.data.description || '';
>
<ContentPost
frontmatter={entry}
contentCategory={'Posts'}
contentCategory={"Posts"}
headings={headings}
similars={similars}
histories={histories}
Expand Down

0 comments on commit 237ab40

Please sign in to comment.