Skip to content

Instantly share code, notes, and snippets.

{
resolve: `gatsby-plugin-prefetch-google-fonts`,
options: {
fonts: [
{
family: `Oswald`,
subsets: [`latin-ext`],
variants: [`300`, `500`],
},
],
{
resolve: "gatsby-plugin-web-font-loader",
options: {
google: {
families: ["Oswald:300,500&display=fallback&subset=latin-ext"],
},
},
}
/* latin-ext */
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 300;
font-display: fallback;
src: url(/font/TK3iWkUHHAIjg752Fz8Ghe4.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
text-rendering: optimizeLegibility;
}
/* latin-ext */
@font-face {
font-family: 'Oswald';
font-style: normal;
font-weight: 300;
font-display: fallback;
src: url(https://fonts.gstatic.com/s/oswald/v31/TK3iWkUHHAIjg752Fz8Ghe4.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
text-rendering: optimizeLegibility;
}
{
resolve: `gatsby-plugin-google-fonts`,
options: {
fonts: [
`Oswald:300,500&subset=latin-ext`,
],
display: 'fallback',
},
}
// OR
export const cleanString = val => {
return String(val)
.replace(/\s+/g, "-")
.toLowerCase();
};
@pilniczek
pilniczek / escape.js
Created January 10, 2020 13:10 — forked from mathiasbynens/escape.js
Escaping JSON-stringified data for use as a JavaScript string literal
// This object contains a string value that in contains a single quote,
// a double quote, a backtick, and a backslash.
const data = { foo: `a'b"c\`d\\e` };
// Turn the data into its JSON-stringified form.
const json = JSON.stringify(data);
// Now, we want to insert the data into a script body as a JavaScript
// string literal per https://v8.dev/blog/cost-of-javascript-2019#json,
// escaping special characters like `"` in the data.