Skip to content

Commit dfd98af

Browse files
committed
Exclude topic and descendants if IsPrivateBranch
Some branches are intended not exposed publicly. This could be because they're intended for internal use, such as `Configuration`. Or it could be because they're exposed to the website, but are not publicly accessibly, such as `Administration`. In these cases, these branches should not be included in the `SitemapController` results. This was previously supported by adding the `NoIndex` any page or container (#38). This was due to a bug, however, and resulted in publicly available pages being excluded from the `SitemapController` if an ascendant topic was marked as `NoIndex`. The recursive `NoIndex` is still supported for `Container` content types, but that's a special condition since `Container` is already excluded from the `SitemapController`, and thus its `NoIndex` attribute _must_ apply to its descendents. That's not intuitive behavior, however, and should be considered deprecated. The `IsPrivateBranch` offers a solution that addresses both of these scenarios. As the name suggests, it is not intended to be used for publicly available pages, and thus won't affect the `NoIndex` treatment on individual pages—and, for that reason, it doesn't need to be added to e.g. the `TopicViewModel`. But it will accomplish what the recursive `NoIndex` was (unintendedly) used for: to exclude otherwise unavailable pages from the `SitemapController` both to avoid crawl errors and, potentially, to maintain data privacy. This satisfies the needs of #72.
1 parent 9b710d2 commit dfd98af

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

OnTopic.AspNetCore.Mvc/Controllers/SitemapController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ private IEnumerable<XElement> AddTopic(Topic topic, bool includeMetadata = false
198198
| Validate topic
199199
\-----------------------------------------------------------------------------------------------------------------------*/
200200
if (
201+
topic.Attributes.GetBoolean("IsPrivateBranch") ||
201202
topic.ContentType.Equals("Container", StringComparison.OrdinalIgnoreCase) &&
202203
topic.Attributes.GetBoolean("NoIndex")
203204
) return topics;

0 commit comments

Comments
 (0)