Skip to content

Support meta name="description" tag #859

Description

@KararTY

api currently does not read <meta name="description" content="" /> field.

Current code:

if fields.Size() > 0 {
fields.Each(func(i int, s *goquery.Selection) {
prop, _ := s.Attr("property")
cont, _ := s.Attr("content")
switch {
/* Support for HTML Open Graph & Twitter meta tags.
* Will show Open Graph & Twitter "Title", "Description", "Image" information of webpages.
* More OG fields & information: https://ogp.me/
* More Twitter fields & information: https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup
*/
case (prop == "og:title" || prop == "twitter:title") && data.Title == "":
data.Title = cont
case (prop == "og:description" || prop == "twitter:description") && data.Description == "":
data.Description = cont
case (prop == "og:image" || prop == "twitter:image") && data.ImageSrc == "":
data.ImageSrc = utils.FormatThumbnailURL(baseURL, r, cont)
}
})
}

A quick & dirty change is to additionally read the "name" property

prop, _ := s.Attr("property")
if prop == "" {
    prop, _ = s.Attr("name")
}

and then read "description":

case (prop == "og:description" || prop == "twitter:description" || prop == "description") && data.Description == "":
  data.Description = cont

I'll leave this as an issue because I'm sure there are better ways of (re)writing this code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions