-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix : add feed icon to rss2.xml #102
Conversation
I configured `feed.icon` in the `config.yml` file but that icon was not exposed when creating the feed xml file. So, I Add in rss2.xml `<url> {{(url + config.feed.icon) | uriencode}} </ url>` and I see that it works.
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.
After this change, it will become impposible to use third-party url of feed icon.
Please use full_url_for()
instead.
|
I installed hexo-util and added the following code to
However, there was an error where |
@sehajyang Try this? First, require hexo-generator-feed/lib/generator.js Line 7 in d169992
const { encodeURL, gravatar, full_url_for } = require('hexo-util'); Then change L38: hexo-generator-feed/lib/generator.js Line 38 in d169992
to: if (feedConfig.icon) icon = encodeURI(full_utl_for.call(this, feedConfig.icon)); You can also include shorter object syntax in this PR: hexo-generator-feed/lib/generator.js Lines 41 to 47 in d169992
to const xml = template.render({
config,
url,
icon,
posts,
feed_url: config.root + feedConfig.path
}); |
@SukkaW |
Unit test is also missing, let me know if you need help creating one. |
@curbengh |
I just added two tests, for atom only. Simply duplicate them (not replace), change the necessary config to A brief guide for using cheerio; atom.xml starts with the following value, <feed xmlns="https://www.w3.org/2005/Atom">
<title>{{ config.title }}</title>
<icon>{{ icon }}</icon> Notice Hint: for subsequent levels, <feed xmlns="https://www.w3.org/2005/Atom">
<title>{{ config.title }}</title>
<foo>
<bar>baz</bar>
<foo> $('feed>foo>bar').text()
// baz |
This reverts commit 07f8b70.
@curbengh |
This PR is an update to hexojs#29. This supposed to be a small PR, but I've encountered some issues regarding the base URL. The `[full_url_for](https://github.com/hexojs/hexo-util/blob/master/lib/full_url_for.js#L27)` function expects the `config.url` not to end with a forward slash. Otherwise it will create a double slash URL, e.g. `http://example.com//atom.xml` (notice that a double slash replacement happens only _after_ the base URL). I was wondering how the icon feature (hexojs#102) can be using `full_url_for` with the current code and not run into any double slash issues. The answer is: it doesn't handle this case. The [unit tests](https://github.com/hexojs/hexo-generator-feed/pull/102/files#diff-910eb6f57886ca16c136101fb1699231R240) are simply running against a custom base URL without an ending slash. I've cleaned up the tests: - removed the ending slash from the base URL - adjusted and added new tests to handle subdirectories correctly (as specified in the [hexo documentation](https://hexo.io/docs/configuration.html#URL)) - hard-coded expected values - it makes a test more reliable and readable
This PR is an update to hexojs#29. This supposed to be a small PR, but I've encountered some issues regarding the base URL. The `[full_url_for](https://github.com/hexojs/hexo-util/blob/master/lib/full_url_for.js#L27)` function expects the `config.url` not to end with a forward slash. Otherwise it will create a double slash URL, e.g. `http://example.com//atom.xml` (notice that a double slash replacement happens only _after_ the base URL). I was wondering how the icon feature (hexojs#102) can be using `full_url_for` with the current code and not run into any double slash issues. The answer is: it doesn't handle this case. The [unit tests](https://github.com/hexojs/hexo-generator-feed/pull/102/files#diff-910eb6f57886ca16c136101fb1699231R240) are simply running against a custom base URL without an ending slash. I've cleaned up the tests: - removed the ending slash from the base URL - adjusted and added new tests to handle subdirectories correctly (as specified in the [hexo documentation](https://hexo.io/docs/configuration.html#URL)) - hard-coded expected values - it makes a test more reliable and readable
This PR is an update to #29. This supposed to be a small PR, but I've encountered some issues regarding the base URL. The `[full_url_for](https://github.com/hexojs/hexo-util/blob/master/lib/full_url_for.js#L27)` function expects the `config.url` not to end with a forward slash. Otherwise it will create a double slash URL, e.g. `http://example.com//atom.xml` (notice that a double slash replacement happens only _after_ the base URL). I was wondering how the icon feature (#102) can be using `full_url_for` with the current code and not run into any double slash issues. The answer is: it doesn't handle this case. The [unit tests](https://github.com/hexojs/hexo-generator-feed/pull/102/files#diff-910eb6f57886ca16c136101fb1699231R240) are simply running against a custom base URL without an ending slash. I've cleaned up the tests: - removed the ending slash from the base URL - adjusted and added new tests to handle subdirectories correctly (as specified in the [hexo documentation](https://hexo.io/docs/configuration.html#URL)) - hard-coded expected values - it makes a test more reliable and readable
I configured
feed.icon
in theconfig.yml
file.but that icon was not exposed when creating the feed xml file.
So, I add in
rss2.xml
:and I see that it works.