File "index.js"

Full path: /home/webcknlt/admissiontell.com/wp-content/plugins/generateblocks/src/components/google-font-link/index.js
File size: 627 B (627 B bytes)
MIME-type: text/x-java
Charset: utf-8

Download   Open   Edit   Advanced Editor &nnbsp; Back

import { Fragment } from '@wordpress/element';

export default ( { fontFamily, googleFont, googleFontVariants, isBlockPreview } ) => {
	if ( isBlockPreview ) {
		return null;
	}

	if ( ! fontFamily ) {
		return null;
	}

	if ( generateBlocksInfo.disableGoogleFonts ) {
		return null;
	}

	const gFontsUrl = 'https://fonts.googleapis.com/css?family=';
	const googleFontsAttr = googleFontVariants ? `:${ googleFontVariants }` : '';
	const href = gFontsUrl + fontFamily.replace( / /g, '+' ) + googleFontsAttr;

	return (
		<Fragment>
			{ fontFamily && googleFont && <link rel="stylesheet" href={ href } /> }
		</Fragment>
	);
};