跳到主要内容

Go 语言中的迭代器

· 阅读需 1 分钟

迭代器模式: 提供一种按顺序访问聚合对象元素的方法,而无需暴露其底层表示。

在 Go 1.23 之前,for/range 语句适用于 Go 的内置容器类型(也适用于字符串、通道以及从 Go 1.22 开始的 int)。

Go 1.23 开始,可以使用 for/range 迭代用户定义的容器(如 Set 类型)。

Docusaurus 简单使用

· 阅读需 2 分钟

文档

侧边栏

默认情况下,Docusaurus 会根据文件夹结构自动生成侧边栏。默认配置位于:sidebars.ts. 自动给侧边栏排序的方法有两种:第一种是给每个文档和文件夹添加一个数字前缀。第二种是在文档的 Front Matter 种添加 sidebar_position 配置。使用自动生成的侧边栏时,文件结构将决定侧边栏结构。可以在 Front Matter 中使用 slug 前置项自定义每个文档的 URL。

博客

侧边栏

使用 blogSidebarTitle 选项更改侧边栏标题文本。设置 blogSidebarCount: 'ALL',则可以将其设置为“所有帖子”,而不是默认的“最近帖子”。

docusaurus.config.ts
blogSidebarTitle: 'All posts',
blogSidebarCount: 'ALL',

如果你在同一天发布了多个帖子,你可以根据一天中的时间对它们进行排序:

---
date: 2021-09-13T10:00
---
Toggle me!

This is the detailed content

console.log("Markdown features including the code block are available");

You can use Markdown here including bold and italic text, and inline link

Nested toggle! Some surprise inside...

😲😲😲😲😲

备注

Some content with Markdown syntax. Check this api.

提示

Some content with Markdown syntax. Check this api.

信息

Some content with Markdown syntax. Check this api.

注意

Some content with Markdown syntax. Check this api.

危险

Some content with Markdown syntax. Check this api.

博客迁移

· 阅读需 1 分钟

把我的博客从 butterfly 迁移到 docusaurus. 一是因为 butterfly 还是太花哨了,二是因为 butterfly 引入了很多外部依赖,编译的速度和页面加载渲染的速度很慢,而且 docusaurus 有相对活跃的开源社区,还用的我相对熟悉的 React 技术构建的,最终决定迁移到 docusaurus.

特此记录。