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

Feature request - custom page pagination, for data files #3423

Closed
msanatan opened this Issue Jan 20, 2019 · 5 comments

Comments

2 participants
@msanatan
Copy link

msanatan commented Jan 20, 2019

Environment Info

Node version(node -v): v11.1.0

Your site _config.yml (Optional):

Your theme _config.yml (Optional):

Hexo and Plugin version(npm ls --depth 0):
├── hexo@3.8.0
├── hexo-deployer-git@0.3.1
├── hexo-generator-archive@0.1.5
├── hexo-generator-category@0.1.3
├── hexo-generator-feed@1.2.2
├── hexo-generator-index@0.2.1
├── hexo-generator-search@2.4.0
├── hexo-generator-sitemap@1.2.0
├── hexo-generator-tag@0.2.0
├── hexo-pagination@0.1.0
├── hexo-renderer-ejs@0.3.1
├── hexo-renderer-marked@0.3.2
├── hexo-renderer-stylus@0.3.3
└── hexo-server@0.3.3

For question

Hi,

How do I add pagination to a custom page? This was asked in issue #1743 but my situation is a bit different. I already have an archive page set up for my posts https://msanatan.com/archives/. I write blog posts for another website and would like my main blog to link to them.

The blog posts in the alternative site are stored as JSON, and my template loops through the JSON to create a page similar to archives https://msanatan.com/other-writing/. Unfortunately, the page variables used in pagination are only available to index and archive layouts.

I noticed this library https://github.com/hexojs/hexo-pagination but I'm not sure how to use it at the theme level to get pagination on my custom page. Any advice?

@tcrowe

This comment has been minimized.

Copy link
Contributor

tcrowe commented Jan 20, 2019

I have an idea @msanatan 🤔


  1. Create new posts for these items if they are not already:
  • 2018-12-09 Building a GraphQL API with Django
  • 2018-11-27 Saving Text, JSON, and CSV to a File in Python

  1. Assign them the category "Other Writing" in the front-matter AND a custom URL field link:
---
title: Building a GraphQL API with Django
date: 2019-01-20 16:34:58
categories: ["Other Writing"]
link: https://stackabuse.com/building-a-graphql-api-with-django/
---

Categories can be like this:

categories:
- Other Writings

Or this:

categories: ["Other Writing"]

Your preference!

The link: https://... config is common to some themes for external URL post.


  1. Change this url in the nav: https://msanatan.com/other-writing/

To this: https://msanatan.com/categories/other-writing/

Now that should be paginated.


  1. Optionally filter any posts with link field from home/index template posts query. Optionally put external link URL into the link with target="_blank".

Some unicode icons:

  • ↗️

Source: https://stackoverflow.com/questions/1899772/new-window-icon-for-web-accessibility


If you're able to change it from JSON into hexo posts this might work. Could you see if this solution works for your site?

It's a nice clean theme. Is that in the themes section or did you make it?


Take care 👋🏻

@msanatan

This comment has been minimized.

Copy link
Author

msanatan commented Jan 21, 2019

Hey @tcrowe, thanks for your quick reply! I got to step out for a bit but I'm pretty excited to try it out your suggestion when I reach back :-).

I forked the theme from https://github.com/probberechts/hexo-theme-cactus, which I found on the themes section on the website. I only made some modifications to change the logo and have a contact page, all credit goes to probberechts!

@tcrowe

This comment has been minimized.

Copy link
Contributor

tcrowe commented Jan 21, 2019

msanatan added a commit to msanatan/msanatan.github.io that referenced this issue Jan 21, 2019

Add stack abuse posts as links
Awesome suggestion by @tcrowe on my GitHub issue:
hexojs/hexo#3423
@msanatan

This comment has been minimized.

Copy link
Author

msanatan commented Jan 21, 2019

Hey @tcrowe, your suggestion worked like a charm. I modified my web scraper to produce markdown files with an 'other' category (didn't seem to like the 2 words but no worries) and made the necessary theme changes. It's also more sustainable as I may write to other sources as well, this is a great way to pull them together.

Thanks again!

@msanatan msanatan closed this Jan 21, 2019

@tcrowe

This comment has been minimized.

Copy link
Contributor

tcrowe commented Jan 21, 2019

@msanatan I am happy this solution worked. Thank you for following up with me and closing out the issue. Msg us again any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment