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

Determine Relation Between Permalinks and Disk Paths #203

Open
hacdias opened this issue Nov 17, 2023 · 2 comments
Open

Determine Relation Between Permalinks and Disk Paths #203

hacdias opened this issue Nov 17, 2023 · 2 comments

Comments

@hacdias
Copy link
Owner

hacdias commented Nov 17, 2023

There are two problems at play here:

  1. Given a path on disk, what will be the permalink?
  2. Given the permalink, what is the path on disk?

Most things for me have a 1:1 location, but not the posts and the categories. There is a bit of glue to make this work:

eagle/core/parser.go

Lines 72 to 77 in 799ba83

parts := strings.Split(id, "/")
if parts[1] == SpecialSection && !fr.Date.IsZero() {
url.Path = fmt.Sprintf("/%04d/%02d/%02d/%s/", fr.Date.Year(), fr.Date.Month(), fr.Date.Day(), parts[len(parts)-2])
} else {
url.Path = id
}

_, err = fs.GetEntry("/" + core.SpecialSection + "/" + parts[1] + "/" + parts[4])
if err == nil {
return false, "", nil
}

Idea

The idea would be to somehow leverage the information in Hugo configuration and be able to at least, given the path on disk, understand what the permalink is. Then we could either cache it in memory or in the helper database. Seems easy enough. This would help with sending and receiving webmentions, as well as maybe other social protocols in the future.

The hard thing here is to determine the permalink without glue. With glue, it is always possible. But that's not good.

@mvr1k
Copy link

mvr1k commented Nov 17, 2023

Hi @hacdias, can I try solving this ?

@hacdias
Copy link
Owner Author

hacdias commented Nov 17, 2023

@mvr1k you can, but please note that this is a personal project and might not work for everyone, especially if you're not using it.

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