# ghostkit/3.4.1/gutenberg/blocks/gist/frontend.js

Block Animations, Motion &amp; Scroll Effects – Ghost Kit, version 3.4.1. 45 lines.

- Page: https://pluginprobe.com/plugins/ghostkit/3.4.1/code/gutenberg/blocks/gist/frontend.js
- Raw: https://pluginprobe.com/plugins/ghostkit/3.4.1/raw/gutenberg/blocks/gist/frontend.js
- Modified: 2024-02-18T18:40:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ghostkit/3.4.1/code/gutenberg/blocks/gist/frontend.js#L10-L20`.

```javascript
/**
 * Block Gist
 */
const {
	GHOSTKIT: { events },
	gistSimple,
} = window;

/**
 * Prepare Gists.
 */
events.on(document, 'init.blocks.gkt', () => {
	if (typeof gistSimple === 'undefined') {
		return;
	}

	document
		.querySelectorAll('.ghostkit-gist:not(.ghostkit-gist-ready)')
		.forEach(($this) => {
			$this.classList.add('ghostkit-gist-ready');

			const match = /^https:\/\/gist.github.com?.+\/(.+)/g.exec(
				$this.getAttribute('data-url')
			);

			if (match && typeof match[1] !== 'undefined') {
				const options = {
					id: match[1],
					file: $this.getAttribute('data-file'),
					caption: $this.getAttribute('data-caption'),
					showFooter:
						$this.getAttribute('data-show-footer') === 'true',
					showLineNumbers:
						$this.getAttribute('data-show-line-numbers') === 'true',
				};

				events.trigger($this, 'prepare.gist.gkt', { options });

				gistSimple($this, options);

				events.trigger($this, 'prepared.gist.gkt', { options });
			}
		});
});

```
