-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Get featuredImage from assets/ dir or page bundles #759
Open
Tempystral
wants to merge
2
commits into
luizdepra:main
Choose a base branch
from
Tempystral:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I don't know. This looks like overly complicated.
GetMatch
could be a problem, because of its pattern matching it could match with a similarly named file. And,resources.Get
will try to find the image inside theassets
folder, which is not related.I see two possible solutions for your problem.
relURL
from the original line, so you could use relative path to the page and not to the base URL. (It makes sense, but we'll need to removerelUr
from the favicon and avatar code too.)featureImage
such asposts/page-bundle/images/something.jpg
.I don't mind going with the option (1), but people will complain about the breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose I could use a full path in the featured image, it would just be nice to be able to use a relative path like you can with page resources. I definitely don't want to introduce a breaking change.
As for too complicated... I don't know, I feel like it's simple but the inlining makes it look ugly, perhaps. The goal is to enable the option for bundled images with a relative path, and whatever evaluates truthy first is picked.
That said, I've done some more testing and realized that if I define a page resource with the same path, the image doesn't render correctly, so I suppose I can see the issue there.
I think I will just use an absolute path, or override the
single.html
template with my own.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, currently this is a practical option. But let me better check other solution this weekend. I think we could create a custom template to render image links and abstract this code. I'm also thinking that using the asset pipeline for images could be a good idea, but I need to understand it better first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. I'm relatively new to using the asset pipeline as well. If you'd like I can draft something in this PR or we can close it and I'll let you do your thing.