pkgdown icon indicating copy to clipboard operation
pkgdown copied to clipboard

Add meta description and squish content

Open salim-b opened this issue 4 years ago • 6 comments

  • Adds a <meta name="description"> tag to the generated HTML (with the same content as the <meta property="og:description"> tag) which pleases Lighthouse.
  • Normalizes whitespace chars within content extracted from the DESCRIPTION file fields (like Title and Description).

salim-b avatar Mar 04 '21 15:03 salim-b

Do you want to finish this one off next? It'll need a rebase/merge to begin.

hadley avatar Oct 04 '21 13:10 hadley

And worth checking if https://github.com/r-lib/desc/blob/master/NEWS.md#breaking-change resolves the squishing issue.

hadley avatar Oct 04 '21 13:10 hadley

And worth checking if https://github.com/r-lib/desc/blob/master/NEWS.md#breaking-change resolves the squishing issue.

Yeah, it does (I've submitted that PR :smile: ). So it would be ok to require desc >= 1.4.0 in DESCRIPTION?

salim-b avatar Oct 04 '21 14:10 salim-b

@salim-b yup, that'd be fine.

hadley avatar Oct 04 '21 16:10 hadley

I've replaced all occurences of

desc$get("<NAME>")[[1]]

with

desc$get_field(
  key = "<NAME>",
  default = NA_character
)

and increased the min. desc pkg version to v1.4.0. The default = NA_character arg ensures no unintended errors arise in case a "<NAME>" field is unset/missing (same behaviour as for the old desc$get("<NAME>")[[1]]).

salim-b avatar Oct 05 '21 14:10 salim-b

It's easier to review code if you keep changes more closely aligned to the purpose of the PR. Here the goal is to improve page descriptions, so I think it would be better to avoid changes not related to that goal.

Ok, I understand. I just wanted to unify pkgdown's internal behaviour by always using desc$get_field() instead of desc$get() to retrieve single DESCRIPTION field values and thought it would really make sense to do it here while we're at it.

salim-b avatar Oct 06 '21 18:10 salim-b