Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add user guiding script #1937

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/gatsby-theme-docs/src/components/user-guiding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PropTypes from 'prop-types';
import { Script } from 'gatsby';

const UserGuiding = (props) => {
return props.ugId ? (
<Script
src={`https://static.userguiding.com/media/user-guiding-${props.ugId}-embedded.js`}
/>
) : null;
};

UserGuiding.propTypes = {
ugId: PropTypes.string,
};

export default UserGuiding;
2 changes: 2 additions & 0 deletions packages/gatsby-theme-docs/src/templates/homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PageDataContext } from '../hooks/use-page-data';
import LayoutContentHomepage from '../layouts/content-homepage';
import { SEO, ThemeProvider } from '../components';
import markdownComponents from '../markdown-components';
import UserGuiding from '../components/user-guiding';

const HomepageTemplate = (props) => (
<IntlProvider locale="en">
Expand Down Expand Up @@ -69,6 +70,7 @@ export function Head({ data, pageContext }) {
// eslint-disable-next-line react/prop-types
excludeFromSearchIndex={data.contentPage.excludeFromSearchIndex}
/>
<UserGuiding ugId={'U4I78799B6RID'} />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FFawzy any better ideas on how/where inject the script?

</ThemeProvider>
);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/gatsby-theme-docs/src/templates/page-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SEO, ThemeProvider } from '../components';
import markdownComponents from '../markdown-components';
import { PageDataContext } from '../hooks/use-page-data';
import ChildSectionsNav from '../components/child-sections-nav';
import UserGuiding from '../components/user-guiding';

const ContentCards = (props) => (
<markdownComponents.Cards fitContentColumn={true} {...props} />
Expand Down Expand Up @@ -82,6 +83,7 @@ export function Head({ data, pageContext }) {
// eslint-disable-next-line react/prop-types
excludeFromSearchIndex={data.contentPage.excludeFromSearchIndex}
/>
<UserGuiding ugId={'U4I78799B6RID'} />
</ThemeProvider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import LayoutReleaseNotesDetail from '../layouts/release-notes-detail';
import LayoutReleaseNoteBody from '../layouts/internals/layout-release-note-body';
import { SEO, ThemeProvider } from '../components';
import markdownComponents from '../markdown-components';
import UserGuiding from '../components/user-guiding';

const releaseNoteMarkdownComponents = {
...markdownComponents,
Expand Down Expand Up @@ -68,6 +69,7 @@ export function Head({ data }) {
// eslint-disable-next-line react/prop-types
excludeFromSearchIndex={data.releaseNotePage.excludeFromSearchIndex}
/>
<UserGuiding ugId={'U4I78799B6RID'} />
</ThemeProvider>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SEO, ThemeProvider } from '../components';
import markdownComponents from '../markdown-components';
import useFilteredReleaseNotes from '../hooks/use-filtered-release-notes';
import GatsbyLink from '../components/link';
import UserGuiding from '../components/user-guiding';

const ReleaseNotesListTemplate = (props) => {
const filteredReleaseNotes = useFilteredReleaseNotes(
Expand Down Expand Up @@ -98,6 +99,7 @@ export function Head({ data }) {
// eslint-disable-next-line react/prop-types
excludeFromSearchIndex={data.contentPage.excludeFromSearchIndex}
/>
<UserGuiding ugId={'U4I78799B6RID'} />
</ThemeProvider>
);
}
Expand Down
Loading