diff --git a/src/components/article/article_body/ArticleBody.astro b/src/components/article/article_body/ArticleBody.astro new file mode 100644 index 0000000..9901f0c --- /dev/null +++ b/src/components/article/article_body/ArticleBody.astro @@ -0,0 +1,37 @@ +--- +// get rendered ArticleBodyContent HTML +const html = await Astro.slots.render("default"); + +// If some lines are not started with ASCII character, +// join them to their previous line. +// This is important. +// Because I add one newline character to wrap Chinese. +const arr = html.split("\n"); +let articleHTMLFinal = arr[0]; +// Whether the current line belongs to the area where +// the line break should be kept. +let remainIntactArea = false; +for (let i = 1; i < arr.length; i++) { + if (arr[i].match(/^( diff --git a/src/components/article/ArticleBody.astro b/src/components/article/article_body/ArticleBodyContent.astro similarity index 100% rename from src/components/article/ArticleBody.astro rename to src/components/article/article_body/ArticleBodyContent.astro diff --git a/src/components/article/article_body/ArticleBodyWrapper.astro b/src/components/article/article_body/ArticleBodyWrapper.astro new file mode 100644 index 0000000..ad07819 --- /dev/null +++ b/src/components/article/article_body/ArticleBodyWrapper.astro @@ -0,0 +1,18 @@ +--- +import type { CollectionKey } from "astro:content"; +import ArticleBody from "./ArticleBody.astro"; +import ArticleBodyContent from "./ArticleBodyContent.astro"; + +interface Props { + articleSlug: string; + collectionName: CollectionKey; +} +const { articleSlug, collectionName } = Astro.props; +--- + + + + diff --git a/src/pages/article/blog/[...blog].astro b/src/pages/article/blog/[...blog].astro index 8cfba5d..05677ce 100644 --- a/src/pages/article/blog/[...blog].astro +++ b/src/pages/article/blog/[...blog].astro @@ -7,7 +7,7 @@ import type { } from "astro:content"; import Footer from "../../../components/Footer.astro"; import Nav from "../../../components/Nav.astro"; -import ArticleBody from "../../../components/article/ArticleBody.astro"; +import ArticleBodyWrapper from "../../../components/article/article_body/ArticleBodyWrapper.astro"; import DefaultLayout from "../../../layouts/DefaultLayout.astro"; export async function getStaticPaths() { @@ -29,6 +29,6 @@ const articlePrettyName:string = entry.id.split("/").pop()!.replace(".md", "");