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

Beginner issue: List page title appears as literal filename in a different list #790

Open
ashprice opened this issue Aug 21, 2020 · 0 comments

Comments

@ashprice
Copy link

Hello,

Sorry if this is the wrong place to ask, I am new to Haskell and new to Hakyll and am trying my best to learn both.

On my index page, I have a list of pages in directory 1. I would like this list to include a link to a page that gives a list of pages in directory 2. (I do not mind where this page is, but I've got it in directory 1 at the moment.)

    create ["misc/scratchpad.html"] $ do
        route idRoute
        compile $ do
            list <- padList tags "scratchpad/*" alphaOrder
            makeItem list
                >>= loadAndApplyTemplate "templates/posts.html" allPadCtx
                >>= loadAndApplyTemplate "templates/not-index.html" allPadCtx
                >>= loadAndApplyTemplate "templates/default.html" allPadCtx
                >>= relativizeUrls
...
                mkmisc = miscList tags "misc/*" alphaOrder
...

This, strictly speaking, works. However, the filename appears as a literal string rather than constField "title" (which is set correctly, as it is populated on the page.) Naturally it looks messy if I have a list like:

  • Here is page one
  • Here is page two
  • here-is-page-three

My solution was just to rename the file to a single word, but the alphaOrder implementation is capitals-sensitive.

alphaOrder :: [Item a] -> Compiler [Item a]
alphaOrder items = return $
    sortBy (comparing (takeBaseName . toFilePath . itemIdentifier)) items

I tried fiddling around with the page creation but given that the title field is set correctly I think I was barking up the wrong tree.
I would appreciate any pointers on how I might implement this, and thanks in advance. Sorry if this is plainly stated in the documentation and I have missed it; I found a blog post that did something similar to this, but ultimately I couldn't figure it out from that.

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

1 participant