Closed Youdaman closed 5 years ago
I noticed that when I generate a static site with nuxt the resulting feed.xml has the correct symbol […]
so I think if the headers are fixed that will correct the problem!
It might be a non-issue if the problem is only present with npm run dev
-- once you npm run generate
(nuxt generate
) then the resulting /feed.xml file renders correctly as it's a proper XML document as a file.
Should work as expected in production
mode. ☺️
I have the same question in utf-8 encoding.
As the saying by @Youdaman ,there is missing charset=UTF-8
in Content-Type
. The chinese word in my website will be like below :
After I chage the code in the.\node_modules\@nuxtjs\feed\lib\module.js
:
function resolveContentType (type) {
const lookup = {
rss2: 'application/rss+xml;',
atom1: 'application/atom+xml;',
json1: 'application/json;'
}
return (lookup.hasOwnProperty(type) ? lookup[type] : 'application/xml;') + ' charset=UTF-8;'
}
The xml page look fine because there is charset=UTF-8;
in the Content-Type
.
Hope can fix it ,thx!
@zzzzbw Could you send in a PR with tests + a fix for that specific scenario? :thinking:
@zzzzbw Could you send in a PR with tests + a fix for that specific scenario?
I don't know how to write a test because it's work fine in the console but encoding invalid in the chrome
@zzzzbw Hm...
The Feed already specifies UTF-8 encoding.
https://github.com/nuxt-community/feed-module/blob/master/test/__snapshots__/module.test.js.snap#L4
But if that isn't enough as you say, feel free to send in the PR with the change ☺️
@manniL I make a demo show this question: https://codesandbox.io/s/oow0v65vmq
And i will PR the change later.
I noticed when comparing the output of the plugin pulling JSON from a WordPress site vs the WP site's own RSS feed that maybe the encoding and headers aren't 100% correct.
For example
[…]
(the "read more" link) in the WordPress feed display as[…]
with this plugin.So I looked at the response headers and I see that WP uses
content-type: application/rss+xml; charset=UTF-8
while this plugin usesContent-Type: application/rss+xml
-- the charset part is missing.Also, the feed with this plugin shows up as a standard html page not an xml document -- I'm using a colour inverter with Chrome https://chrome.google.com/webstore/detail/dark-reader/eimadpbcbfnmbkopoojfekhnkhdbieeh?hl=en and the feed from this plugin shows up with inverted colours vs the WP feed which shows up as black text on a white background, so this gave me the clue that the browser might be receiving this plugin's feed as HTML not RSS/XML.