Skip to content
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

Merged
merged 7 commits into from Apr 14, 2024

Conversation

CyrusYip
Copy link
Contributor

@CyrusYip CyrusYip commented Nov 13, 2023

解决 #662

Copy link
Member

@yihui yihui left a 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>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<script async src="{{ relURL "/js/shortcuts.js" }}"></script>
<script src="https://cdn.jsdelivr.net/npm/@xiee/utils/js/post-nav.min.js" defer></script>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我这个比你的功能多一些。除了文章翻页,首页也能翻页,还添加了提示框。没提示框估计读者也不知道能翻页。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,我抽空看一下。如果能整合到一个脚本中就好了,别人可以复用。谢谢。

Copy link
Contributor Author

@CyrusYip CyrusYip Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可是不同 Hugo 主题里面那些元素的类名不一样,咋复用?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihui 我已经把你代码抄得差不多了,应该没问题了。

https://github.com/yihui/misc.js/blob/83b2aea9132d522ff8260df6df8ebdc874fad62d/js/post-nav.js#L15-L21

就是这段没看明白在干啥。

Comment on lines +53 to +57
// make <pre> focusable
const preElements = document.querySelectorAll("pre");
preElements.forEach((element) => {
element.setAttribute("tabindex", "0");
});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tabindex 应该加到主题,此处代码只是临时使用。

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不好意思,放这儿太久放忘了。

@yihui yihui merged commit 01cc1e1 into cosname:master Apr 14, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants