Skip to content

Usage of quicklink#642

Merged
1v9 merged 1 commit intotheme-next:masterfrom
1v9:quicklink
Mar 3, 2019
Merged

Usage of quicklink#642
1v9 merged 1 commit intotheme-next:masterfrom
1v9:quicklink

Conversation

@1v9
Copy link
Member

@1v9 1v9 commented Mar 3, 2019

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines.
  • Tests for the changes was maked (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs in NexT website have been added / updated (for new features).

PR Type

What kind of change does this PR introduce?

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Build related changes.
  • CI related changes.
  • Documentation content changes.
  • Other... Please describe:

What is the current behavior?

#637 introduced per_page: true option to load quicklink on demand, but home page and archive page can't be fully controlled.

What is the new behavior?

  • Now quicklink will load on demand by default.
  • add quicklink: true in front matter for those pages or posts you want.
  • Home page and archive page can be controlled through home: and archive: option.

How to use?

In NexT _config.yml:

quicklink:
  enable: true 
- per_page: true
+ home: true # enable or disable quicklink on home page
+ archive: true # enable or disable quicklink on archive page
# Add `quicklink: true` in front matter to enable quicklink on special page or post

Does this PR introduce a breaking change?

  • Yes.
  • No.

* Remove per_page option

* Add home and archive option
@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

I'm a newbee so I comitted codes many times on a same feature, but I think it's enough now. Most useful functions of quicklink has been implemented. We can control any page or post to load quicklink or not and custom ignore patterns, timeout, privoity. It's done, thank you all.

@stevenjoezhang
Copy link
Contributor

Are custom pages included? (e.g. tags, categories)
See: https://hexo.io/zh-cn/docs/helpers
There are also functions named is_category and is_tag

@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

@stevenjoezhang tags and categories or other pages included, need quicklink: true.
I disabled home page, enable archive page and a post, you can check these URLs.
disable home
enable archive
enable post
enable a custom page
批注 2019-03-03 194044.jpg

Copy link
Member

@ivan-nginx ivan-nginx left a comment

Choose a reason for hiding this comment

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

Need to add docs on NexT site with new settings.

@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

Need to add docs on NexT site with new settings.

I'm waiting for some suggestions 🍵

Copy link
Member

@ivan-nginx ivan-nginx left a comment

Choose a reason for hiding this comment

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

What suggestions? It seems all fine.

@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

@ivan-nginx Some pages with deeper level URLs won't be controlled, they never load quicklink, maybe it's not important?
Like /categories/xxx/ or yearly archive page.

@ivan-nginx
Copy link
Member

ivan-nginx commented Mar 3, 2019

Oh, it's bad. Why they want be controlled?


/categories/xxx/ or same with tags – i think not actually important.
Important is subpages, e.g. https://theme-next.org/docs/third-party-services/ Is that pages working fine?

@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

Any page or post has index.md, they can be controlled.
I enabled quciklink on https://1v9.im/test/ https://1v9.im/test/sub1/sub2/ and disabled quicklink on https://1v9.im/test/sub1/
You can check now.

@1v9 1v9 merged commit 511d788 into theme-next:master Mar 3, 2019
1v9 added a commit to theme-next/theme-next.org that referenced this pull request Mar 3, 2019
@ivan-nginx
Copy link
Member

So, if I want to enable qicklink for all pages/posts without front-matter editing for pages, will it work?

@1v9
Copy link
Member Author

1v9 commented Mar 3, 2019

@ivan-nginx It won't, in previous version we can globally load quicklink but couldn't control home and archive page fully, so I commit this PR. I think editing scaffolds/page.md or post.md is good.

---
title: {{ title }}
date: {{ date }}
comments: false
quicklink: true
---

@ivan-nginx
Copy link
Member

Maybe need to add option for global usage, like in MathJax? Why you remove per_page option?

@1v9 1v9 deleted the quicklink branch March 3, 2019 18:46
@1v9
Copy link
Member Author

1v9 commented Mar 4, 2019

@ivan-nginx At first I followed the code of mathjax and pdf.js, they all have the per_page option but not truely load on demand especially home page & archive page. Also quicklink itself is a radical plugin, if want best effect we need set proper Cache-Control header on own Web Server or 3rd-party Hosting.

By now we have these options, they are "descending":

quicklink:
  # which page or post load quicklink
  enable: true # On-off
  home: true # load in home or not
  archive: true # load in archive or not

 # load quicklink
  delay: true # page loaded or not -> initialize
  timeout: 3000 # timeout -> execute prefetching
  priority: true # fetch -> XHR
  ignores: # custom ignore patterns # current page's URL and URLs include '#' have been ignored by default.

@liolok liolok changed the title Refactor: Improve usage of quicklink Improve usage of quicklink Mar 31, 2019
@liolok liolok changed the title Improve usage of quicklink Usage of quicklink Mar 31, 2019
@liolok liolok changed the title Usage of quicklink Usage of quicklink Mar 31, 2019
tongluyang pushed a commit to tongluyang/hexo-theme-next that referenced this pull request Nov 19, 2019
* Remove per_page option (theme-next#637 )

* Add home and archive option
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants