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

pagevar fails to retrive variables randomly #937

Closed
newptcai opened this issue Dec 27, 2021 · 10 comments
Closed

pagevar fails to retrive variables randomly #937

newptcai opened this issue Dec 27, 2021 · 10 comments

Comments

@newptcai
Copy link

I tried to update my website to use latest Franklin. But I found a weird bug. The following code failed to retrieve page variables currently.

posts = filter!(p -> endswith(p, ".md") && p != "index.md", readdir("blog"))
dates  = Vector{Date}(undef, length(posts))
lines = Vector{String}(undef, length(posts))
indices  = Vector{Tuple{Date, String}}(undef, length(posts))
for (i, post) in enumerate(posts)
    ps  = splitext(post)[1]
    url = "/blog/$ps/"
    surl = strip(url, '/')
    title = pagevar(surl, :title)
    pubdate = pagevar(surl, :pubdate)
    if isnothing(pubdate)
        dates[i] = Date("2021-01-01")
    else
        dates[i] = Date(pubdate)
    end
    lines[i] = "\n* [$title]($url)\n"
    indices[i] = (dates[i], title)
end

For some pages, title = pagevar(surl, :title) will return nothing. And for which pages this happens is random if you run serve(clear=true). The line pubdate = pagevar(surl, :pubdate) also fails at random even when pubdate is defined.

To reproduce this error, you can clone my website, and update to v0.10.65. The run the website.

@tlienart
Copy link
Owner

tlienart commented Dec 30, 2021

Please use @delay in front of the hfun that makes use of all the pagevar so

@delay function hfun_***...
...
end

(ex:

@delay function hfun_case_2()
all_tags = globvar("fd_page_tags")
(all_tags === nothing) && return ""
all_tags = union(values(all_tags)...)
tagstr = strip(prod("$t " for t in all_tags))
return """<p style="color:red;">tags: { $tagstr }</p>"""
end
)

@Wikunia
Copy link
Contributor

Wikunia commented Jan 2, 2022

Just encountered this as well. I thought pagevar checks if the variable is already there and if not parses the markdown file to retrieve it. Also @delay doesn't seem to work in my case.

That would be consistent with the docstring for pagevar as well.

@newptcai
Copy link
Author

newptcai commented Jan 3, 2022

Adding @delay does not change anything for me neither.

@tlienart
Copy link
Owner

tlienart commented Jan 3, 2022

@newptcai same suggestion as I made to @Wikunia ; for now please pin Franklin to 0.10.58 if things used to work for you but don't anymore now.

The next version will be released soon and fixes this pagevar stuff so this workaround should hopefully be ok in the meantime

@newptcai
Copy link
Author

newptcai commented Mar 8, 2022

@tlienart Any update?

@tlienart
Copy link
Owner

tlienart commented Mar 8, 2022

did you do the version pinning suggested above? (both locally & in the deploy script).

There's not much point in me fixing this in depth for Franklin 0.10.x given that it's already fixed for the upcoming version which is being tested (you can test it as well if you want but if you just want a quick fix, just pin the version).

@newptcai
Copy link
Author

newptcai commented Mar 8, 2022

Yes, I pinned the version and it works now. How can I test the upcoming version?

@tlienart
Copy link
Owner

tlienart commented Mar 8, 2022

👍 I'll close this issue.

If you want to test the new version, have a look at this repository, please read the README as it contains information about the migration and what users should be careful about. Also if you intend to use it, please join the slack channel #xranklin for questions.

We're still at beta-testing stage so if you'd rather stick with something that works most of the time (even though Xranklin should, you'll have to adjust a few things, there's also a few features missing), I'd suggest sticking with the pinned version of Franklin for another couple of months.

@maleadt
Copy link

maleadt commented Jun 23, 2022

Why is this closed? The bug is still present on current master, and adding @delay (to this function) doesn't help). The release notes now mention this as being fixed in v0.10.72, which is wrong.

@tlienart
Copy link
Owner

tlienart commented Jun 23, 2022

Hello @maleadt, sorry for the frustration, I'd recommend you pin Franklin to 10.58 + use @delay and check if that helps for the time being.

This problem has been fixed by overhauling the entirety of the pagevar logic in the upcoming new release which is in prep at Xranklin.jl. It's pretty much ready bar a few minor stuff I need to find some time to complete.

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

4 participants