更新、想法和资源
了解如何使用 daisyUI 的 Astro 文档模板快速构建专业文档。
创建用户友好的文档对于任何项目都至关重要,但不必很复杂。使用“Astro 文档模板”,可在daisyUI 官方商店获取,您可以为您的产品或项目快速构建美观且易于导航的文档。如果您更喜欢使用 Next.js,还可以使用该模板的Next.js 版本。本指南将引导您完成使用 Astro 模板安装、自定义和部署文档站点的过程。
要开始使用,请从daisyUI 商店购买并下载文档模板。下载后,请按照以下步骤操作
导航到您的项目目录并安装必要的依赖项
安装依赖
npm install
运行开发服务器
npm run dev
此模板附带可自定义的着陆页(主页)和专门的文档页面。虽然我们的重点将放在文档页面上,但我们也将简要解释如何自定义着陆页。
着陆页是访问者首先看到的内容,因此使其在视觉上吸引人且信息丰富至关重要。这是一个关于如何自定义它的快速指南
导航到src/pages/index.astro
:
此文件控制着陆页的布局和内容。您可以调整英雄区域、行动号召按钮、特色内容等。
---
import CodeBlock from "../components/home/CodeBlock.astro";
import Features from "../components/home/Features.astro";
import Hero from "../components/home/Hero.astro";
import Integration from "../components/home/Integration.astro";
import Contributors from "../components/home/Contributors.astro";
import Testimonial from "../components/home/Testimonial.astro";
---
<script>
import Translate from "$components/Translate.svelte"
</script>
<div>
<Hero />
<Features />
<CodeBlock />
<Integration />
<Contributors />
<Testimonial />
</div>
修改导入的组件(Hero、Features 等)以适应您的品牌和内容需求。
个性化文档页面非常简单。以下是如何自定义关键部分
导航到src/components/docs/DocsHeader.astro
:
此文件包含您的页眉部分信息。在这里,您可以修改搜索栏、社交链接和主题切换。
<header class="sticky top-0 z-30">
<nav class="navbar bg-base-100/90 shadow-sm backdrop-blur-lg justify-center items-center py-2 md:px-10 px-2 border-b border-base-content/10">
<div class="navbar-start">
<label for="my-drawer-2" class="btn btn-square btn-ghost lg:hidden">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="inline-block w-5 h-5 stroke-current"
>
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M4 6h16M4 12h16M4 18h16"
></path>
</svg>
</label>
</div>
<div class="navbar-end">
<a
class="btn btn-sm btn-ghost"
href="https://www.x.com"
aria-label="twitter"
>
<svg viewBox="0 0 24 24" aria-hidden="true" class="h-4 w-4">
<path
d="M13.3174 10.7749L19.1457 4H17.7646L12.7039 9.88256L8.66193 4H4L10.1122 12.8955L4 20H5.38119L10.7254 13.7878L14.994 20H19.656L13.3171 10.7749H13.3174ZM11.4257 12.9738L10.8064 12.0881L5.87886 5.03974H8.00029L11.9769 10.728L12.5962 11.6137L17.7652 19.0075H15.6438L11.4257 12.9742V12.9738Z"
fill="currentColor"
></path>
</svg>
</a>
<ThemeToggle />
</div>
</nav>
</header>
导航到src/components/docs/SideBar.astro
:
侧边栏是列出文档部分的位置。更新它以添加、删除或修改部分
<div class="drawer-side z-40 md:border-r md:border-base-content/10">
<label
for="my-drawer-2"
aria-label="close sidebar"
class="drawer-overlay"
></label>
<aside class="bg-base-100 min-h-screen w-80">
<div
class="bg-base-100/90 sticky top-0 z-20 items-center gap-2 px-4 py-2 backdrop-blur lg:flex"
>
<a href="/" class="flex-0 btn btn-ghost px-2">
<h1
class="text-2xl font-bold bg-clip-text text-transparent bg-linear-to-r from-primary to-primary/50"
>
Access Shield{" "}
<span class="text-sm text-base-content opacity-50">docs</span>
</h1>
</a>
</div>
</aside>
<!-- SideBar Code -->
</div>
向文档添加新内容页面很简单
导航到src/content/docs
目录并创建一个新的 .mdx 文件。例如
src/content/docs/gettingstarted.mdx
打开新文件并使用 Markdown 添加您的内容。这是一个基本结构
---
title: Getting Started
description: "Quasi sapiente voluptates aut minima non doloribus similique quisquam. In quo expedita ipsum nostrum corrupti incidunt. Et aut eligendi ea perferendis."
---
<script>
import Translate from "$components/Translate.svelte"
</script>
## Overview
Authentication is a crucial aspect of any web application, ensuring that users are who they claim to be before granting access to resources or sensitive information. Access Shield simplifies the process of user authentication, offering features such as:
- **User Registration and Login**: Allow users to create accounts and securely log in to your application.
- **Password Hashing and Encryption**: Safeguard user passwords by securely hashing and encrypting them before storage.
- **Session Management**: Manage user sessions to maintain authentication state across requests.
- **OAuth Integration**: Simplify user authentication by integrating with popular OAuth providers.
- **Two-Factor Authentication (2FA)**: Enhance security by requiring an additional authentication factor.
- **Role-Based Access Control (RBAC)**: Define roles and permissions to control access to resources.
保存文件并运行开发服务器 (npm run dev
) 以在文档站点中查看您的新页面。
当您准备好上线时,请构建文档站点以用于生产环境
npm run build
此命令将优化并生成您站点的静态资源,以便进行部署。
使用以下选项可以轻松部署您的文档站点
借助 daisyUI 的“Astro 文档模板”,创建简洁易用的文档既快速又简单。只需按照这些步骤操作,您就可以立即启动并运行您的站点。访问daisyUI商店开始使用!
订阅 daisyUI 博客新闻通讯,以获取有关新帖子的更新。
当有新的博客文章发布时,您只会收到一封电子邮件。没有垃圾邮件。没有广告。