DOCUSAURUS 2-如何在移动视图中的Navbar中添加正确的项目中的一个按钮?

发布于 2025-02-09 19:45:37 字数 946 浏览 2 评论 0原文

我想在Mobile View中的Navbar中添加一个按钮(很可能是GitHub链接)之类的项目,如下所示。

我没有在docusaurus.config.js中看到任何选项。

navbar: {
        items: [
          { to: "/docs/get-started", label: "HOME", position: "left" },
          { to: "/docs/get-started", label: "GET STARTED", position: "left" },
          { to: "/docs/learn", label: "LEARN", position: "left" },
          { to: "/docs/api", label: "API", position: "left" },
          {
            href: "https://dev.to/nucleoid",
            label: "BLOG",
            position: "left",
          },
          {
            href: "https://github.com/NucleoidJS/Nucleoid",
            html: require("fs").readFileSync("./github.html", "utf8"),
            position: "right",
          },
        ],
      },

I'd like to add an item like a button (Most likely GitHub link) in right items to Navbar in mobile view like below.

I didn't see any option in docusaurus.config.js for that.

navbar: {
        items: [
          { to: "/docs/get-started", label: "HOME", position: "left" },
          { to: "/docs/get-started", label: "GET STARTED", position: "left" },
          { to: "/docs/learn", label: "LEARN", position: "left" },
          { to: "/docs/api", label: "API", position: "left" },
          {
            href: "https://dev.to/nucleoid",
            label: "BLOG",
            position: "left",
          },
          {
            href: "https://github.com/NucleoidJS/Nucleoid",
            html: require("fs").readFileSync("./github.html", "utf8"),
            position: "right",
          },
        ],
      },

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韵柒 2025-02-16 19:45:37

由于正确的Navbar项目将设置为显示:无当视口较小时996px时,您可以使用自定义CSS覆盖它们,如下

@media (max-width: 996px) {
  div.navbar__items.navbar__items--right > * {
    display: block;
    position: inherit;
  }
}

docs

since the right navbar items will set to display: none when the viewport is smaller then 996px, you may override them with custom css as follow:

@media (max-width: 996px) {
  div.navbar__items.navbar__items--right > * {
    display: block;
    position: inherit;
  }
}

mobile view setup are mentioned in the docs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文