~jan0sch/smederee
Showing details for patch 0fcddc959653307cbde277cd8af98dc09d7dbb1f.
diff -rN -u old-smederee/modules/html-utils/src/main/scala/de/smederee/html/MetaTags.scala new-smederee/modules/html-utils/src/main/scala/de/smederee/html/MetaTags.scala --- old-smederee/modules/html-utils/src/main/scala/de/smederee/html/MetaTags.scala 2025-01-16 09:50:46.424902093 +0000 +++ new-smederee/modules/html-utils/src/main/scala/de/smederee/html/MetaTags.scala 2025-01-16 09:50:46.424902093 +0000 @@ -18,10 +18,46 @@ package de.smederee.html enum MetaRobotsDirective(val tag: String) { - case Follow extends MetaRobotsDirective("follow") - case Index extends MetaRobotsDirective("index") + + /** Equivalent to index, follow. Used by Google + */ + case All extends MetaRobotsDirective("all") + + /** Allows the robot to follow the links on the page (default). Used by all. + */ + case Follow extends MetaRobotsDirective("follow") + + /** Allows the robot to index the page (default). Used by all. + */ + case Index extends MetaRobotsDirective("index") + + /** Requests the search engine not to cache the page content. Used by Bing, Google, Yahoo. + */ + case NoArchive extends MetaRobotsDirective("noarchive") + + /** Synonym of noarchive. Used by Bing. + */ + case NoCache extends MetaRobotsDirective("nocache") + + /** Requests the robot to not follow the links on the page. Used by all. + */ case NoFollow extends MetaRobotsDirective("nofollow") - case NoIndex extends MetaRobotsDirective("noindex") + + /** Requests this page not to appear as the referring page of an indexed image. Used by Google. + */ + case NoImageIndex extends MetaRobotsDirective("noimageindex") + + /** Requests the robot to not index the page. Used by all. + */ + case NoIndex extends MetaRobotsDirective("noindex") + + /** Prevents displaying any description of the page in search engine results. Used by Bing, Google. + */ + case NoSnippet extends MetaRobotsDirective("nosnippet") + + /** Equivalent to noindex, nofollow. Used by Google. + */ + case None extends MetaRobotsDirective("none") } opaque type MetaDescription = String @@ -93,15 +129,33 @@ * An optional description for the related meta tag which should not be too long (max. 160/200 characters). * @param keywords * A list of keywords which can be empty and should not be too long. + * @param robots + * A set of directives for the meta tag "robots" to affect search engine / crawler indexing behaviour. */ -final case class MetaTags(description: Option[MetaDescription], keywords: MetaKeyWords) +final case class MetaTags( + description: Option[MetaDescription], + keywords: MetaKeyWords, + robots: Set[MetaRobotsDirective] +) object MetaTags { + /** Return a default instance of meta tags which is empty and has the nofollow and noindex flags for robots set. + * + * @return + * An instance of meta tags containing only nofollow and noindex flags for robots. + */ + def default: MetaTags = + MetaTags( + description = None, + keywords = MetaKeyWords.empty, + robots = Set(MetaRobotsDirective.NoFollow, MetaRobotsDirective.NoIndex) + ) + /** Return an empty meta tags instance. * * @return * An instance of meta tags containing no values, resulting in no tags being rendered. */ - def empty: MetaTags = MetaTags(description = None, keywords = MetaKeyWords.empty) + def empty: MetaTags = MetaTags(description = None, keywords = MetaKeyWords.empty, robots = Set.empty) }