Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
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
13 changes: 13 additions & 0 deletions ADVANCED-USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ your website. Make sure that your users are aware of this.

For more details, see [creating new themes][creating-new-themes].

### `data-callback`

The callback function will be invoked after loading the `iframe`.

```html
<script src="https://giscus.app/client.js"
data-repo="giscus/giscus"
...
data-callback="console.log('iframe loaded')"
...>
</script>
```

## `<meta>` tags

Your website can define additional `<meta>` tags to help giscus gather the
Expand Down
2 changes: 2 additions & 0 deletions client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
const locale = attributes.lang ? `/${attributes.lang}` : '';
const src = `${giscusOrigin}${locale}/widget?${new URLSearchParams(params)}`;
const loading = attributes.loading === 'lazy' ? 'lazy' : undefined;
const onload = attributes.callback ?? undefined;

// Set up iframe element
const iframeElement = document.createElement('iframe');
Expand All @@ -98,6 +99,7 @@
allow: 'clipboard-write',
src,
loading,
onload,
};
Object.entries(iframeAttributes).forEach(
([key, value]) => value && iframeElement.setAttribute(key, value),
Expand Down