Skip to content

Commit

Permalink
feat(theme): 添加搜索功能和无障碍支持
Browse files Browse the repository at this point in the history
- 在主题配置中添加了搜索功能和无障碍支持
- 引入了新的组件 SearchWithAria.vue
- 全局注册了 SearchWithAria 组件
  • Loading branch information
Leetfs committed Sep 8, 2024
1 parent fc95d1d commit 95c20c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion docs/.vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
// https://vitepress.dev/guide/custom-theme
import PtjsTheme from '@project-trans/vitepress-theme-project-trans/theme'

import { App } from 'vue';
import SearchWithAria from '../../../packages/vitepress-theme-project-trans/src/components/SearchWithAria.vue'; // 引入组件
import 'uno.css'
import './style.css'

export default {
extends: PtjsTheme,
enhanceApp({ app }: { app: App }) {
// 全局注册组件
app.component('SearchWithAria', SearchWithAria);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<template>
<div>
<!-- 为输入框强制添加 ARIA 标签,确保无障碍访问 -->
<!-- 这里的 ARIA 标签应与 config.ts 的 buttonAriaLabel 对应 -->
<input
type="text"
aria-label="搜索文档"
placeholder="请输入搜索内容"
/>

<!-- 强制为搜索按钮添加 ARIA 标签 -->
<!-- 与 config.ts 中的 buttonAriaLabel 保持一致 -->
<button
aria-label="搜索文档"
>
Expand Down

0 comments on commit 95c20c1

Please sign in to comment.