ParitoshBh / grav-coder

https://paritoshbh.me
MIT License
28 stars 8 forks source link

Previous / Next Article function won't work #31

Open guime7000 opened 1 year ago

guime7000 commented 1 year ago

Hi !

Thanks for the work on grav-coder, I really like the sobriety of your theme !

Don't know if this should be a PR or if it's an issue due to a misconfiguration or misunderstanding of how the theme is working....

I've been in trouble to make the previous / next Article function work. Related links were always corresponding to the current article URL. I'm using Grav v1.7.38.

I managed to get it work modifying the file navigation.html.twig in /grav-coder/templates/partials/item/

I replaced page.prevSibling().slug (resp. nextSibling)

with page.parent().children().prevSibling(page.path).url (resp. nextSibling)

and...tadam, it worked....

ParitoshBh commented 1 year ago

Pagination logic is already there in the theme itself. You shouldn't have needed to make the changes you made.

Can you please confirm if,

  1. you've followed the instructions as mentioned under Blog (Listing) Setup?
  2. you've updated grav-coder.yaml to include following config,
    post:
    navigation: true
guime7000 commented 1 year ago

Hi !

My directory and file structure is :

mygrav/
└── grav-admin/
    └── user/
        └── pages/
            ├── 01.blog/
            │   ├── 02.dir1/
            │   │   └── item.md
            │   ├── 03.dir2/
            │   │   └── item.md
            │   ├── 04.dir3/
            │   │   └── item.md
            │   └── blog.md
            └── 02.Typography

Inside 01.blog directory, my blog.md contains :

---
 content:
     items: '@self.children'
     order:
         by: date
         dir: desc
     limit: 10
     pagination: true
 metadata:
   description: 'Some description for metadata'
 ---

and my grav-coder.yaml file inside mygrav//grav-admin/user/themes/grav-coder/ contains :

enabled: true
dropdown:
  enabled: true
navbar:
  title: MyTitle
#  url: https:/myurl/blog
#  rel: me
  auth_link:
    enabled: false
    login_slug: login
    login_label: Login
#footer:
#  copyright: Grav Coder

social:
  github:
    title: Github
    url: https://mygithubURL
    icon: fab fa-github
    rel: me
  linkedin:
    title: LinkedIn
    url: https:/myLinkedInURL
    icon: fab fa-linkedin-in
    rel: me
post:
  navigation: true
  taxonomy: true
#listing_title:
#  taxonomy:
#    category: 'Category: '
#    tag: 'Tag: '
#  blogs: 'Posts'
pages:
  order:
    by: default
    dir: asc

pagination:
  count: 10

So where could be my mistake(s) ?

ParitoshBh commented 1 year ago

I tested your setup with grav version 1.7.35 and 1.7.38 and the navigation links work just fine. And your configs seem to be fine as well. The directory structure however, seems interesting. Since I cannot reproduce it on my end, would you be able to share a bare minimum zip of your setup?

guime7000 commented 1 year ago

For sure ! Tell me what you need in the zip file, and I'll attach it !

ParitoshBh commented 1 year ago

Based on your file structure, I would say a zip of mygrav directory. Please redact any private information and if you aren't comfortable sharing zip here (or it is too big), feel free to send it to my email paritoshbh [at] outlook [dot] com

oldstonegryzzly commented 5 months ago

I have the same problem, partially resolved with page.parent().children().prevSibling(page.path).url but {% if not page.isLast %} and {% if not page.isFirst %} dont work properly : next and prev they also remain on the first and last page.

edit:

next and prev work fine with: {% if not page.parent().children().isFirst(page.path) %}

Grav 1.7.46 - Admin v1.10.46

thanks for your works and sorry for my bad english...