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

Feature Request: Edit this page #47

Closed
saurabh-sm opened this issue Sep 21, 2023 · 16 comments
Closed

Feature Request: Edit this page #47

saurabh-sm opened this issue Sep 21, 2023 · 16 comments

Comments

@saurabh-sm
Copy link

Paige is a great theme for personal and technical blogs. A reader may want to update a part of the webpage where the information is outdated, incorrect, etc.

Providing a link to the markdown file in the repository is helpful as the reader can create an issue, pull request, etc.

@willfaught
Copy link
Owner

Hi @saurabh-mish, if you enable Git info with hugo server --enableGitInfo, you can click the time on a page to go to the latest commit for that page. Does that meet this need?

@saurabh-sm
Copy link
Author

saurabh-sm commented Sep 22, 2023

I ran

hugo server --enableGitInfo --buildDrafts --ignoreCache --cleanDestinationDir

but don't see the time on any page.

I have

[params.paige.git]
commit_url = "https://codeberg.org/mishra/patterns.se/%s"

in my config file.

Am I missing a configuration and is this correct given that the view file URL for

  • GitHub is

    https://github.com/USERNAME/REPOSITORY_NAME/blob/BRANCH_NAME/.gitignore
    
  • and Codeberg is

    https://codeberg.org/USERNAME/REPOSITORY_NAME/src/branch/BRANCH_NAME/.gitignore
    

and edit file URL for

  • GitHub is

    https://github.com/USERNAME/REPOSITORY_NAME/edit/BRANCH_NAME/.gitignore
    
  • and Codeberg is

    https://codeberg.org/USERNAME/REPOSITORY_NAME/_edit/BRANCH_NAME/.gitignore
    

?

@willfaught
Copy link
Owner

willfaught commented Sep 22, 2023

I meant page date, not time. It's displayed between the page authors and reading time rows, below the page title and description. It's shown by default, but you may have hidden it in your style settings. The %s in commit_link will be replaced with the commit hash, and the date will be wrapped in an anchor that references that link. It won't be a direct link to edit the page in GitHub, though. So users would need to take an extra step to edit the file.

For Codeberg, it looks like the commit_url should be https://codeberg.org/mishra/patterns.se/commit/%s.

@willfaught
Copy link
Owner

It looks like there's a way to get the file path for a page, so it's possible to add an edit link. I don't know off the top of my head where it should go, or how it should be represented, though. I almost didn't include the commit link because I wasn't sure how to represent it, and I'm still not happy about using the date for it. I don't want to clutter the metadata or footer unnecessarily. I'll have to give it some thought.

How were you thinking the link would be presented?

@saurabh-sm
Copy link
Author

I meant page date, not time. It's displayed between the page authors and reading time rows, below the page title and description. It's shown by default, but you may have hidden it in your style settings. The %s in commit_link will be replaced with the commit hash, and the date will be wrapped in an anchor that references that link. It won't be a direct link to edit the page in GitHub, though. So users would need to take an extra step to edit the file.

I removed layouts/partials/ directory, but see everything except the date. I have also set

[paige.date]
format = ":date_long" # Hugo date format

in the config.

For Codeberg, it looks like the commit_url should be https://codeberg.org/mishra/patterns.se/commit/%s.

I've updated the config, but it doesn't seem to work.

How were you thinking the link would be presented?

There could be "Edit this page", which works like this - its towards the bottom on the left side.

For the representation: the author(s) could be on the left side, reading time in the center, and "Edit this page" on the right. Paige is using a good amount of width which could be used to represent this information horizontally.

@willfaught
Copy link
Owner

I removed layouts/partials/ directory, but see everything except the date.

You can see the date on https://willfaught.com/paige/customization/show/: "February 1, 2023"

I've updated the config, but it doesn't seem to work.

What are your style overrides? Have you set paige.style in page front matter or site params? Have you overridden style.html?

If you look at the HTML with the inspector, do you see the element for the date?

@willfaught
Copy link
Owner

Added in the latest version, v0.70.0. See the new paige.link configuration.

@saurabh-mish Can you confirm it works for you?

@saurabh-sm
Copy link
Author

What are your style overrides? Have you set paige.style in page front matter or site params? Have you overridden style.html?

I don't have any style overrides configured. I've also not set paige.style in the front matter because I can't find it in the README. And I've not overridden style.html

Added in the latest version, v0.70.0. See the new paige.link configuration

Quick question about the paige.link configuration - the URL documented is of type:

https://github.com/USERNAME/REPOSITORY_NAME/edit/BRANCH_NAME/content/%s

but when I open the edit link for a README.md file located at the repository root, the URL is of type:

https://github.com/USERNAME/REPOSITORY_NAME/edit/BRANCH_NAME/README.md

why is there an extra context content after BRANCH_NAME in the documentation ?

I have added the below in hugo.toml, but don't see "Edit this page":

[paige.link]
content = "Edit this page"
hide_page = false
url = "https://codeberg.org/mishra/patterns.se/_edit/main/%s"

@saurabh-sm
Copy link
Author

Can you add "Edit this page" to an existing page in exampleSite?

@willfaught
Copy link
Owner

I've also not set paige.style in the front matter because I can't find it in the README

For reference, it's here: https://github.com/willfaught/paige/blob/master/README.md?plain=1#L184

You don't have any dates set in your published pages' front matter, which is why no dates are showing.

why is there an extra context content after BRANCH_NAME in the documentation ?

I added a bit more documentation: 254710f.

The %s is replaced with the path to the file relative to the content directory, which means that the content directory should be in your URL. You can't refer to a file outside of the content directory, because by definition it's not a rendered page.

For https://codeberg.org/mishra/patterns.se/src/branch/main/content/_index.md, you probably want https://codeberg.org/mishra/patterns.se/_edit/main/content/%s. I can't verify because I don't have a Codeberg account.

@saurabh-sm
Copy link
Author

saurabh-sm commented Oct 10, 2023

You don't have any dates set in your published pages' front matter, which is why no dates are showing.

Gotcha! I have set date in the archetype and also have #paige-date, in layouts/partials/Paige/style-first.css to hide dates in individual pages and also .paige-date, to hide dates in list pages.


https://codeberg.org/mishra/patterns.se/_edit/main/content/%s doesn't work either.

@saurabh-sm
Copy link
Author

If you have an "Edit this page" in the exampleSite, please point me towards it so that I can ask about it in Codeberg groups.

@willfaught
Copy link
Owner

I added file link examples to https://willfaught.com/paige/customization/ and its sub-pages.

@willfaught
Copy link
Owner

Note that paige.link was renamed to paige.file_link.

@willfaught
Copy link
Owner

And paige.link.hide_page was renamed to paige.file_link.disable.

@saurabh-sm
Copy link
Author

saurabh-sm commented Oct 12, 2023

Thanks a lot @willfaught!

I added file link examples to https://willfaught.com/paige/customization/ and its sub-pages.

This was very helpful.

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