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/404.astro b/src/pages/404.astro index 7d9a9a9..4384e4e 100644 --- a/src/pages/404.astro +++ b/src/pages/404.astro @@ -2,11 +2,11 @@ import DefaultLayout from "../layouts/DefaultLayout.astro"; import Nav from "../components/Nav.astro"; import Footer from "../components/Footer.astro"; -import ArticleBody from "../components/article/ArticleBody.astro"; +import ArticleBodyWrapper from "../components/article/article_body/ArticleBodyWrapper.astro"; ---