feat: enhance documentation and internationalization support

- Updated content-collections.ts to clarify usage for Fumadocs.
- Added new ISSUES.md file to track known issues.
- Introduced @orama/orama and @orama/tokenizers dependencies in package.json for improved search functionality.
- Enhanced search API route to support internationalization and custom tokenizers for Chinese.
- Added new introduction and documentation files in both English and Chinese.
- Removed outdated test.mdx file to streamline documentation.
- Improved error handling and metadata generation in page.tsx for better user experience.
This commit is contained in:
javayhu 2025-03-29 14:30:29 +08:00
parent 02af1c7512
commit 83f5760126
12 changed files with 950 additions and 69 deletions

1
ISSUES.md Normal file
View File

@ -0,0 +1 @@
1. Doc Search in Chinese not working

View File

@ -23,8 +23,7 @@ import {
*/
/**
* Fumadocs documentation
*
* Use Content Collections for Fumadocs
* https://fumadocs.vercel.app/docs/headless/content-collections
*/
const docs = defineCollection({

View File

@ -1,17 +1,214 @@
---
title: Hello World
description: Your first document
title: MkSaaS
description: MkSaaS is the best boilerplate for building AI SaaS websites.
---
Hey there!
Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
## Heading
By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
We get lots of complaints about it actually, with people regularly asking us things like:
> Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
> We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
```html
<article class="prose">
<h1>Garlic bread with cheese: What the science tells us</h1>
<p>
For years parents have espoused the health benefits of eating garlic bread
with cheese to their children, with the food earning such an iconic status
in our culture that kids will often dress up as warm, cheesy loaf for
Halloween.
</p>
<p>
But a recent study shows that the celebrated appetizer may be linked to a
series of rabies cases springing up around the country.
</p>
</article>
```
For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md).
---
## What to expect from here on out
What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_.
It's important to cover all of these use cases for a few reasons:
1. We want everything to look good out of the box.
2. Really just the first reason, that's the whole point of the plugin.
3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
Now we're going to try out another header style.
### Typography should be easy
So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.
Something a wise person once told me about typography is:
> Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.
It's probably important that images look okay here by default as well:
{/* <Image
src="/images/blog/mksaas-og.png"
width="718"
height="404"
alt="Image"
/> */}
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
Now I'm going to show you an example of an unordered list to make sure that looks good, too:
- So here is the first item in this list.
- In this example we're keeping the items short.
- Later, we'll use longer, more complex list items.
And that's the end of this section.
## What if we stack headings?
### We should make sure that looks good, too.
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
### When a heading comes after a paragraph …
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.
- **I often do this thing where list items have headings.**
For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right.
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way.
- **Since this is a list, I need at least two items.**
I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.
- **It's not a bad idea to add a third item either.**
I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
## Code should look okay by default.
I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting.
Here's what a default `tailwind.config.js` file looks like at the time of writing:
```js
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
};
```
Hopefully that looks good enough to you.
### What about nested lists?
Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
1. **Nested lists are rarely a good idea.**
- You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
- Nesting tons of folders in your source code is also not helpful.
2. **Since we need to have more items, here's another one.**
- I'm not sure if we'll bother styling more than two levels deep.
- Two is already too much, three is guaranteed to be a bad idea.
- If you nest four levels deep you belong in prison.
3. **Two items isn't really a list, three is good though.**
- Again please don't nest lists if you want people to actually read your content.
- Nobody wants to look at this.
- I'm upset that we even have to bother styling this.
The most annoying thing about lists in Markdown is that `<li>` elements aren't given a child `<p>` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
- **For example, here's another nested list.**
But this time with a second paragraph.
- These list items won't have `<p>` tags
- Because they are only one line each
- **But in this second top-level list item, they will.**
This is especially annoying because of the spacing on this paragraph.
- As you can see here, because I've added a second line, this list item now has a `<p>` tag.
This is the second line I'm talking about by the way.
- Finally here's another list item so it's more like a list.
- A closing list item, but with no nested list, because why not?
And finally a sentence to close off this section.
## There are other elements we need to style
I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
We even included table styles, check it out:
| Wrestler | Origin | Finisher |
| ----------------------- | ------------ | ------------------ |
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor's Edge |
We also need to make sure inline code looks good, like if I wanted to talk about `<span>` elements or tell you the good news about `@tailwindcss/typography`.
### Sometimes I even use `code` in headings
Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
#### We haven't used an `h4` yet
But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
### We still need to think about stacked headings though.
#### Let's make sure we don't screw that up with `h4` elements, either.
Phew, with any luck we have styled the headings above this text and they look pretty good.
Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
What I've written here is probably long enough, but adding this final sentence can't hurt.
## GitHub Flavored Markdown
I've also added support for GitHub Flavored Mardown using `remark-gfm`.
With `remark-gfm`, we get a few extra features in our markdown. Example: autolink literals.
A link like www.example.com or https://example.com would automatically be converted into an `a` tag.
This works for email links too: contact@example.com.
<Cards>
<Card title="Learn more about Next.js" href="https://nextjs.org/docs" />
<Card title="Learn more about Fumadocs" href="https://fumadocs.vercel.app" />
</Cards>
### Heading
#### Heading

View File

@ -1,8 +1,205 @@
---
title: 中文
description: 您的第一個文檔
title: MkSaaS
description: MkSaaS 是构建 AI SaaS 网站的最佳代码模板。
---
## Hi 中文
到目前为止,尝试使用 Tailwind 来设计文章、文档或博客文章的样式一直是一项繁琐的任务,需要对排版有敏锐的眼光,并且需要大量复杂的自定义 CSS。
Fumadocs 對 i18n 有良好的支持
默认情况下Tailwind 会删除段落、标题、列表等所有默认的浏览器样式。这对于构建应用程序 UI 非常有用,因为您花更少的时间撤销用户代理样式,但是当您真的只是尝试设置来自 CMS 中富文本编辑器或 markdown 文件的内容的样式时,这可能会令人惊讶和不直观。
我们实际上收到了很多关于它的投诉,人们经常问我们这样的问题:
> 为什么 Tailwind 删除了我的 `h1` 元素上的默认样式?我如何禁用这个?你说我也会失去所有其他基本样式是什么意思?
> 我们听到了您的声音,但我们并不确信简单地禁用我们的基本样式就是您真正想要的。您不希望每次在仪表板 UI 的一部分中使用 `p` 元素时都必须删除烦人的边距。而且我怀疑您真的希望您的博客文章使用用户代理样式——您希望它们看起来很棒,而不是糟糕。
`@tailwindcss/typography` 插件是我们尝试给您真正想要的东西,而不会有做一些愚蠢的事情(比如禁用我们的基本样式)的任何缺点。
它添加了一个新的 `prose` 类,您可以将其应用于任何普通 HTML 内容块,并将其转变为一个美丽、格式良好的文档:
```html
<article class="prose">
<h1>大蒜面包配奶酪:科学告诉我们什么</h1>
<p>
多年来,父母一直向他们的孩子宣扬吃大蒜面包配奶酪的健康益处,这种食物在我们的文化中获得了如此标志性的地位,以至于孩子们经常在万圣节装扮成温暖、奶酪味的面包。
</p>
<p>
但最近的一项研究表明,这种受欢迎的开胃菜可能与全国各地出现的一系列狂犬病病例有关。
</p>
</article>
```
有关如何使用该插件及其包含的功能的更多信息,[阅读文档](https://github.com/tailwindcss/typography/blob/master/README.md)。
---
## 从现在开始期待什么
从这里开始的是我写的一堆绝对无意义的内容,用来测试插件本身。它包括我能想到的每一个合理的排版元素,如**粗体文本**、无序列表、有序列表、代码块、块引用_甚至斜体_。
涵盖所有这些用例很重要,原因如下:
1. 我们希望一切开箱即用看起来都很好。
2. 实际上只是第一个原因,这是插件的全部意义。
3. 这里有第三个假装的原因,尽管一个有三个项目的列表看起来比一个有两个项目的列表更真实。
现在我们将尝试另一种标题样式。
### 排版应该很简单
所以这是给你的一个标题——如果我们做得正确,那应该看起来相当合理。
一位智者曾经告诉我关于排版的一件事是:
> 如果你不希望你的东西看起来像垃圾,排版是非常重要的。做好它,那么它就不会糟糕。
默认情况下,图片在这里看起来也应该不错:
{/* <Image
src="/images/blog/mksaas-og.png"
width="718"
height="404"
alt="图片"
/> */}
与普遍的看法相反Lorem Ipsum 并不是简单的随机文本。它起源于公元前 45 年的一段古典拉丁文学,使其有超过 2000 年的历史。
现在我将向您展示一个无序列表的例子,以确保它看起来也不错:
- 所以这是这个列表中的第一项。
- 在这个例子中,我们保持项目简短。
- 稍后,我们将使用更长、更复杂的列表项。
这就是本节的结尾。
## 如果我们堆叠标题怎么办?
### 我们也应该确保这看起来不错。
有时候你有直接堆叠在一起的标题。在这些情况下,你通常必须取消第二个标题上的顶部边距,因为标题彼此靠得更近通常看起来比段落后面跟着标题要好。
### 当标题在段落之后出现时……
当标题在段落之后出现时,我们需要更多的空间,就像我上面已经提到的那样。现在让我们看看一个更复杂的列表会是什么样子。
- **我经常做这种事,列表项有标题。**
由于某种原因,我认为这看起来很酷,这很不幸,因为要让样式正确是相当烦人的。
我在这些列表项中通常也有两到三个段落,所以困难的部分是让段落之间的间距、列表项标题和单独的列表项都有意义。老实说,这很困难,你可以提出一个强有力的论点,认为你根本不应该这样写。
- **由于这是一个列表,我至少需要两个项目。**
我已经在前面的列表项中解释了我在做什么,但是如果一个列表只有一个项目,那就不是一个列表,我们真的希望这看起来真实。这就是为什么我添加了这第二个列表项,所以我在写样式时实际上有东西可以看。
- **添加第三项也不是一个坏主意。**
我认为只使用两个项目可能已经足够了,但三个肯定不会更糟,而且由于我似乎在编造任意的东西时没有遇到麻烦,我不妨包括它。
在这种列表之后,我通常会有一个结束语或段落,因为直接跳到标题看起来有点奇怪。
## 代码默认应该看起来不错。
我认为大多数人如果想要设置他们的代码块的样式,会使用 [highlight.js](https://highlightjs.org/) 或 [Prism](https://prismjs.com/) 或其他东西但是让它们开箱即用看起来_还不错_即使没有语法高亮也不会有害。
以下是撰写本文时默认的 `tailwind.config.js` 文件的样子:
```js
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
};
```
希望这对你来说看起来足够好。
### 嵌套列表怎么办?
嵌套列表基本上总是看起来很糟糕,这就是为什么像 Medium 这样的编辑器甚至不让你这样做,但我猜既然你们中的一些傻瓜要这样做,我们至少要承担让它工作的负担。
1. **嵌套列表很少是一个好主意。**
- 你可能觉得你真的很"有组织"或者什么的,但你只是在屏幕上创建一个难以阅读的粗糙形状。
- UI 中的嵌套导航也是一个坏主意,尽可能保持扁平。
- 在源代码中嵌套大量文件夹也没有帮助。
2. **既然我们需要有更多的项目,这里有另一个。**
- 我不确定我们是否会费心设置超过两级深度的样式。
- 两级已经太多了,三级肯定是一个坏主意。
- 如果你嵌套四级深度,你应该进监狱。
3. **两个项目并不是真正的列表,三个项目就好了。**
- 再次请不要嵌套列表,如果你希望人们真正阅读你的内容。
- 没有人想看这个。
- 我很不高兴我们甚至必须费心设置这个样式。
Markdown 中列表最烦人的事情是,除非列表项中有多个段落,否则 `<li>` 元素不会被赋予子 `<p>` 标签。这意味着我也必须担心设置那种烦人情况的样式。
- **例如,这里是另一个嵌套列表。**
但这次有第二段。
- 这些列表项不会有 `<p>` 标签
- 因为它们每个只有一行
- **但在这第二个顶级列表项中,它们会有。**
这特别烦人,因为这段话的间距。
- 正如你在这里看到的,因为我添加了第二行,这个列表项现在有一个 `<p>` 标签。
顺便说一下,这是我说的第二行。
- 最后这里有另一个列表项,所以它更像一个列表。
- 一个结束列表项,但没有嵌套列表,为什么不呢?
最后一句话结束这一节。
## 还有其他我们需要设置样式的元素
我几乎忘了提到链接,比如[这个链接到 Tailwind CSS 网站](https://tailwindcss.com)。我们几乎把它们变成蓝色,但那是昨天的事了,所以我们选择了深灰色,感觉更前卫。
我们甚至包括了表格样式,看看:
| 摔跤手 | 出生地 | 终结技 |
| ----------------------- | ------------- | ------------------- |
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor's Edge |
我们还需要确保内联代码看起来不错,比如如果我想谈论 `<span>` 元素或者告诉你关于 `@tailwindcss/typography` 的好消息。
### 有时我甚至在标题中使用 `code`
尽管这可能是一个坏主意而且历史上我一直很难让它看起来不错。不过这个_"将代码块包裹在反引号中"_的技巧效果相当不错。
我过去做过的另一件事是在链接中放置一个 `code` 标签,比如如果我想告诉你关于 [`tailwindcss/docs`](https://github.com/tailwindcss/docs) 仓库的事情。我不喜欢反引号下面有下划线,但为了避免它而导致的疯狂绝对不值得。
#### 我们还没有使用 `h4`
但现在我们有了。请不要在你的内容中使用 `h5` 或 `h6`Medium 只支持两个标题级别是有原因的,你们这些动物。我老实说考虑过使用 `before` 伪元素,如果你使用 `h5` 或 `h6` 就对你大喊大叫。
我们根本不会为它们设置样式,因为 `h4` 元素已经很小,与正文大小相同。我们应该怎么处理 `h5`让它比正文更_小_谢谢。
### 不过我们仍然需要考虑堆叠的标题。
#### 让我们确保我们也不会用 `h4` 元素搞砸这个。
呼,运气好的话,我们已经设置了上面这段文字的标题样式,它们看起来相当不错。
让我们在这里添加一个结束段落,这样事情就会以一个相当大小的文本块结束。我无法解释为什么我希望事情以这种方式结束,但我必须假设这是因为我认为如果文档末尾太靠近标题,事情会看起来奇怪或不平衡。
我在这里写的可能已经足够长了,但添加这最后一句话不会有害。
## GitHub 风格的 Markdown
我还添加了对使用 `remark-gfm` 的 GitHub 风格 Markdown 的支持。
使用 `remark-gfm`,我们在 markdown 中获得了一些额外的功能。例如:自动链接文字。
像 www.example.com 或 https://example.com 这样的链接会自动转换为 `a` 标签。
这对电子邮件链接也有效contact@example.com。

View File

@ -0,0 +1,214 @@
---
title: Introduction
description: Introduction to MkSaaS
---
Until now, trying to style an article, document, or blog post with Tailwind has been a tedious task that required a keen eye for typography and a lot of complex custom CSS.
By default, Tailwind removes all of the default browser styling from paragraphs, headings, lists and more. This ends up being really useful for building application UIs because you spend less time undoing user-agent styles, but when you _really are_ just trying to style some content that came from a rich-text editor in a CMS or a markdown file, it can be surprising and unintuitive.
We get lots of complaints about it actually, with people regularly asking us things like:
> Why is Tailwind removing the default styles on my `h1` elements? How do I disable this? What do you mean I lose all the other base styles too?
> We hear you, but we're not convinced that simply disabling our base styles is what you really want. You don't want to have to remove annoying margins every time you use a `p` element in a piece of your dashboard UI. And I doubt you really want your blog posts to use the user-agent styles either — you want them to look _awesome_, not awful.
The `@tailwindcss/typography` plugin is our attempt to give you what you _actually_ want, without any of the downsides of doing something stupid like disabling our base styles.
It adds a new `prose` class that you can slap on any block of vanilla HTML content and turn it into a beautiful, well-formatted document:
```html
<article class="prose">
<h1>Garlic bread with cheese: What the science tells us</h1>
<p>
For years parents have espoused the health benefits of eating garlic bread
with cheese to their children, with the food earning such an iconic status
in our culture that kids will often dress up as warm, cheesy loaf for
Halloween.
</p>
<p>
But a recent study shows that the celebrated appetizer may be linked to a
series of rabies cases springing up around the country.
</p>
</article>
```
For more information about how to use the plugin and the features it includes, [read the documentation](https://github.com/tailwindcss/typography/blob/master/README.md).
---
## What to expect from here on out
What follows from here is just a bunch of absolute nonsense I've written to dogfood the plugin itself. It includes every sensible typographic element I could think of, like **bold text**, unordered lists, ordered lists, code blocks, block quotes, _and even italics_.
It's important to cover all of these use cases for a few reasons:
1. We want everything to look good out of the box.
2. Really just the first reason, that's the whole point of the plugin.
3. Here's a third pretend reason though a list with three items looks more realistic than a list with two items.
Now we're going to try out another header style.
### Typography should be easy
So that's a header for you — with any luck if we've done our job correctly that will look pretty reasonable.
Something a wise person once told me about typography is:
> Typography is pretty important if you don't want your stuff to look like trash. Make it good then it won't be bad.
It's probably important that images look okay here by default as well:
{/* <Image
src="/images/blog/mksaas-og.png"
width="718"
height="404"
alt="Image"
/> */}
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.
Now I'm going to show you an example of an unordered list to make sure that looks good, too:
- So here is the first item in this list.
- In this example we're keeping the items short.
- Later, we'll use longer, more complex list items.
And that's the end of this section.
## What if we stack headings?
### We should make sure that looks good, too.
Sometimes you have headings directly underneath each other. In those cases you often have to undo the top margin on the second heading because it usually looks better for the headings to be closer together than a paragraph followed by a heading should be.
### When a heading comes after a paragraph …
When a heading comes after a paragraph, we need a bit more space, like I already mentioned above. Now let's see what a more complex list would look like.
- **I often do this thing where list items have headings.**
For some reason I think this looks cool which is unfortunate because it's pretty annoying to get the styles right.
I often have two or three paragraphs in these list items, too, so the hard part is getting the spacing between the paragraphs, list item heading, and separate list items to all make sense. Pretty tough honestly, you could make a strong argument that you just shouldn't write this way.
- **Since this is a list, I need at least two items.**
I explained what I'm doing already in the previous list item, but a list wouldn't be a list if it only had one item, and we really want this to look realistic. That's why I've added this second list item so I actually have something to look at when writing the styles.
- **It's not a bad idea to add a third item either.**
I think it probably would've been fine to just use two items but three is definitely not worse, and since I seem to be having no trouble making up arbitrary things to type, I might as well include it.
After this sort of list I usually have a closing statement or paragraph, because it kinda looks weird jumping right to a heading.
## Code should look okay by default.
I think most people are going to use [highlight.js](https://highlightjs.org/) or [Prism](https://prismjs.com/) or something if they want to style their code blocks but it wouldn't hurt to make them look _okay_ out of the box, even with no syntax highlighting.
Here's what a default `tailwind.config.js` file looks like at the time of writing:
```js
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
};
```
Hopefully that looks good enough to you.
### What about nested lists?
Nested lists basically always look bad which is why editors like Medium don't even let you do it, but I guess since some of you goofballs are going to do it we have to carry the burden of at least making it work.
1. **Nested lists are rarely a good idea.**
- You might feel like you are being really "organized" or something but you are just creating a gross shape on the screen that is hard to read.
- Nested navigation in UIs is a bad idea too, keep things as flat as possible.
- Nesting tons of folders in your source code is also not helpful.
2. **Since we need to have more items, here's another one.**
- I'm not sure if we'll bother styling more than two levels deep.
- Two is already too much, three is guaranteed to be a bad idea.
- If you nest four levels deep you belong in prison.
3. **Two items isn't really a list, three is good though.**
- Again please don't nest lists if you want people to actually read your content.
- Nobody wants to look at this.
- I'm upset that we even have to bother styling this.
The most annoying thing about lists in Markdown is that `<li>` elements aren't given a child `<p>` tag unless there are multiple paragraphs in the list item. That means I have to worry about styling that annoying situation too.
- **For example, here's another nested list.**
But this time with a second paragraph.
- These list items won't have `<p>` tags
- Because they are only one line each
- **But in this second top-level list item, they will.**
This is especially annoying because of the spacing on this paragraph.
- As you can see here, because I've added a second line, this list item now has a `<p>` tag.
This is the second line I'm talking about by the way.
- Finally here's another list item so it's more like a list.
- A closing list item, but with no nested list, because why not?
And finally a sentence to close off this section.
## There are other elements we need to style
I almost forgot to mention links, like [this link to the Tailwind CSS website](https://tailwindcss.com). We almost made them blue but that's so yesterday, so we went with dark gray, feels edgier.
We even included table styles, check it out:
| Wrestler | Origin | Finisher |
| ----------------------- | ------------ | ------------------ |
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor's Edge |
We also need to make sure inline code looks good, like if I wanted to talk about `<span>` elements or tell you the good news about `@tailwindcss/typography`.
### Sometimes I even use `code` in headings
Even though it's probably a bad idea, and historically I've had a hard time making it look good. This _"wrap the code blocks in backticks"_ trick works pretty well though really.
Another thing I've done in the past is put a `code` tag inside of a link, like if I wanted to tell you about the [`tailwindcss/docs`](https://github.com/tailwindcss/docs) repository. I don't love that there is an underline below the backticks but it is absolutely not worth the madness it would require to avoid it.
#### We haven't used an `h4` yet
But now we have. Please don't use `h5` or `h6` in your content, Medium only supports two heading levels for a reason, you animals. I honestly considered using a `before` pseudo-element to scream at you if you use an `h5` or `h6`.
We don't style them at all out of the box because `h4` elements are already so small that they are the same size as the body copy. What are we supposed to do with an `h5`, make it _smaller_ than the body copy? No thanks.
### We still need to think about stacked headings though.
#### Let's make sure we don't screw that up with `h4` elements, either.
Phew, with any luck we have styled the headings above this text and they look pretty good.
Let's add a closing paragraph here so things end with a decently sized block of text. I can't explain why I want things to end that way but I have to assume it's because I think things will look weird or unbalanced if there is a heading too close to the end of the document.
What I've written here is probably long enough, but adding this final sentence can't hurt.
## GitHub Flavored Markdown
I've also added support for GitHub Flavored Mardown using `remark-gfm`.
With `remark-gfm`, we get a few extra features in our markdown. Example: autolink literals.
A link like www.example.com or https://example.com would automatically be converted into an `a` tag.
This works for email links too: contact@example.com.
<Cards>
<Card title="Learn more about Next.js" href="https://nextjs.org/docs" />
<Card title="Learn more about Fumadocs" href="https://fumadocs.vercel.app" />
</Cards>

View File

@ -0,0 +1,205 @@
---
title: 介绍
description: MkSaaS 是构建 AI SaaS 网站的最佳代码模板。
---
到目前为止,尝试使用 Tailwind 来设计文章、文档或博客文章的样式一直是一项繁琐的任务,需要对排版有敏锐的眼光,并且需要大量复杂的自定义 CSS。
默认情况下Tailwind 会删除段落、标题、列表等所有默认的浏览器样式。这对于构建应用程序 UI 非常有用,因为您花更少的时间撤销用户代理样式,但是当您真的只是尝试设置来自 CMS 中富文本编辑器或 markdown 文件的内容的样式时,这可能会令人惊讶和不直观。
我们实际上收到了很多关于它的投诉,人们经常问我们这样的问题:
> 为什么 Tailwind 删除了我的 `h1` 元素上的默认样式?我如何禁用这个?你说我也会失去所有其他基本样式是什么意思?
> 我们听到了您的声音,但我们并不确信简单地禁用我们的基本样式就是您真正想要的。您不希望每次在仪表板 UI 的一部分中使用 `p` 元素时都必须删除烦人的边距。而且我怀疑您真的希望您的博客文章使用用户代理样式——您希望它们看起来很棒,而不是糟糕。
`@tailwindcss/typography` 插件是我们尝试给您真正想要的东西,而不会有做一些愚蠢的事情(比如禁用我们的基本样式)的任何缺点。
它添加了一个新的 `prose` 类,您可以将其应用于任何普通 HTML 内容块,并将其转变为一个美丽、格式良好的文档:
```html
<article class="prose">
<h1>大蒜面包配奶酪:科学告诉我们什么</h1>
<p>
多年来,父母一直向他们的孩子宣扬吃大蒜面包配奶酪的健康益处,这种食物在我们的文化中获得了如此标志性的地位,以至于孩子们经常在万圣节装扮成温暖、奶酪味的面包。
</p>
<p>
但最近的一项研究表明,这种受欢迎的开胃菜可能与全国各地出现的一系列狂犬病病例有关。
</p>
</article>
```
有关如何使用该插件及其包含的功能的更多信息,[阅读文档](https://github.com/tailwindcss/typography/blob/master/README.md)。
---
## 从现在开始期待什么
从这里开始的是我写的一堆绝对无意义的内容,用来测试插件本身。它包括我能想到的每一个合理的排版元素,如**粗体文本**、无序列表、有序列表、代码块、块引用_甚至斜体_。
涵盖所有这些用例很重要,原因如下:
1. 我们希望一切开箱即用看起来都很好。
2. 实际上只是第一个原因,这是插件的全部意义。
3. 这里有第三个假装的原因,尽管一个有三个项目的列表看起来比一个有两个项目的列表更真实。
现在我们将尝试另一种标题样式。
### 排版应该很简单
所以这是给你的一个标题——如果我们做得正确,那应该看起来相当合理。
一位智者曾经告诉我关于排版的一件事是:
> 如果你不希望你的东西看起来像垃圾,排版是非常重要的。做好它,那么它就不会糟糕。
默认情况下,图片在这里看起来也应该不错:
{/* <Image
src="/images/blog/mksaas-og.png"
width="718"
height="404"
alt="图片"
/> */}
与普遍的看法相反Lorem Ipsum 并不是简单的随机文本。它起源于公元前 45 年的一段古典拉丁文学,使其有超过 2000 年的历史。
现在我将向您展示一个无序列表的例子,以确保它看起来也不错:
- 所以这是这个列表中的第一项。
- 在这个例子中,我们保持项目简短。
- 稍后,我们将使用更长、更复杂的列表项。
这就是本节的结尾。
## 如果我们堆叠标题怎么办?
### 我们也应该确保这看起来不错。
有时候你有直接堆叠在一起的标题。在这些情况下,你通常必须取消第二个标题上的顶部边距,因为标题彼此靠得更近通常看起来比段落后面跟着标题要好。
### 当标题在段落之后出现时……
当标题在段落之后出现时,我们需要更多的空间,就像我上面已经提到的那样。现在让我们看看一个更复杂的列表会是什么样子。
- **我经常做这种事,列表项有标题。**
由于某种原因,我认为这看起来很酷,这很不幸,因为要让样式正确是相当烦人的。
我在这些列表项中通常也有两到三个段落,所以困难的部分是让段落之间的间距、列表项标题和单独的列表项都有意义。老实说,这很困难,你可以提出一个强有力的论点,认为你根本不应该这样写。
- **由于这是一个列表,我至少需要两个项目。**
我已经在前面的列表项中解释了我在做什么,但是如果一个列表只有一个项目,那就不是一个列表,我们真的希望这看起来真实。这就是为什么我添加了这第二个列表项,所以我在写样式时实际上有东西可以看。
- **添加第三项也不是一个坏主意。**
我认为只使用两个项目可能已经足够了,但三个肯定不会更糟,而且由于我似乎在编造任意的东西时没有遇到麻烦,我不妨包括它。
在这种列表之后,我通常会有一个结束语或段落,因为直接跳到标题看起来有点奇怪。
## 代码默认应该看起来不错。
我认为大多数人如果想要设置他们的代码块的样式,会使用 [highlight.js](https://highlightjs.org/) 或 [Prism](https://prismjs.com/) 或其他东西但是让它们开箱即用看起来_还不错_即使没有语法高亮也不会有害。
以下是撰写本文时默认的 `tailwind.config.js` 文件的样子:
```js
module.exports = {
purge: [],
theme: {
extend: {},
},
variants: {},
plugins: [],
};
```
希望这对你来说看起来足够好。
### 嵌套列表怎么办?
嵌套列表基本上总是看起来很糟糕,这就是为什么像 Medium 这样的编辑器甚至不让你这样做,但我猜既然你们中的一些傻瓜要这样做,我们至少要承担让它工作的负担。
1. **嵌套列表很少是一个好主意。**
- 你可能觉得你真的很"有组织"或者什么的,但你只是在屏幕上创建一个难以阅读的粗糙形状。
- UI 中的嵌套导航也是一个坏主意,尽可能保持扁平。
- 在源代码中嵌套大量文件夹也没有帮助。
2. **既然我们需要有更多的项目,这里有另一个。**
- 我不确定我们是否会费心设置超过两级深度的样式。
- 两级已经太多了,三级肯定是一个坏主意。
- 如果你嵌套四级深度,你应该进监狱。
3. **两个项目并不是真正的列表,三个项目就好了。**
- 再次请不要嵌套列表,如果你希望人们真正阅读你的内容。
- 没有人想看这个。
- 我很不高兴我们甚至必须费心设置这个样式。
Markdown 中列表最烦人的事情是,除非列表项中有多个段落,否则 `<li>` 元素不会被赋予子 `<p>` 标签。这意味着我也必须担心设置那种烦人情况的样式。
- **例如,这里是另一个嵌套列表。**
但这次有第二段。
- 这些列表项不会有 `<p>` 标签
- 因为它们每个只有一行
- **但在这第二个顶级列表项中,它们会有。**
这特别烦人,因为这段话的间距。
- 正如你在这里看到的,因为我添加了第二行,这个列表项现在有一个 `<p>` 标签。
顺便说一下,这是我说的第二行。
- 最后这里有另一个列表项,所以它更像一个列表。
- 一个结束列表项,但没有嵌套列表,为什么不呢?
最后一句话结束这一节。
## 还有其他我们需要设置样式的元素
我几乎忘了提到链接,比如[这个链接到 Tailwind CSS 网站](https://tailwindcss.com)。我们几乎把它们变成蓝色,但那是昨天的事了,所以我们选择了深灰色,感觉更前卫。
我们甚至包括了表格样式,看看:
| 摔跤手 | 出生地 | 终结技 |
| ----------------------- | ------------- | ------------------- |
| Bret "The Hitman" Hart | Calgary, AB | Sharpshooter |
| Stone Cold Steve Austin | Austin, TX | Stone Cold Stunner |
| Randy Savage | Sarasota, FL | Elbow Drop |
| Vader | Boulder, CO | Vader Bomb |
| Razor Ramon | Chuluota, FL | Razor's Edge |
我们还需要确保内联代码看起来不错,比如如果我想谈论 `<span>` 元素或者告诉你关于 `@tailwindcss/typography` 的好消息。
### 有时我甚至在标题中使用 `code`
尽管这可能是一个坏主意而且历史上我一直很难让它看起来不错。不过这个_"将代码块包裹在反引号中"_的技巧效果相当不错。
我过去做过的另一件事是在链接中放置一个 `code` 标签,比如如果我想告诉你关于 [`tailwindcss/docs`](https://github.com/tailwindcss/docs) 仓库的事情。我不喜欢反引号下面有下划线,但为了避免它而导致的疯狂绝对不值得。
#### 我们还没有使用 `h4`
但现在我们有了。请不要在你的内容中使用 `h5` 或 `h6`Medium 只支持两个标题级别是有原因的,你们这些动物。我老实说考虑过使用 `before` 伪元素,如果你使用 `h5` 或 `h6` 就对你大喊大叫。
我们根本不会为它们设置样式,因为 `h4` 元素已经很小,与正文大小相同。我们应该怎么处理 `h5`让它比正文更_小_谢谢。
### 不过我们仍然需要考虑堆叠的标题。
#### 让我们确保我们也不会用 `h4` 元素搞砸这个。
呼,运气好的话,我们已经设置了上面这段文字的标题样式,它们看起来相当不错。
让我们在这里添加一个结束段落,这样事情就会以一个相当大小的文本块结束。我无法解释为什么我希望事情以这种方式结束,但我必须假设这是因为我认为如果文档末尾太靠近标题,事情会看起来奇怪或不平衡。
我在这里写的可能已经足够长了,但添加这最后一句话不会有害。
## GitHub 风格的 Markdown
我还添加了对使用 `remark-gfm` 的 GitHub 风格 Markdown 的支持。
使用 `remark-gfm`,我们在 markdown 中获得了一些额外的功能。例如:自动链接文字。
像 www.example.com 或 https://example.com 这样的链接会自动转换为 `a` 标签。
这对电子邮件链接也有效contact@example.com。

View File

@ -1,21 +0,0 @@
---
title: Test Document
description: Your first document
---
Hey there!
## Heading
<Cards>
<Card title="Learn more about Next.js" href="https://nextjs.org/docs" />
<Card title="Learn more about Fumadocs" href="https://fumadocs.vercel.app" />
</Cards>
### Heading
```js
console.log('Hello World');
```
#### Heading

View File

@ -24,6 +24,8 @@
"@fumadocs/content-collections": "^1.1.8",
"@hookform/resolvers": "^4.1.0",
"@neondatabase/serverless": "^0.10.4",
"@orama/orama": "^3.1.4",
"@orama/tokenizers": "^3.1.4",
"@radix-ui/react-accordion": "^1.2.3",
"@radix-ui/react-alert-dialog": "^1.1.6",
"@radix-ui/react-aspect-ratio": "^1.1.2",

22
pnpm-lock.yaml generated
View File

@ -47,6 +47,12 @@ importers:
'@neondatabase/serverless':
specifier: ^0.10.4
version: 0.10.4
'@orama/orama':
specifier: ^3.1.4
version: 3.1.4
'@orama/tokenizers':
specifier: ^3.1.4
version: 3.1.4
'@radix-ui/react-accordion':
specifier: ^1.2.3
version: 1.2.3(@types/react-dom@19.0.3(@types/react@19.0.9))(@types/react@19.0.9)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
@ -1814,10 +1820,14 @@ packages:
resolution: {integrity: sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg==}
engines: {node: '>=8.0.0'}
'@orama/orama@3.1.3':
resolution: {integrity: sha512-UdtAMLe2RxtqvmfNDJSMpYoQYUpXgs+9qXVVFCO0BqHF86gp+uz8N6ftkaLe1p55OQXmliciw7BH34GFozKLnQ==}
'@orama/orama@3.1.4':
resolution: {integrity: sha512-7tTuIdkzgRscJ7sGHVsoK9GtXSpwbfrj3WYnuSu/SepXHhshYiQaOeXc/aeLh4MfgIre6tEs/caIop8wrhMi3g==}
engines: {node: '>= 16.0.0'}
'@orama/tokenizers@3.1.4':
resolution: {integrity: sha512-OKyw/uKDZqlS4Vwwyp2l+d1ISGtBt3qMORbTp3jyfeGjXllTLJrH/erzlVYKWdNp5bPrWGVrQbtgWgE5nLV1Ng==}
engines: {node: '>= 18.0.0'}
'@parcel/watcher-android-arm64@2.5.1':
resolution: {integrity: sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==}
engines: {node: '>= 10.0.0'}
@ -6958,7 +6968,11 @@ snapshots:
'@opentelemetry/api@1.9.0': {}
'@orama/orama@3.1.3': {}
'@orama/orama@3.1.4': {}
'@orama/tokenizers@3.1.4':
dependencies:
'@orama/orama': 3.1.4
'@parcel/watcher-android-arm64@2.5.1':
optional: true
@ -9166,7 +9180,7 @@ snapshots:
fumadocs-core@15.1.2(@types/react@19.0.9)(next@15.2.1(@babel/core@7.24.5)(@opentelemetry/api@1.9.0)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(react-dom@19.0.0(react@19.0.0))(react@19.0.0):
dependencies:
'@formatjs/intl-localematcher': 0.6.0
'@orama/orama': 3.1.3
'@orama/orama': 3.1.4
'@shikijs/rehype': 3.2.1
'@shikijs/transformers': 3.2.1
github-slugger: 2.0.0

View File

@ -5,24 +5,56 @@ import {
DocsBody,
DocsDescription,
DocsPage,
DocsTitle,
DocsTitle
} from 'fumadocs-ui/page';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { Locale } from 'next-intl';
import { notFound } from 'next/navigation';
export async function generateMetadata({
params,
}: DocPageProps) {
const { slug, locale } = await params;
const language = locale as string;
const page = source.getPage(slug, language);
if (!page) {
console.warn('docs page not found', slug, language);
notFound();
}
return {
title: page.data.title,
description: page.data.description,
} satisfies Metadata;
}
interface DocPageProps {
params: Promise<{
slug?: string[];
locale: Locale
}>;
}
export default async function Page({
params,
}: {
params: { slug?: string[]; locale: Locale };
}) {
const page = source.getPage(params.slug, params.locale);
if (!page) notFound();
}: DocPageProps) {
const { slug, locale } = await params;
const language = locale as string;
const page = source.getPage(slug, language);
if (!page) {
console.warn('docs page not found', slug, language);
notFound();
}
return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsTitle>
{page.data.title}
</DocsTitle>
<DocsDescription>
{page.data.description}
</DocsDescription>
<DocsBody>
<MDXContent
code={page.data.body}
@ -37,21 +69,3 @@ export default async function Page({
</DocsPage>
);
}
export function generateStaticParams() {
return source.generateParams();
}
export async function generateMetadata({
params,
}: {
params: { slug?: string[]; locale: Locale };
}) {
const page = source.getPage(params.slug, params.locale);
if (!page) notFound();
return {
title: page.data.title,
description: page.data.description,
} satisfies Metadata;
}

View File

@ -1,4 +1,57 @@
import { source } from '@/lib/docs/source';
import { createFromSource } from 'fumadocs-core/search/server';
import { createTokenizer } from '@orama/tokenizers/mandarin';
import { createI18nSearchAPI } from 'fumadocs-core/search/server';
import { docsI18nConfig } from '@/lib/docs/i18n';
export const { GET } = createFromSource(source);
/**
* Fumadocs i18n search configuration
*
* 1. For internationalization, use createI18nSearchAPI:
* https://fumadocs.vercel.app/docs/headless/search/orama#internationalization
*
* 2. For special languages like Chinese, configure custom tokenizers:
* https://fumadocs.vercel.app/docs/headless/search/orama#special-languages
*/
export const { GET } = createI18nSearchAPI('advanced', {
// Pass the i18n config for proper language detection
i18n: docsI18nConfig,
// Get all pages from all languages and map them to search indexes
indexes: source.getLanguages().flatMap(({ language, pages }) =>
pages.map((page) => {
return {
title: page.data.title,
description: page.data.description,
structuredData: page.data.structuredData,
id: page.url,
url: page.url,
// Set the locale explicitly for each page
locale: language,
};
}),
),
// Configure special language tokenizers and search options
localeMap: {
// Chinese configuration with Mandarin tokenizer
zh: {
components: {
tokenizer: createTokenizer(),
},
search: {
// Lower threshold for better matches with Chinese text
threshold: 0,
// Lower tolerance for better precision
tolerance: 0,
},
},
// Use the default English tokenizer for English content
en: 'english',
},
// Global search configuration
search: {
limit: 20,
},
});

View File

@ -3,8 +3,14 @@ import { allDocs, allMetas } from 'content-collections';
import { loader } from 'fumadocs-core/source';
import { docsI18nConfig } from './i18n';
/**
* Turn a content source into a unified interface
*
* https://fumadocs.vercel.app/docs/headless/source-api
* https://fumadocs.vercel.app/docs/headless/content-collections
*/
export const source = loader({
baseUrl: '/docs',
i18n: docsI18nConfig,
source: createMDXSource(allDocs, allMetas),
});
});