r-lib / pkgdown

Generate static html documentation for an R package
https://pkgdown.r-lib.org/
Other
720 stars 336 forks source link

pkgdown with webtracker "Clarity" #2819

Closed erex closed 2 hours ago

erex commented 2 hours ago

Any experience of using Clarity with a pkgdown site? I have used the following code in _pkgdown.yml

    primary: "#0542a3"
    base_font: {google: "Roboto"}
  includes:
    in_header: 
      - file: Clarity.txt

resulting in this inside the index.html

<body>
<p>

  list(file = "Clarity.txt")

I would have expected the includes in_header: to have placed the file within the

as it has done with an ordinary Quarto website:

<script src="https://kit.fontawesome.com/78ddb093ea.js" crossorigin="anonymous"></script>
<script type="text/javascript">

    (function(c,l,a,r,i,t,y){

        c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};

        t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;

        y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);

    })(window, document, "clarity", "script", "lo7j6sob8t");

</script>

<link rel="stylesheet" href="styles.css">
</head>

Am I misunderstanding how files are to be included as part of the header of a rendered pkgdown site?

jayhesselberth commented 2 hours ago

You'd need to paste the content directly into the yaml, here's an example:

https://github.com/tidyverse/tidytemplate/blob/42cf848c5a5e082f9d95ae2ae2c7804b65d097ef/_pkgdown.yml#L5-L7

erex commented 1 hour ago

Thanks @jayhesselberth, appreciate the fast and accurate help.