purescript / pursuit

Website for hosting and searching PureScript API documentation
https://pursuit.purescript.org/
Other
170 stars 47 forks source link

Support open graph metadata for package and module pages #338

Open paf31 opened 6 years ago

paf31 commented 6 years ago

I think it would be nice to link to pages from Twitter and see a description in the link:

http://ogp.me/

chexxor commented 6 years ago

These properties from OGP would be good start with:

<meta property="og:title" content="PACKAGE_NAME" />
<meta property="og:url" content="PACKAGE_URL_IN_PURSUIT" />
<meta property="og:image" content="LINK_TO_IMAGE_ON_PURSUIT" />
<meta property="og:description" content="PACKAGE_DESCRIPTION"/> 
<meta property="og:site_name" content="Pursuit" />
chexxor commented 6 years ago

Some useful links to help us decide which meta attributes to use.

https://www.bruceclay.com/blog/how-to-use-social-meta-tags/#twitter-card https://search.google.com/structured-data/testing-tool/ https://developer.twitter.com/en/docs/tweets/optimize-with-cards/guides/getting-started http://schema.org/SoftwareSourceCode

Shouldn't use an image, though, as it becomes huuuge on Facebook posts.

joncfoo commented 6 years ago

Work is in progress as a result of today's hack session - https://github.com/joncfoo/pursuit/tree/338-opengraph

hdgarrood commented 6 years ago

Nice! The description from bower.json should be accessible via the PackageMeta type, I think. You'll have to do something clever to be able to obtain that value without performing an extra database lookup though.

joncfoo commented 6 years ago

Yea, I'm not sure what the best way is to obtain the description. I was thinking to utilize the package lookup functions that are already built ... the pages are only rendered once by the backend and then cached so it should be fine to do the expensive operation once? If that's not ok, what would you suggest @hdgarrood ?

hdgarrood commented 6 years ago

I think what we want is some way of (optionally) specifying in individual handlers what the ogp description should be. Maybe we could define a variant of defaultLayout, or maybe Yesod's widget functionality could be appropriate for this?