1

I'm trying to add the Bookalet third party widget to my Gatsby index page. I have tried just including in the page and via Helmet. Both methods aren't working sadly. Any ideas?

The script in question:

<div><script src="https://widgets.bookalet.co.uk/publish.js" data-bookalet="da8ebdf5-2f4a-47cb-8c92-f84032b16f5b" data-property="17263" data-monthcount="1"></script></div>

Example 1: simply placing in the page:

          <TextBlock>
        <Heading>
          <h2>Availability</h2>
        </Heading>
        <RichText>
          You can check availabilty below. Please note the minimum booking
          is seven nights. Short breaks may be considered out of season,
          please contact us.
        </RichText>
        <Spacer></Spacer>
        <div>
          <script
            src="https://widgets.bookalet.co.uk/publish.js"
            data-bookalet="da8ebdf5-2f4a-47cb-8c92-f84032b16f5b"
            data-property="17263"
            data-monthcount="1"
          ></script>
        </div>
      </TextBlock>

Example 2: using helmet to add into the page.

            <Helmet>
          <script
            src="https://widgets.bookalet.co.uk/publish.js"
            data-bookalet="da8ebdf5-2f4a-47cb-8c92-f84032b16f5b"
            data-property="17263"
            data-monthcount="1"
          ></script>
        </Helmet>
1
  • Did you read the documentation? Using React Helmet should work, but you will likely have to wait until the component has mounted to call the external library's methods. You can use useEffect or componentDidMount Commented Sep 11, 2020 at 12:09

1 Answer 1

1

I've used the <Helmet> approach and it's working. Here's the snippet:

import React from 'react';
import Helmet from 'react-helmet';

const Index = props => {
  return <Layout>
    <Helmet>
      <script src="https://widgets.bookalet.co.uk/publish.js"
              data-bookalet="da8ebdf5-2f4a-47cb-8c92-f84032b16f5b"
              data-property="17263"
              data-monthcount="1"/>
    </Helmet>
    <h1>Hi people</h1>
  </Layout>;
};


export default Index;

A screenshot of the 200 response (success):

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.