Docsify.AspNetCore 1.0.0

dotnet add package Docsify.AspNetCore --version 1.0.0
                    
NuGet\Install-Package Docsify.AspNetCore -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Docsify.AspNetCore" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Docsify.AspNetCore" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Docsify.AspNetCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Docsify.AspNetCore --version 1.0.0
                    
#r "nuget: Docsify.AspNetCore, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Docsify.AspNetCore@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Docsify.AspNetCore&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Docsify.AspNetCore&version=1.0.0
                    
Install as a Cake Tool

Docsify.AspNetCore

在 ASP.NET Core 项目里一键托管 Docsify 文档站点。

Docsify 是一个用 Markdown 写文档、零构建的前端框架。本库把它封装成 ASP.NET Core 中间件:前端资源内置打包、离线可用、无需 CDN,侧边栏还根据文档目录自动生成,你只需要放 Markdown 文件。

特性

  • 开箱即用:Docsify 及其插件资源全部嵌入程序集,离线可用,部署时无需额外静态文件。
  • 自动侧边栏:根据 Markdown 目录树自动生成 _sidebar.md,目录变化无需手动维护。
  • 数学公式:内置 KaTeX 支持。
  • 图表绘制:内置 Mermaid 支持。
  • 全文搜索:内置搜索插件,标题/内容自动索引。
  • 明暗主题:内置亮色/暗色主题切换。

快速开始

1. 添加项目引用

dotnet add Demo.Web reference Docsify.AspNetCore

或通过 NuGet 安装:

dotnet add package Docsify.AspNetCore

2. 注册中间件

Program.cs 中加入两行代码:

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDocsify(builder.Configuration);  // 注册配置

var app = builder.Build();

app.UseDocsify();  // 启用 Docsify 中间件
app.UseStaticFiles();

3. 放入你的文档

在项目的 wwwroot/md-files 目录下放 Markdown 文件(如 README.mdguide/getting-started.md)。启动站点后访问 /docsify/ 即可查看文档,侧边栏会自动生成。

配置

默认配置如下,可在 appsettings.jsonDocsify 节点中覆盖:

{
  "Docsify": {
    "DocsDirectory": "md-files",
    "SidebarPath": "/_sidebar.md",
    "Name": "文档",
    "Homepage": "md-files/README.md",
    "EntryPath": "docsify"
  }
}
配置项 默认值 说明
DocsDirectory md-files Markdown 文档所在目录(相对 wwwroot
SidebarPath /_sidebar.md 侧边栏内容的路由地址,由中间件动态生成
Name 文档 站点名称,显示在页面标题和侧边栏顶部
Homepage md-files/README.md 首页展示的 Markdown 文件路径
EntryPath docsify 站点入口路径,支持多级,如 foo/bar

自定义入口

默认入口是 /docsify/。如果不希望暴露该路径,可通过 EntryPath 换成任意前缀:

{
  "Docsify": {
    "EntryPath": "foo/bar"
  }
}

配置后入口变为 /foo/bar/(或 /foo/bar/index.html),页面与静态资源都自动跟随该前缀;访问根路径 / 返回 404。

工作原理

整个请求链路由两个中间件组成:

  • DocsifyMiddleware:响应入口路径(/{EntryPath}/{EntryPath}/index.html)和 /{EntryPath}/lib/* 静态资源。入口首页渲染时会按当前入口前缀替换资源引用,资源以嵌入式资源(EmbeddedResource)方式打包在程序集里,不依赖任何外部 CDN。
  • SidebarMiddleware:在访问 SidebarPath(默认 /_sidebar.md)时,扫描 DocsDirectory 下的 Markdown 目录树,动态生成侧边栏内容。

目录结构

docsify-aspnetcore/
├── Docsify.AspNetCore/         # 核心库(NuGet 包)
│   ├── DocsifyExtensions.cs      # AddDocsify / UseDocsify 扩展方法
│   ├── DocsifyMiddleware.cs      # 入口与静态资源中间件
│   ├── SidebarMiddleware.cs      # 自动侧边栏中间件
│   ├── DocsifyOptions.cs         # 配置选项
│   └── wwwroot/docsify/          # 内置的前端资源与入口页面(docsify/katex/mermaid)
├── Demo.Web/                   # 演示项目
│   └── wwwroot/md-files/         # 示例文档
└── docsify-aspnetcore.slnx

演示项目

Demo.Web 是一个可直接运行的示例,展示了本库的基本用法,涵盖文档、图表(Mermaid)和公式(KaTeX)等效果:

dotnet run --project Demo.Web

启动后访问入口地址(默认 /docsify/)。

许可证

MIT

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 98 8/26/2026