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

feat: add qualified plugin #5410

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ const config = {
id: 'docs-fullstory',
},
],
[
'./plugins/qualified',
{
id: 'docs-qualified',
},
],
'docusaurus-plugin-sass',
require.resolve('docusaurus-plugin-image-zoom'),
],
Expand Down
29 changes: 29 additions & 0 deletions plugins/qualified.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = async function fullStory({ context, options }) {
Copy link
Contributor

Choose a reason for hiding this comment

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

assuming this block was inspired by the fullstory implementation, but the function should get it's own name 😄

const isProd = process.env.NODE_ENV === 'production'
return {
name: 'docusaurus-plugin-qualified',
injectHtmlTags({ content }) {
if (!isProd) {
return {}
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to return an empty object specifically or is this just a short circuit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is only a short circuit to avoid pollution

}
return {
headTags: [
{
tagName: 'script',
innerHTML: `
(function(w,q){w['QualifiedObject']=q;w[q]=w[q]||function(){
(w[q].q=w[q].q||[]).push(arguments)};})(window,'qualified')
`,
},
{
tagName: 'script',
attributes: {
src: 'https://js.qualified.com/qualified.js?token=rBwsq6b6C9SwcRe6',
async: true,
},
},
],
}
},
}
}
Loading