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

Feature: add per-feed custom titles and abstracts #295

Merged
merged 8 commits into from
Jun 16, 2024

Conversation

toomanybrians
Copy link
Contributor

@toomanybrians toomanybrians commented Jun 15, 2024

This pull request allows an RSS feed to override the MkDocs default site_name: and/or site_description: settings to allow feed-specific titles and descriptions. This is useful when multiple instances of the plugin are used (for example, one for blog posts and another for doc updates), as it will allow RSS feed subscribers to know which feed is which.

It's also useful even with a single instance of the plugin, since sometimes the site title or description is SEO-optimized, while the RSS feed might want shorter or alternate versions.

To use this capability, add a feed_title: and/or feed_description: setting to the RSS feed plugin settings. If either of these keys is not included, the previous behavior of using the site-wide versions is used. This feature does not change any behavior of any existing configs.

A minimal example:

site_name: My awesome website
site_description: Obviously the best website that exists, because MkDocs is awesome!

plugins:
  - search
  - rss:
      match_path: blog/posts/.*      
      feed_title: My awesome blog feed
      feed_description: The best blog from the best site
  - rss:
      match_path: guide/.*      
      feed_title: Doc updates from the best site
      feed_description: Provides updates to documentation on this great site

I have updated the documentation, and also added tests.

(Comment updated to reflect latest changes to the PR)

toomanybrians and others added 3 commits June 15, 2024 11:32
Adds new `title:` and `description` options to the plugin which will be used in the generated feeds. If these keys are not present, the default MkDocs site-wide `site_title:` and `site_description:` will be used.
@github-actions github-actions bot added documentation Improvements or additions to documentation enhancement New feature or request quality Tests, project resiliency, etc. labels Jun 15, 2024
Copy link

codecov bot commented Jun 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.55%. Comparing base (7aa5e99) to head (1c17192).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   80.49%   80.55%   +0.06%     
==========================================
  Files           9        9              
  Lines         610      612       +2     
  Branches      127      127              
==========================================
+ Hits          491      493       +2     
  Misses         82       82              
  Partials       37       37              
Flag Coverage Δ
unittests 80.55% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
mkdocs_rss_plugin/config.py 100.00% <100.00%> (ø)
...lugin/integrations/theme_material_social_plugin.py 76.42% <ø> (ø)
mkdocs_rss_plugin/plugin.py 90.69% <ø> (ø)
mkdocs_rss_plugin/util.py 73.12% <ø> (ø)

@Guts Guts self-requested a review June 15, 2024 16:04
Copy link
Owner

@Guts Guts left a comment

Choose a reason for hiding this comment

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

Hi @toomanybrians

Thanks for your interest and your great contribution, especially since it does fit every contribution guideline. It's really appreciated.

2 suggestions:

  • prefix new option with feed_: feed_description, feed_title
  • use None as default value

mkdocs_rss_plugin/config.py Outdated Show resolved Hide resolved
mkdocs_rss_plugin/config.py Outdated Show resolved Hide resolved
mkdocs_rss_plugin/plugin.py Outdated Show resolved Hide resolved
mkdocs_rss_plugin/plugin.py Outdated Show resolved Hide resolved
tests/test_build.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
tests/test_config.py Outdated Show resolved Hide resolved
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@toomanybrians
Copy link
Contributor Author

Awesome, thanks for these suggestions! I have incorporated everything you suggested, confirmed all tests pass, and updated the PR. Thanks!

Copy link
Owner

@Guts Guts left a comment

Choose a reason for hiding this comment

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

Thanks for taking every review in account. I merge right now and will release a new version next week because I want to wait a bit for having feedback about the latest release (yesterday).

@Guts Guts merged commit 5adbaaf into Guts:main Jun 16, 2024
7 checks passed
@toomanybrians toomanybrians deleted the feature-custom-feed-title branch June 16, 2024 13:25
@Guts
Copy link
Owner

Guts commented Jun 25, 2024

Release as part of 1.13.2

Thanks again @toomanybrians!

@Guts
Copy link
Owner

Guts commented Jun 25, 2024

I've made a bit of communication here https://mapstodon.space/@geojulien/112672843319595679. If you have a Mastodon account, I would like to credit your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request quality Tests, project resiliency, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants