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

List pages by weight doesn't work #60

Closed
saurabh-sm opened this issue May 26, 2024 · 8 comments
Closed

List pages by weight doesn't work #60

saurabh-sm opened this issue May 26, 2024 · 8 comments

Comments

@saurabh-sm
Copy link

saurabh-sm commented May 26, 2024

Steps to Reproduce

  • Clone the Paige repository and navigate to the exampleSite/ directory

  • Create a new page in the content section

    hugo new content/content/test-page.md
    
  • Modify file ./content/content/rich-content.md by removing:

    ## Twitter Simple Shortcode
    
    {{< twitter_simple user="DesignReviewed" id="1085870671291310081" >}}
    
    <br>
    
    ---
    

    to fix error ERROR error calling resources.GetRemote ...

  • In the front matter of test-page.md, change draft to false and ensure that it's weight is more than all other pages (eg: 100)

  • Run the server and navigate to https://localhost:1313/content/

  • The page "Test Page" is listed at the top instead of the bottom, even though it has the maximum weight

Observation

List pages by weight only works if the month and year of all pages in the directory are the same.

Related

#50

@willfaught
Copy link
Owner

Hi @saurabh-sm, thanks for the repro steps, but I can't reproduce this.

I created exampleSite/content/content/test-page.md with:

---
date: "2023-09-25T21:29:31-07:00"
description: "Only a test."
draft: false
title: "Test"
weight: 100
---
Test

and I see it listed at the bottom of the list, as expected:

Screenshot 2024-05-28 at 12 58 35 AM

@willfaught
Copy link
Owner

I also tried setting the page's year to 2020, but I still see it listed last.

@saurabh-sm
Copy link
Author

saurabh-sm commented May 28, 2024

Hi @willfaught,

Hugo's default archetype looks like:

+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = true
+++

which means that when hugo new content/content/test-page.md is run, the date would correspond to today's date, not September 2023.

It looks like you've edited the date manually to September 2023.

@saurabh-sm
Copy link
Author

saurabh-sm commented May 28, 2024

I also tried setting the page's year to 2020, but I still see it listed last.

Can you try changing the year to 2024 and see where it ends up ? I'm also curious to see what your archetype looks like.


The point is that front matter other than title, date, and draft will need to be added to an archetype. For example, my archetype looks like:

+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = false
description = 'Brief description for {{ replace .File.ContentBaseName "-" " " }}'
authors = ['john', 'jane']
categories = ['foo']
tags = ['bar']
weight = 50
[paige]
style = """
#paige-authors,
#paige-keywords,
#paige-toc,
#paige-date,
.paige-authors,
.paige-keywords,
.paige-date,
"""
[paige.file_link]
disable = false
+++

The key thing to note here is the date. I can think of people changing the date format, but can't imagine people manually editing the date after a page gets created.

@willfaught
Copy link
Owner

My apologies. You were right. The issue was the current date from the archetype. I can reproduce the issue. This should be fixed in v0.76.1. Can you confirm?

@willfaught
Copy link
Owner

By the way, you can style #paige-authors, #paige-keywords, etc. for all pages in https://github.com/willfaught/paige/blob/master/exampleSite/layouts/partials/paige/style-first.css.

@saurabh-sm
Copy link
Author

My apologies. You were right. The issue was the current date from the archetype. I can reproduce the issue. This should be fixed in v0.76.1. Can you confirm?

Yes, it works !! Thanks a lot

(Personal reference for the future)

hugo mod get -u github.com/willfaught/[email protected]

By the way, you can style #paige-authors, #paige-keywords, etc. for all pages in https://github.com/willfaught/paige/blob/master/exampleSite/layouts/partials/paige/style-first.css.

I'm not sure how to get this to work. My archetype/default.md looked like:

+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
date = {{ .Date }}
draft = false
description = 'Brief description for {{ replace .File.ContentBaseName "-" " " }}'
authors = ['john', 'jane']
categories = ['foo']
tags = ['bar']
weight = 50
[paige]
style = """
#paige-authors,
#paige-keywords,
#paige-toc,
#paige-date,
.paige-authors,
.paige-keywords,
.paige-date,
"""
[paige.file_link]
disable = false
+++

which I changed to:

+++
title = '{{ replace .File.ContentBaseName "-" " " | title }}'
description = 'Brief description for {{ replace .File.ContentBaseName "-" " " }}'
date = {{ .Date }}
authors = ['john', 'jane']
categories = ['foo']
tags = ['bar']
weight = 50
[paige.file_link]
disable = false
+++

and updated layouts/partials/paige/style-first.css to:

#paige-authors,
#paige-keywords,
#paige-toc,
#paige-date,
.paige-authors,
.paige-keywords,
.paige-date,

but the result is not the same.

Moving this question to the F.A.Q section.

@willfaught
Copy link
Owner

Looks like you got it working in the discussion you opened.

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

No branches or pull requests

2 participants