New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #662: 使用方向键翻页 #1118
fix #662: 使用方向键翻页 #1118
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
谢谢,这代码我以前已经写过了,可以直接用。
@@ -4,6 +4,7 @@ | |||
<script async src="//yihui.name/js/no-highlight.js"></script> | |||
<script async src="{{ relURL "/js/pangu.js" }}"></script> | |||
<script src="https://cdn.jsdelivr.net/npm/@xiee/utils/js/heading-anchor.min.js" defer></script> | |||
<script async src="{{ relURL "/js/shortcuts.js" }}"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<script async src="{{ relURL "/js/shortcuts.js" }}"></script> | |
<script src="https://cdn.jsdelivr.net/npm/@xiee/utils/js/post-nav.min.js" defer></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我这个比你的功能多一些。除了文章翻页,首页也能翻页,还添加了提示框。没提示框估计读者也不知道能翻页。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,我抽空看一下。如果能整合到一个脚本中就好了,别人可以复用。谢谢。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可是不同 Hugo 主题里面那些元素的类名不一样,咋复用?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yihui 我已经把你代码抄得差不多了,应该没问题了。
就是这段没看明白在干啥。
// make <pre> focusable | ||
const preElements = document.querySelectorAll("pre"); | ||
preElements.forEach((element) => { | ||
element.setAttribute("tabindex", "0"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tabindex
应该加到主题,此处代码只是临时使用。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不好意思,放这儿太久放忘了。
解决 #662