Improve accessibility (#597)

This commit is contained in:
Mimi 2022-11-21 15:19:44 +08:00 committed by GitHub
parent e9a1268c0d
commit aa6da25f89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 9 deletions

View File

@ -28,7 +28,7 @@
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
<div class="toggle popup-trigger" aria-label="{{ __('menu.search') }}" role="button">
{%- if theme.algolia_search.enable or theme.local_search.enable %}
<i class="fa fa-search fa-fw fa-lg"></i>
{%- endif %}

View File

@ -1,12 +1,5 @@
{%- if page.prev or page.next %}
<nav class="pagination">
{{
paginator({
prev_text: '<i class="fa fa-angle-left" aria-label="' + __('accessibility.prev_page') + '"></i>',
next_text: '<i class="fa fa-angle-right" aria-label="' + __('accessibility.next_page') + '"></i>',
mid_size : 1,
escape : false
})
}}
{{ next_paginator() }}
</nav>
{%- endif %}

View File

@ -0,0 +1,18 @@
/* global hexo */
'use strict';
hexo.extend.helper.register('next_paginator', function() {
const prev = this.__('accessibility.prev_page');
const next = this.__('accessibility.next_page');
let paginator = this.paginator({
prev_text: '<i class="fa fa-angle-left"></i>',
next_text: '<i class="fa fa-angle-right"></i>',
mid_size : 1,
escape : false
});
paginator = paginator
.replace('rel="prev"', `rel="prev" title="${prev}" aria-label="${prev}"`)
.replace('rel="next"', `rel="next" title="${next}" aria-label="${next}"`);
return paginator;
});