Giter Club home page Giter Club logo

Comments (6)

Keats avatar Keats commented on May 9, 2024

Good point, I'll fix that

from zola.

Keats avatar Keats commented on May 9, 2024

That's actually quite tricky!
We need to render pages from the render_sections so we can sort/populate prev/next correctly but we also want to render correctly prev/next for the index page if we don't have a section for content like my site.
So we would have 2 spots to render a page: render_section and build_pages. render_section needs to be called first and build_pages can check whether the file already exists and if not, populate with "global" previous/next and render the page.

The index page does seem a bit too magical looking at the above, I'll need to think a bit more on what would be the best behaviour for it. Maybe I was thinking too much about how Hugo does it while it could be done better.

from zola.

Keats avatar Keats commented on May 9, 2024

(writing down some thoughts)

So after some thoughts the problem boils down to the differences between a simple case (blog + about page) and more complex cases such as blog + landing page + knowledge base for example. Your blog is a bit towards the simple case where you have a few sections that you want to order separately but never together. It's more a documentation site in this regard.
I can't think of a single case where you would to mix sections automagically in the index page though.

A few solutions came to mind but after writing this only one didn't feel like a hack, let's take a simple case as example since this is where the confusion comes I think.

content/
  - _index.md
  - one-blog-post.md
  - another-blog-post.md
  - pages/
       - about.md
       - projects.md

Make index a (almost) pure section

Which means it won't automatically get variables like pages at all. The index will still get variables like sections but it will only get pages directly next to the content/_index.md. In the example, section.pages in the landing page will contain one-blog-post and another-blog-post and a user would iterate like so:

{% for page in section.pages %}...{% endfor %}

The index section may or may not be contained in the sections variable passed to the template, I'm not convinced about the necessity of doing that yet.
Pages will be sorted by the index section depending on the sort_by parameter and prev/next will always only apply inside a section only.

I think this approach solves most of the issue and will do what people expect to most of the time. It's not as straightforward as Hugo might be but I believe it's not that far in practice and removes ambiguity for the index page.

from zola.

Keats avatar Keats commented on May 9, 2024

The last question to solve for it to make sense is what to do with pages with no sections (orphan pages). Those should still be rendered but won't be listed in any section.pages.

The easiest way would be to find make the list of pages in sections and compare those missing from the full list of pages and render the orphan pages after rendering all sections.

from zola.

Keats avatar Keats commented on May 9, 2024

Implementation is in #60 which should also fix what this issue is about!
I'll need to test it a bit more myself though.

from zola.

Keats avatar Keats commented on May 9, 2024

@phil-opp it should be working in master

Edit: also in 0.0.5 that was just released

from zola.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.