@@ -21,6 +21,11 @@ function style() {
2121 align-items: center;
2222}
2323
24+ .search .results-status:not(:empty) {
25+ margin-top: 10px;
26+ font-size: smaller;
27+ }
28+
2429.search .results-panel {
2530 display: none;
2631}
@@ -122,12 +127,14 @@ function tpl(defaultValue = '') {
122127 </svg>
123128 </div>
124129 </div>
130+ <div class="results-status" aria-live="polite"></div>
125131 <div class="results-panel"></div>
126132 ` ;
127133 const el = Docsify . dom . create ( 'div' , html ) ;
128134 const aside = Docsify . dom . find ( 'aside' ) ;
129135
130136 Docsify . dom . toggleClass ( el , 'search' ) ;
137+ el . setAttribute ( 'role' , 'search' ) ;
131138 Docsify . dom . before ( aside , el ) ;
132139}
133140
@@ -136,12 +143,14 @@ function doSearch(value) {
136143 const $panel = Docsify . dom . find ( $search , '.results-panel' ) ;
137144 const $clearBtn = Docsify . dom . find ( $search , '.clear-button' ) ;
138145 const $sidebarNav = Docsify . dom . find ( '.sidebar-nav' ) ;
146+ const $status = Docsify . dom . find ( 'div.search .results-status' ) ;
139147 const $appName = Docsify . dom . find ( '.app-name' ) ;
140148
141149 if ( ! value ) {
142150 $panel . classList . remove ( 'show' ) ;
143151 $clearBtn . classList . remove ( 'show' ) ;
144152 $panel . innerHTML = '' ;
153+ $status . textContent = '' ;
145154
146155 if ( options . hideOtherSidebarContent ) {
147156 $sidebarNav && $sidebarNav . classList . remove ( 'hide' ) ;
@@ -151,12 +160,12 @@ function doSearch(value) {
151160 return ;
152161 }
153162
154- const matchs = search ( value ) ;
163+ const matches = search ( value ) ;
155164
156165 let html = '' ;
157- matchs . forEach ( post => {
166+ matches . forEach ( ( post , i ) => {
158167 html += /* html */ `
159- <div class="matching-post">
168+ <div class="matching-post" aria-label="search result ${ i + 1 } " >
160169 <a href="${ post . url } ">
161170 <h2>${ post . title } </h2>
162171 <p>${ post . content } </p>
@@ -168,6 +177,8 @@ function doSearch(value) {
168177 $panel . classList . add ( 'show' ) ;
169178 $clearBtn . classList . add ( 'show' ) ;
170179 $panel . innerHTML = html || /* html */ `<p class="empty">${ NO_DATA_TEXT } </p>` ;
180+ $status . textContent = `Found ${ matches . length } results` ;
181+
171182 if ( options . hideOtherSidebarContent ) {
172183 $sidebarNav && $sidebarNav . classList . add ( 'hide' ) ;
173184 $appName && $appName . classList . add ( 'hide' ) ;
0 commit comments