Skip to content

Commit 205550a

Browse files
committed
feat(embed): parse google font external deps
1 parent b89511c commit 205550a

File tree

1 file changed

+13
-0
lines changed
  • packages/app/src/embed/components/Sidebar/ExternalResources

1 file changed

+13
-0
lines changed

packages/app/src/embed/components/Sidebar/ExternalResources/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
import React from 'react';
22
import { Container, Row } from './elements';
33

4+
function getFontFamily(search) {
5+
const hashes = search.slice(search.indexOf('?') + 1).split('&');
6+
const family = hashes
7+
.find(hash => hash.split('=')[0] === 'family')
8+
.split('=')[1];
9+
10+
return family.split('+').join(' ');
11+
}
12+
413
function getName(resource) {
14+
if (resource.includes('https://fonts.googleapis.com/css')) {
15+
return `${getFontFamily(resource)} (Google Fonts)`;
16+
}
17+
518
if (resource.endsWith('.css') || resource.endsWith('.js')) {
619
const match = resource.match(/.*\/(.*)/);
720
if (match && match[1]) {

0 commit comments

Comments
 (0)