-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Check issue with remote resources.Get and Hugo server #9233
Comments
Thanks for your feedback, do you have a link to the RSS feed or a complete example RSS file that is showing them problem? Have you tried dumping the results for debugging using:
|
By using
I am getting a map of the feed. Regarding the image issue I mentioned above, I just realised that most feeds, embed the image inside CDATA typically within the I tried rendering it with: Here are is a sample feed I tested: https://hyperallergic.com/feed/ Of course all of the above is displayed after the project is served as I mentioned above. Anyway, thank you for all your hard work in implementing this feature. P.S. The unmarshall error that I mentioned above still happens. I only get output if I already have the server running and then fetch the remote feed. |
Thanks for the heads up, that sounds like a issue that needs looking into... |
I just figured it out and I am able to render remote images locally with The problem I encountered earlier was CORS related, due to the project's server configuration. Anyway sorry to bother. Again thanks so much for this! The |
This is why the example is using:
The embedding of third party HTML comes with significant security risk and should only be used if you completely trust the source. |
I will try to replicate this issue later today. What is the command you are using to start the server? |
Simply |
Info: I'm planning on doing a Hugo release on Monday. /cc @jmooring |
You can also use this method, which is safer than just including third party HTML on your side. {{ with resources.Get "https://example.com/feed/" | transform.Unmarshal }}
{{ range .channel.item }}
<div style="display: inline-block;">
{{ $desc := (.description | transform.Unmarshal) }}
{{ with resources.Get (index $desc.img "-src") }}
{{ $img := .Fill "200x200 smart" }}
<img src="{{ $img.Permalink }}" style="float: left; margin-right: 10px;"/>
{{ end }}
<div>
<strong>{{ .title | plainify | htmlUnescape }}</strong><br />
<p>{{ .description | plainify | htmlUnescape }}</p>
{{ $link := .link | plainify | htmlUnescape }}
<a href="{{ $link }}">{{ $link }}</a><br />
</div>
</div>
<hr />
{{ end }}
{{ end }} Please note that this downloads and processes images locally, this prevents any CORS issues but keep in mind that images might hold copyrights. You probably want to consider usage and include a copyright notification. |
I have not yet been able to replicate your issue, until now, what operating system are you using? Can you also test with a new hugo site, using the default config? Just to make sure that this is not triggered by any of the config settings. |
Thank you very much for the method you posted above. Your method will be simplifying my workflow. I already sort of anticipated that there was a method to get the This feature is way cooler than I thought. |
Just checked with another skeleton Hugo project, unfortunately again the error is there:
|
I just tested the above method:
Unfortunately I am getting another error.
Apparently
so (just for fun) I tried: just see what might happen and then I got:
|
I think that could happen if the description doesn't contain any HTML, it might need a |
Ok, I will try later today and report back. |
I was able to replicate the |
I have no idea ... I'm on MacOS so I could eventually look at it. |
I forgot to mention that I am on macOS |
I was able to solve the problem by adding the
This doesn't explain why is works after the server is started and why it works on Linux and on Windows. Adding the I will create a pull request to get this sorted. |
@bep Also I just tested the method posted above for downloading and processing images with a feed that contains HTML in the `description element and everything works flawlessly. The Instagram feed I'm checking has a different setup. I suppose that I will figure it out eventually. Thank you both so much. This new feature offers plenty of new possibilities. |
Just in case someone else tries to render an image in Hugo from a remote XML feed and the above method throws the aforementioned error because the input element is perceived as a string, I was able to render the remote image as follows. Template code:
Notes
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using (
hugo version
)?Does this issue reproduce with the latest release?
No
I just built Hugo from source and tested commit 0eaaa8f that introduces XML support in Hugo.
Using the provided example:
Upon first execution of the
hugo server
command I am always getting the following error:<transform.Unmarshal>: error calling Unmarshal: MIME "application/rss+xml" not supported
However if I execute
hugo server
first and then paste the above code and hit save, then the remote RSS output is displayed as expected.Furthermore I am unable to render the contents of the RSS image element from a feed e.g.
I tried
{{ .image.url }}
,{{ .image.title }}
,{{ .image.link }}
.They all return empty. Is rendering of this element supported?
Anyway I thought you may want to know.
cc: @bep @vanbroup
The text was updated successfully, but these errors were encountered: