format all code (#386)
This commit is contained in:
committed by
GitHub
parent
7ea2f7f40f
commit
286b050fa8
+11
-11
@@ -1,20 +1,20 @@
|
||||
---
|
||||
import type { GetStaticPaths } from 'astro'
|
||||
import PostPage from '../components/PostPage.astro'
|
||||
import Pagination from '../components/control/Pagination.astro'
|
||||
import { PAGE_SIZE } from '../constants/constants'
|
||||
import MainGridLayout from '../layouts/MainGridLayout.astro'
|
||||
import { getSortedPosts } from '../utils/content-utils'
|
||||
import type { GetStaticPaths } from "astro";
|
||||
import PostPage from "../components/PostPage.astro";
|
||||
import Pagination from "../components/control/Pagination.astro";
|
||||
import { PAGE_SIZE } from "../constants/constants";
|
||||
import MainGridLayout from "../layouts/MainGridLayout.astro";
|
||||
import { getSortedPosts } from "../utils/content-utils";
|
||||
|
||||
export const getStaticPaths = (async ({ paginate }) => {
|
||||
const allBlogPosts = await getSortedPosts()
|
||||
return paginate(allBlogPosts, { pageSize: PAGE_SIZE })
|
||||
}) satisfies GetStaticPaths
|
||||
const allBlogPosts = await getSortedPosts();
|
||||
return paginate(allBlogPosts, { pageSize: PAGE_SIZE });
|
||||
}) satisfies GetStaticPaths;
|
||||
// https://github.com/withastro/astro/issues/6507#issuecomment-1489916992
|
||||
|
||||
const { page } = Astro.props
|
||||
const { page } = Astro.props;
|
||||
|
||||
const len = page.data.length
|
||||
const len = page.data.length;
|
||||
---
|
||||
|
||||
<MainGridLayout>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
---
|
||||
|
||||
import MainGridLayout from '../layouts/MainGridLayout.astro'
|
||||
import MainGridLayout from "../layouts/MainGridLayout.astro";
|
||||
|
||||
import { getEntry } from 'astro:content'
|
||||
import { i18n } from '../i18n/translation'
|
||||
import I18nKey from '../i18n/i18nKey'
|
||||
import Markdown from '@components/misc/Markdown.astro'
|
||||
import { render } from 'astro:content'
|
||||
import { getEntry } from "astro:content";
|
||||
import { render } from "astro:content";
|
||||
import Markdown from "@components/misc/Markdown.astro";
|
||||
import I18nKey from "../i18n/i18nKey";
|
||||
import { i18n } from "../i18n/translation";
|
||||
|
||||
const aboutPost = await getEntry('spec', 'about')
|
||||
const aboutPost = await getEntry("spec", "about");
|
||||
|
||||
if (!aboutPost) {
|
||||
throw new Error("About page content not found");
|
||||
throw new Error("About page content not found");
|
||||
}
|
||||
|
||||
const { Content } = await render(aboutPost)
|
||||
const { Content } = await render(aboutPost);
|
||||
---
|
||||
<MainGridLayout title={i18n(I18nKey.about)} description={i18n(I18nKey.about)}>
|
||||
<div class="flex w-full rounded-[var(--radius-large)] overflow-hidden relative min-h-32">
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
---
|
||||
import { getCategoryList } from '@utils/content-utils'
|
||||
import MainGridLayout from '@layouts/MainGridLayout.astro'
|
||||
import ArchivePanel from '@components/ArchivePanel.astro'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import ArchivePanel from "@components/ArchivePanel.astro";
|
||||
import I18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
import MainGridLayout from "@layouts/MainGridLayout.astro";
|
||||
import { getCategoryList } from "@utils/content-utils";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = await getCategoryList()
|
||||
return categories.map(category => {
|
||||
return {
|
||||
params: {
|
||||
category: category.name,
|
||||
},
|
||||
}
|
||||
})
|
||||
const categories = await getCategoryList();
|
||||
return categories.map((category) => {
|
||||
return {
|
||||
params: {
|
||||
category: category.name,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const category = Astro.params.category as string
|
||||
const category = Astro.params.category as string;
|
||||
---
|
||||
|
||||
<MainGridLayout title={i18n(I18nKey.archive)} description={i18n(I18nKey.archive)}>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
---
|
||||
import MainGridLayout from '@layouts/MainGridLayout.astro'
|
||||
import ArchivePanel from '@components/ArchivePanel.astro'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import { UNCATEGORIZED } from '@constants/constants'
|
||||
import ArchivePanel from "@components/ArchivePanel.astro";
|
||||
import { UNCATEGORIZED } from "@constants/constants";
|
||||
import I18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
import MainGridLayout from "@layouts/MainGridLayout.astro";
|
||||
---
|
||||
|
||||
<MainGridLayout title={i18n(I18nKey.archive)}>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
import MainGridLayout from '@layouts/MainGridLayout.astro'
|
||||
import ArchivePanel from '@components/ArchivePanel.astro'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import ArchivePanel from "@components/ArchivePanel.astro";
|
||||
import I18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
import MainGridLayout from "@layouts/MainGridLayout.astro";
|
||||
---
|
||||
|
||||
<MainGridLayout title={i18n(I18nKey.archive)}>
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
---
|
||||
import ArchivePanel from '@components/ArchivePanel.astro'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import MainGridLayout from '@layouts/MainGridLayout.astro'
|
||||
import { getSortedPosts } from '@utils/content-utils'
|
||||
import ArchivePanel from "@components/ArchivePanel.astro";
|
||||
import I18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
import MainGridLayout from "@layouts/MainGridLayout.astro";
|
||||
import { getSortedPosts } from "@utils/content-utils";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getSortedPosts()
|
||||
const posts = await getSortedPosts();
|
||||
|
||||
// タグを集めるための Set の型を指定
|
||||
const allTags = posts.reduce<Set<string>>((acc, post) => {
|
||||
// biome-ignore lint/complexity/noForEach: <explanation>
|
||||
post.data.tags.forEach(tag => acc.add(tag))
|
||||
return acc
|
||||
}, new Set())
|
||||
// タグを集めるための Set の型を指定
|
||||
const allTags = posts.reduce<Set<string>>((acc, post) => {
|
||||
// biome-ignore lint/complexity/noForEach: <explanation>
|
||||
post.data.tags.forEach((tag) => acc.add(tag));
|
||||
return acc;
|
||||
}, new Set());
|
||||
|
||||
const allTagsArray = Array.from(allTags)
|
||||
const allTagsArray = Array.from(allTags);
|
||||
|
||||
return allTagsArray.map(tag => ({
|
||||
params: {
|
||||
tag: tag,
|
||||
},
|
||||
}))
|
||||
return allTagsArray.map((tag) => ({
|
||||
params: {
|
||||
tag: tag,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
const tag = Astro.params.tag as string
|
||||
const tag = Astro.params.tag as string;
|
||||
---
|
||||
|
||||
<MainGridLayout title={i18n(I18nKey.archive)} description={i18n(I18nKey.archive)}>
|
||||
|
||||
@@ -1,47 +1,49 @@
|
||||
---
|
||||
import path from 'node:path'
|
||||
import License from '@components/misc/License.astro'
|
||||
import Markdown from '@components/misc/Markdown.astro'
|
||||
import I18nKey from '@i18n/i18nKey'
|
||||
import { i18n } from '@i18n/translation'
|
||||
import MainGridLayout from '@layouts/MainGridLayout.astro'
|
||||
import { getDir, getPostUrlBySlug } from '@utils/url-utils'
|
||||
import { Icon } from 'astro-icon/components'
|
||||
import { licenseConfig } from 'src/config'
|
||||
import PostMetadata from '../../components/PostMeta.astro'
|
||||
import ImageWrapper from '../../components/misc/ImageWrapper.astro'
|
||||
import { profileConfig, siteConfig } from '../../config'
|
||||
import { formatDateToYYYYMMDD } from '../../utils/date-utils'
|
||||
import { getSortedPosts } from '@utils/content-utils'
|
||||
import path from "node:path";
|
||||
import License from "@components/misc/License.astro";
|
||||
import Markdown from "@components/misc/Markdown.astro";
|
||||
import I18nKey from "@i18n/i18nKey";
|
||||
import { i18n } from "@i18n/translation";
|
||||
import MainGridLayout from "@layouts/MainGridLayout.astro";
|
||||
import { getSortedPosts } from "@utils/content-utils";
|
||||
import { getDir, getPostUrlBySlug } from "@utils/url-utils";
|
||||
import { Icon } from "astro-icon/components";
|
||||
import { licenseConfig } from "src/config";
|
||||
import PostMetadata from "../../components/PostMeta.astro";
|
||||
import ImageWrapper from "../../components/misc/ImageWrapper.astro";
|
||||
import { profileConfig, siteConfig } from "../../config";
|
||||
import { formatDateToYYYYMMDD } from "../../utils/date-utils";
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const blogEntries = await getSortedPosts();
|
||||
return blogEntries.map(entry => ({
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
}))
|
||||
const blogEntries = await getSortedPosts();
|
||||
return blogEntries.map((entry) => ({
|
||||
params: { slug: entry.slug },
|
||||
props: { entry },
|
||||
}));
|
||||
}
|
||||
|
||||
const { entry } = Astro.props
|
||||
const { Content, headings } = await entry.render()
|
||||
const { entry } = Astro.props;
|
||||
const { Content, headings } = await entry.render();
|
||||
|
||||
const { remarkPluginFrontmatter } = await entry.render()
|
||||
const { remarkPluginFrontmatter } = await entry.render();
|
||||
|
||||
const jsonLd = {
|
||||
'@context': 'https://schema.org',
|
||||
'@type': 'BlogPosting',
|
||||
headline: entry.data.title,
|
||||
description: entry.data.description || entry.data.title,
|
||||
keywords: entry.data.tags,
|
||||
author: {
|
||||
'@type': 'Person',
|
||||
name: profileConfig.name,
|
||||
url: Astro.site,
|
||||
},
|
||||
datePublished: formatDateToYYYYMMDD(entry.data.published),
|
||||
inLanguage: (entry.data.lang ? entry.data.lang.replace('_', '-') : siteConfig.lang.replace('_', '-')),
|
||||
// TODO include cover image here
|
||||
}
|
||||
"@context": "https://schema.org",
|
||||
"@type": "BlogPosting",
|
||||
headline: entry.data.title,
|
||||
description: entry.data.description || entry.data.title,
|
||||
keywords: entry.data.tags,
|
||||
author: {
|
||||
"@type": "Person",
|
||||
name: profileConfig.name,
|
||||
url: Astro.site,
|
||||
},
|
||||
datePublished: formatDateToYYYYMMDD(entry.data.published),
|
||||
inLanguage: entry.data.lang
|
||||
? entry.data.lang.replace("_", "-")
|
||||
: siteConfig.lang.replace("_", "-"),
|
||||
// TODO include cover image here
|
||||
};
|
||||
---
|
||||
<MainGridLayout banner={entry.data.image} title={entry.data.title} description={entry.data.description} lang={entry.data.lang} setOGTypeArticle={true} headings={headings}>
|
||||
<script is:inline slot="head" type="application/ld+json" set:html={JSON.stringify(jsonLd)}></script>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import type { APIRoute } from 'astro'
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
const robotsTxt = `
|
||||
User-agent: *
|
||||
Allow: /
|
||||
|
||||
Sitemap: ${new URL('sitemap-index.xml', import.meta.env.SITE).href}
|
||||
`.trim()
|
||||
Sitemap: ${new URL("sitemap-index.xml", import.meta.env.SITE).href}
|
||||
`.trim();
|
||||
|
||||
export const GET: APIRoute = () => {
|
||||
return new Response(robotsTxt, {
|
||||
headers: {
|
||||
'Content-Type': 'text/plain; charset=utf-8',
|
||||
},
|
||||
})
|
||||
}
|
||||
return new Response(robotsTxt, {
|
||||
headers: {
|
||||
"Content-Type": "text/plain; charset=utf-8",
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
+27
-27
@@ -1,33 +1,33 @@
|
||||
import { siteConfig } from '@/config'
|
||||
import rss from '@astrojs/rss'
|
||||
import { getSortedPosts } from '@utils/content-utils'
|
||||
import type { APIContext } from 'astro'
|
||||
import MarkdownIt from 'markdown-it'
|
||||
import sanitizeHtml from 'sanitize-html'
|
||||
import { siteConfig } from "@/config";
|
||||
import rss from "@astrojs/rss";
|
||||
import { getSortedPosts } from "@utils/content-utils";
|
||||
import type { APIContext } from "astro";
|
||||
import MarkdownIt from "markdown-it";
|
||||
import sanitizeHtml from "sanitize-html";
|
||||
|
||||
const parser = new MarkdownIt()
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
export async function GET(context: APIContext) {
|
||||
const blog = await getSortedPosts()
|
||||
const blog = await getSortedPosts();
|
||||
|
||||
return rss({
|
||||
title: siteConfig.title,
|
||||
description: siteConfig.subtitle || 'No description',
|
||||
site: context.site ?? 'https://fuwari.vercel.app',
|
||||
items: blog.map(post => {
|
||||
const content =
|
||||
typeof post.body === 'string' ? post.body : String(post.body || '')
|
||||
return rss({
|
||||
title: siteConfig.title,
|
||||
description: siteConfig.subtitle || "No description",
|
||||
site: context.site ?? "https://fuwari.vercel.app",
|
||||
items: blog.map((post) => {
|
||||
const content =
|
||||
typeof post.body === "string" ? post.body : String(post.body || "");
|
||||
|
||||
return {
|
||||
title: post.data.title,
|
||||
pubDate: post.data.published,
|
||||
description: post.data.description || '',
|
||||
link: `/posts/${post.slug}/`,
|
||||
content: sanitizeHtml(parser.render(content), {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img']),
|
||||
}),
|
||||
}
|
||||
}),
|
||||
customData: `<language>${siteConfig.lang}</language>`,
|
||||
})
|
||||
return {
|
||||
title: post.data.title,
|
||||
pubDate: post.data.published,
|
||||
description: post.data.description || "",
|
||||
link: `/posts/${post.slug}/`,
|
||||
content: sanitizeHtml(parser.render(content), {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]),
|
||||
}),
|
||||
};
|
||||
}),
|
||||
customData: `<language>${siteConfig.lang}</language>`,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user