JakeKempo
JakeKempo

Reputation: 590

add Google Hire script to Gatsby site

I'm working on a GatabyJS site hosted on Netlify https://www.evooq.ch/careers/. I'm trying to add a Google Hire script to display a list of job openings.

This is what Google provide (I've tried with a plain html file and it works)

<div class="hire-jobs"></div>
<script id="hire-embed-loader" async defer src="https://hire.withgoogle.com/s/embed/hire-jobs.js?company=evooqch"></script>

I changed class to className, I've tried adding the script tag directly into the component, doing this randomly shows the job listings, more often though nothing is displayed.

I've also tried adding the script tag to gatsby-ssr.js like so..

import React from "react";
export function onRenderBody({ setHeadComponents }) {
  setHeadComponents([
    <script
      id="hire-embed-loader"
      src="https://hire.withgoogle.com/s/embed/hire-jobs.js?company=evooqch"
    />
  ]);
}

I tried with setHeadComponents, setPreBodyComponents and setPostBodyComponents in the ssr file.

I also tried with async and defer in different combinations.

Upvotes: 3

Views: 110

Answers (1)

JakeKempo
JakeKempo

Reputation: 590

I never managed to fix this issue, but I found that Google Hire provide a JSON feed so I'm using this instead.

I now have an issue with getting the JSON data to load at runtime. See Gatsby load JSON data at runtime

Upvotes: 1

Related Questions