@@ -2,17 +2,10 @@ import * as pathModule from 'path';
2
2
import { DefaultSettings } from '@onlook/models/constants' ;
3
3
import type { Font } from '@onlook/models/assets' ;
4
4
import { camelCase } from 'lodash' ;
5
- import {
6
- addFontVariableToAppLayout ,
7
- addFontVariableToPageApp ,
8
- removeFontVariableFromLayout ,
9
- } from './layout' ;
10
5
import { parse } from '@babel/parser' ;
11
6
import traverse from '@babel/traverse' ;
12
7
import * as t from '@babel/types' ;
13
8
import generate from '@babel/generator' ;
14
- import { removeFontFromTailwindConfig , updateTailwindFontConfig } from './tailwind' ;
15
- import { detectRouterType } from '../../pages' ;
16
9
import { readFile } from '../../code/files' ;
17
10
import fs from 'fs' ;
18
11
import { extractFontName , getFontFileName } from '@onlook/utility' ;
@@ -89,19 +82,6 @@ export const ${fontName} = ${importName}({
89
82
newContent += fontConfig ;
90
83
91
84
fs . writeFileSync ( fontPath , newContent ) ;
92
-
93
- await updateTailwindFontConfig ( projectRoot , font ) ;
94
-
95
- const routerConfig = await detectRouterType ( projectRoot ) ;
96
- if ( routerConfig ) {
97
- if ( routerConfig . type === 'app' ) {
98
- const layoutPath = pathModule . join ( routerConfig . basePath , 'layout.tsx' ) ;
99
- await addFontVariableToAppLayout ( layoutPath , fontName ) ;
100
- } else {
101
- const appPath = pathModule . join ( routerConfig . basePath , '_app.tsx' ) ;
102
- await addFontVariableToPageApp ( appPath , fontName ) ;
103
- }
104
- }
105
85
} catch ( error ) {
106
86
console . error ( 'Error adding font:' , error ) ;
107
87
}
@@ -251,24 +231,6 @@ export async function removeFont(projectRoot: string, font: Font) {
251
231
252
232
await fs . writeFileSync ( fontPath , code ) ;
253
233
254
- await removeFontFromTailwindConfig ( projectRoot , font ) ;
255
-
256
- const routerConfig = await detectRouterType ( projectRoot ) ;
257
- if ( routerConfig ) {
258
- if ( routerConfig . type === 'app' ) {
259
- const layoutPath = pathModule . join ( routerConfig . basePath , 'layout.tsx' ) ;
260
- await removeFontVariableFromLayout ( layoutPath , font . id , [ 'html' ] ) ;
261
- } else {
262
- const appPath = pathModule . join ( routerConfig . basePath , '_app.tsx' ) ;
263
- await removeFontVariableFromLayout ( appPath , font . id , [
264
- 'div' ,
265
- 'main' ,
266
- 'section' ,
267
- 'body' ,
268
- ] ) ;
269
- }
270
- }
271
-
272
234
// Delete font files if found
273
235
if ( fontFilesToDelete . length > 0 ) {
274
236
for ( const fileRelativePath of fontFilesToDelete ) {
@@ -303,8 +265,6 @@ export async function addFonts(projectRoot: string, fonts: Font[]) {
303
265
* Adds a local font to the project by:
304
266
* 1. Saving the font files to the fonts folder
305
267
* 2. Adding the font configuration to fonts.ts using next/font/local
306
- * 3. Updating Tailwind config with the new font family
307
- * 4. Adding the font variable to the appropriate layout file
308
268
*/
309
269
export async function addLocalFont (
310
270
projectRoot : string ,
@@ -403,31 +363,6 @@ export const ${fontName} = localFont({
403
363
404
364
fs . writeFileSync ( fontPath , newContent ) ;
405
365
406
- // Update Tailwind config
407
- const font : Font = {
408
- id : fontName ,
409
- family : baseFontName ,
410
- subsets : [ 'latin' ] ,
411
- weight : fontConfigs . map ( ( config ) => config . weight ) ,
412
- styles : fontConfigs . map ( ( config ) => config . style ) ,
413
- variable : `--font-${ fontName } ` ,
414
- type : 'local' ,
415
- } ;
416
-
417
- await updateTailwindFontConfig ( projectRoot , font ) ;
418
-
419
- // Update layout file
420
- const routerConfig = await detectRouterType ( projectRoot ) ;
421
- if ( routerConfig ) {
422
- if ( routerConfig . type === 'app' ) {
423
- const layoutPath = pathModule . join ( routerConfig . basePath , 'layout.tsx' ) ;
424
- await addFontVariableToAppLayout ( layoutPath , fontName ) ;
425
- } else {
426
- const appPath = pathModule . join ( routerConfig . basePath , '_app.tsx' ) ;
427
- await addFontVariableToPageApp ( appPath , fontName ) ;
428
- }
429
- }
430
-
431
366
return fontName ;
432
367
} catch ( error ) {
433
368
console . error ( 'Error adding local font:' , error ) ;
0 commit comments