Skip to content

Instantly share code, notes, and snippets.

@lilpolymath
Created April 7, 2021 16:15
Show Gist options
  • Save lilpolymath/8a4c3acfcc6dac0db4ae1e1024dea985 to your computer and use it in GitHub Desktop.
Save lilpolymath/8a4c3acfcc6dac0db4ae1e1024dea985 to your computer and use it in GitHub Desktop.
SCSS mixin to load fonts.
@mixin font($font-family, $font-file, $font-weight) {
@font-face {
font-family: $font-family;
// Add font types here
src: url($font-file+'.ttf') format('truetype');
font-weight: $font-weight;
font-style: normal;
font-display: swap;
}
}
// Alias import with gatsby-plugin-alias-import
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Bold', 700);
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Medium', 500);
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Regular', 400);
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-SemiBold', 600);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment