ProseCodeTree
ProseCodeTree (코드 트리)
ProseCodeTree는 문법 강조된 코드로 파일·폴더 구조를 시각화해 주는 타입그래피 컴포넌트예요. 여러 파일을 하나의 트리 뷰로 묶어 보여줄 수 있어요.
출처: Nuxt UI
본문
코드 블록을 원하는 순서대로 code-tree 컴포넌트로 감싸면 파일 트리 뷰로 표시돼요.
::code-tree{defaultValue="app/app.config.ts"}
```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@nuxt/ui'],
css: ['~/assets/css/main.css']
})
```
```css [app/assets/css/main.css]
@import "tailwindcss";
@import "@nuxt/ui";
```
```ts [app/app.config.ts]
export default defineAppConfig({
ui: {
colors: {
primary: 'sky',
colors: 'slate'
}
}
})
```
```vue [app/app.vue]
<template>
<UApp>
<NuxtPage />
</UApp>
</template>
```
```json [package.json]
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"typecheck": "nuxt typecheck"
},
"dependencies": {
"@iconify-json/lucide": "^1.2.0",
"@nuxt/ui": "^4.0.0",
"nuxt": "^4.0.0"
},
"devDependencies": {
"typescript": "^6.0.0",
"vue-tsc": "^3.2.0"
}
}
```
```json [tsconfig.json]
{
"extends": "./.nuxt/tsconfig.json"
}
```
````md [README.md]
# Nuxt 4 Minimal Starter
Look at the [Nuxt 4 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.
## Setup
Make sure to install the dependencies:
```bash
# npm
npm install
# pnpm
pnpm install
# yarn
yarn install
# bun
bun install
```
## Development server
Start the development server on `http://localhost:3000`:
```bash
# npm
npm run dev
# pnpm
pnpm run dev
# yarn
yarn dev
# bun
bun run dev
```
## Production
Build the application for production:
```bash
# npm
npm run build
# pnpm
pnpm run build
# yarn
yarn build
# bun
bun run build
```
Locally preview production build:
```bash
# npm
npm run preview
# pnpm
pnpm run preview
# yarn
yarn preview
# bun
bun run preview
```
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
````
::
[!NOTE] 참고: /docs/typography/code#code-blocks
ProsePre컴포넌트처럼CodeTree도 파일명, 아이콘, 복사 버튼을 처리해요.
API
Props
/**
* Props for the ProseProseCodeTree component
*/
interface ProseProseCodeTreeProps {
items?: TreeItem[] | undefined;
/**
* The selected path.
*/
modelValue?: string | undefined;
/**
* The default path to select.
*/
defaultValue?: string | undefined;
/**
* Expand all directories by default.
* @default false
*/
expandAll?: boolean | undefined;
ui?: { root?: SlotClass; list?: SlotClass; item?: SlotClass; listWithChildren?: SlotClass; itemWithChildren?: SlotClass; link?: SlotClass; linkLeadingIcon?: SlotClass; linkLabel?: SlotClass; linkTrailing?: SlotClass; linkTrailingIcon?: SlotClass; content?: SlotClass; } | undefined;
}
Slots
/**
* Slots for the ProseCodeTree component
*/
interface ProseCodeTreeSlots {
default(): any;
}
테마 (Theme)
export default defineAppConfig({
ui: {
prose: {}
}
})