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

Issue 2378 lang level feed config #2400

Open
wants to merge 7 commits into
base: next
Choose a base branch
from

Conversation

SumDonkuS
Copy link

@SumDonkuS SumDonkuS commented Jan 4, 2024

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

Looking at issue 2378 and the related issue 2360, found that there were a few places that needed to check the LangaugeOptions. To handle the change for detecting the settings for feed_filename, the code has been switched to having this config be optional. This also allowed for switching back to the first implementation of the merge_field macro. generate_feed checks both the section for the default language as well as the global area for its config. If it exists in both places an error is thrown for the collision.

  • Are you doing the PR on the next branch?

  • Have you created/updated the relevant documentation page(s)?

No documentation change for this bug fix.

This is my first PR for this project. Please let me know if there is anything that I'm missing. Thank you again for the great project.

.feed_filename
.as_ref()
.map(|ff| path.ends_with(ff))
.unwrap_or_else(|| path.ends_with(DEFAULT_FEED_FILENAME))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe put that as a variable above so the condition is easier to read.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I have that one changed to keep the if statement more readable.

@@ -1022,6 +1029,19 @@ impl Site {
Ok(())
}

pub fn language_feed_filename(&self, lang: &str) -> String {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we not return &str?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Completely spaced that. Thank you for the heads up.

.config
.languages
.get(&self.config.default_language)
.map_or(false, |lang_opt| lang_opt.generate_feed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we do need better config querying based on a language like you did with language_feed_filename.
No need to change anything here, just thinking aloud

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if the change I have is what you were thinking.

…_filename, and modify config querying for generate_feed value lookup.
@SumDonkuS
Copy link
Author

Thank you for catching those things for me. I'll keep a closer eye out for those in the future. Let me know if the modification to querying generate_feed from the config looks like what you were thinking. Thank you again.

@SumDonkuS SumDonkuS requested a review from Keats January 14, 2024 21:16
Copy link
Collaborator

@Keats Keats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's ok. A bit iffy with Option but maybe it's fine

@@ -18,7 +18,7 @@ pub struct LanguageOptions {
pub generate_feed: bool,
/// The filename to use for feeds. Used to find the template, too.
/// Defaults to "atom.xml", with "rss.xml" also having a template provided out of the box.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to change the docstring no?

@@ -66,7 +67,7 @@ pub struct Config {
pub feed_limit: Option<usize>,
/// The filename to use for feeds. Used to find the template, too.
/// Defaults to "atom.xml", with "rss.xml" also having a template provided out of the box.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@SumDonkuS
Copy link
Author

Thank you for spotting those docs. They should now be modified to describe how the default values are handled.

@SumDonkuS SumDonkuS requested a review from Keats January 27, 2024 17:43
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

Successfully merging this pull request may close these issues.

None yet

2 participants