mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
89a700081d
Co-authored-by: locadex-agent[bot] <217277504+locadex-agent[bot]@users.noreply.github.com>
95 lines
2.1 KiB
Plaintext
95 lines
2.1 KiB
Plaintext
---
|
||
title: "相对代码片段测试"
|
||
description: "用于验证相对代码片段导入的隐藏测试页面"
|
||
---
|
||
|
||
<div id="relative-snippets-test-page">
|
||
# 相对路径代码片段测试页面
|
||
</div>
|
||
|
||
这是一个用于验证相对路径代码片段导入功能的隐藏测试页面。
|
||
|
||
---
|
||
|
||
<div id="test-1-parent-directory-import-snippets">
|
||
## 测试 1:父目录导入 (`../snippets/`)
|
||
</div>
|
||
|
||
从 `/snippets/test-snippet-a.mdx` 导入时使用 `../snippets/test-snippet-a.mdx`:
|
||
|
||
import TestSnippetA from "../snippets/test-snippet-a.mdx";
|
||
|
||
<TestSnippetA />
|
||
|
||
***
|
||
|
||
|
||
<div id="test-2-parent-directory-import-with-named-export">
|
||
## 测试 2:父目录导入(具名导出)
|
||
</div>
|
||
|
||
从 `/snippets/test-snippet-b.mdx` 中导入 `testVariable`:
|
||
|
||
import TestSnippetB from "../snippets/test-snippet-b.mdx";
|
||
|
||
<TestSnippetB />
|
||
|
||
**导出的变量值:** {testVariable}
|
||
|
||
***
|
||
|
||
|
||
<div id="test-3-same-directory-import">
|
||
## 测试 3:同级目录导入(`./`)
|
||
</div>
|
||
|
||
从同一文件夹下的 `local-snippet.mdx` 导入:
|
||
|
||
import LocalSnippet, { localMessage } from "./local-snippet.mdx";
|
||
|
||
<LocalSnippet />
|
||
|
||
**导出变量的值:** {localMessage}
|
||
|
||
***
|
||
|
||
|
||
<div id="test-4-child-directory-import-nested">
|
||
## 测试 4:子目录导入 (`./nested/`)
|
||
</div>
|
||
|
||
从 `nested/deep-snippet.mdx` 文件导入:
|
||
|
||
import DeepSnippet, { deepMessage } from "./nested/deep-snippet.mdx";
|
||
|
||
<DeepSnippet />
|
||
|
||
**导出变量的值:** {deepMessage}
|
||
|
||
***
|
||
|
||
|
||
<div id="test-5-absolute-import-for-comparison">
|
||
## 测试 5:绝对路径导入(用于比较)
|
||
</div>
|
||
|
||
通过绝对路径 `/snippets/icons-optional.mdx` 进行导入:
|
||
|
||
import IconsOptional from "/snippets/zh/icons-optional.mdx";
|
||
|
||
<IconsOptional />
|
||
|
||
***
|
||
|
||
|
||
<div id="summary">
|
||
## 概览
|
||
</div>
|
||
|
||
| 测试 | 导入路径 | 类型 | 状态 |
|
||
|------|-------------|------|--------|
|
||
| 1 | `../snippets/test-snippet-a.mdx` | 上级目录 | 见上文 |
|
||
| 2 | `../snippets/test-snippet-b.mdx` | 上级目录 + 导出 | 见上文 |
|
||
| 3 | `./local-snippet.mdx` | 同级目录 | 见上文 |
|
||
| 4 | `./nested/deep-snippet.mdx` | 子目录 | 见上文 |
|
||
| 5 | `/snippets/icons-optional.mdx` | 绝对路径 | 见上文 | |