Skip to content

Commit

Permalink
fix endpoints after font collection rest controller improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gigitux committed Jan 29, 2024
1 parent e534157 commit fcc774b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import apiFetch from '@wordpress/api-fetch';
import { FONT_FAMILIES_TO_INSTALL } from '../assembler-hub/sidebar/global-styles/font-pairing-variations/constants';
import { FontFace, FontFamiliesToInstall, FontFamily } from '../types/font';

export type FontCollectionsResponse = Array< {
slug: string;
description: string;
name: string;
} >;

export type FontCollectionResponse = {
slug: string;
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
installFontFace,
installFontFamily,
getFontFamiliesAndFontFaceToInstall,
FontCollectionsResponse,
} from './fonts';

const assembleSite = async () => {
Expand Down Expand Up @@ -54,11 +55,6 @@ const installAndActivateTheme = async () => {
};

const installFontFamilies = async () => {
const config = {
path: '/wp/v2/font-collections/default-font-collection',
method: 'GET',
};

try {
const installedFontFamily = ( await resolveSelect(
'core'
Expand All @@ -84,9 +80,15 @@ const installFontFamilies = async () => {
} )
);

const fontCollection = await apiFetch< FontCollectionResponse >(
config
);
const fontCollections = await apiFetch< FontCollectionsResponse >( {
path: '/wp/v2/font-collections?_fields=slug,name,description,id',
method: 'GET',
} );

const fontCollection = await apiFetch< FontCollectionResponse >( {
path: `/wp/v2/font-collections/${ fontCollections[ 0 ].slug }`,
method: 'GET',
} );

const { fontFacesToInstall, fontFamiliesWithFontFacesToInstall } =
getFontFamiliesAndFontFaceToInstall(
Expand Down

0 comments on commit fcc774b

Please sign in to comment.