callumbwhyte / friendly-robots

A friendly tool for creating dynamic robots.txt files in Umbraco
MIT License
7 stars 1 forks source link

Expose a way to generate a Default RobotsConfiguration that can be overriden #2

Closed NikRimington closed 3 years ago

NikRimington commented 4 years ago

I have a requirement where I only really need to customise the XML sitemap, rather than having to replicate the entire creation process that occurs in the default composer, it would be great to there was a static method that essentially did this method:

https://github.com/callumbwhyte/friendly-robots/blob/a5c4efbda2853dd79206c77b0a7dbc77ce3c1cfa/src/Our.Umbraco.FriendlyRobots/Startup/RobotsConfigComposer.cs#L17

Then any fields that need overriding could be overridden on the response.

e.g.

var myRobotsConfig = Default.GetRobotsConfig();
myRobots.Config.Sitemap = new [] {"MyXMLSitemapLink"}; 
callumbwhyte commented 3 years ago

Hey @NikRimington,

Thanks for the feedback, this makes so much sense...

Your wish is my command! As part of a review into the configuration options for both Friendly Robots and Friendly Sitemap, I have introduced some static methods used to build the default configuration.

You can use it like this:

var config = RobotsConfiguration.Create();

config.Sitemap = new[] { "..." };

This change is available as of v1.2.0, which is now available from all good package stores! Hope that helps.

Cheers, Callum