-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
Fix to work without errors in Nuxt Universal #723
Conversation
I'm not really sure what we supposed to see, but both links from the message above don't work. One returns "not found" (maybe you meant https://remark.polv.cc/web/ ?) and the second "Error: Server Error" |
@umputun Sorry, the website was down for some reasons (Google App Engine throws no log.) But it is back now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For SPA we could create api like:
const instance = window.REMARK42.createInstance({
host: "host",
site_id: "siteId",
url: "url",
max_shown_comments: 50,
theme: "light",
page_title: "test",
node: DOMNode,
locale: "en",
});
// instance.changeTheme();
// instance.destroy();
frontend/app/embed.ts
Outdated
this.back!.setAttribute('data-animation', ''); | ||
this.node!.setAttribute('data-animation', ''); | ||
this.iframe!.focus(); | ||
this.back?.setAttribute('data-animation', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node should be always exist. Nullish operator should not be use for these cases. If we get null that mean that destroy doesn't work properly. It can create memory leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, so it would probably become,
if (!this.node) {
this.node = document.createElement('div');
...
}
if (!this.back) {
this.back = document.createElement('div');
...
}
this.iframe = iframe;
...
setTimeout(() => {
this.back!.setAttribute('data-animation', '');
this.node!.setAttribute('data-animation', '');
iframe.focus();
}, 400);
Gentle ping for @patarapolw to change the code after the review. |
Do you need some kind of commitiquette, like commitizen or commitlint? Also, ~/projects/remark42(master*) » git commit patarapolw@192
husky > pre-commit (node v12.16.3)
↓ Stashing changes... [skipped]
→ No partially staged files found...
✔ Running tasks...
husky > post-commit (node v12.16.3)
[master 6358acd2] fix onDestroy-related methods
1 file changed, 16 insertions(+), 11 deletions(-)
------------------------------------------------------------------------------------------------------------------------------------------------------------
~/projects/remark42(master) » git push origin master patarapolw@192
husky > pre-push (node v12.16.3)
> remark-ui@0.1.0 check /Users/patarapolw/projects/remark42/frontend
> cross-env NODE_ENV=production npm run build && run-p check:*
> remark-ui@0.1.0 build /Users/patarapolw/projects/remark42/frontend
> webpack --mode production
NODE_ENV = production
REMARK_ENV = https://demo.remark42.com |
LGTM, but I would ask @Mavrin to revise. |
BTW, does not work in GatsbyJS, but OK in NextJS (and of course NuxtJS). A reproducible repo is here -- https://github.com/patarapolw/jpdiary/tree/gatsby |
@patarapolw. Thank you for reproducible example. Did you read my comment?
I think if you impent this all should work as expected. You need to call this code when page is mount and unmount. |
Ok, it seems that I have to frame the |
Merge branch 'master' of github.com:umputun/remark42
…fore try to attach node
You can run all test by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Could you please revert all replaced !.
back?
@Mavrin OK, but in theory, I am not sure when |
If it is possible. We should add this check. Could you describe case when it is null? |
Lgtm. |
@patarapolw good job, would you be so kind to add documentation for this feature? And yes, as @Mavrin asked, it would be great to check working example. |
For the example, where I really used, see my website -- https://www.polv.cc. I also made a much simpler example -- https://github.com/patarapolw/remark42-spa (will update in there.) |
iframe.remove(); | ||
} | ||
|
||
// TODO: These do not appear in Chrome DevTools |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have this unresolved problem. Not really a problem to me, but may affect backward compatibility...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patarapolw @umputun With current const iframe =
(document.querySelector('iframe[title=Remark42]') as HTMLIFrameElement) ||
createFrame({ host: BASE_URL, query, __colors__: config.__colors__ }); to const iframe =
createFrame({ host: BASE_URL, query, __colors__: config.__colors__ }); |
A small correction: that's definintely not the only thing preventing multiple comment sections from working on the same page, but changing that is required if multiple comment sections are ever to be implemented (I'm probably going to be working on it soon and I will provide a PR) |
As a solution to #722 I cloned and edited the repo.
embed.ts
,!.
with?.
so it will not throw error ... of undefined.destroy()
towindow.Remark42
, which actually removes global listeners (onwindow
anddocument
)Also, in production, instead of your init function https://github.com/umputun/remark42#comments, I moved it inside a function and add a typing for TypeScript. -- remark42.ts and it is implemented here -- PostFull.vue
In order to test in production, I deploy it to Google Compute Engine and Docker Hub with
patarapolw/remark42
, as can be seen at