0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-10 23:01:26 -05:00

feat(fonts): rename component (#13207)

This commit is contained in:
Florian Lefebvre 2025-02-10 17:30:51 +01:00 committed by GitHub
parent 489935904d
commit c6bc00f992
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 9 additions and 11 deletions

View file

@ -54,7 +54,7 @@ declare module 'astro:assets' {
inferRemoteSize: typeof import('./dist/assets/utils/index.js').inferRemoteSize;
Image: typeof import('./components/Image.astro').default;
Picture: typeof import('./components/Picture.astro').default;
Fonts: typeof import('./components/Fonts.astro').default;
Font: typeof import('./components/Font.astro').default;
};
type ImgAttributes = import('./dist/type-utils.js').WithRequired<

View file

@ -8,4 +8,4 @@ The vite plugin orchestrates the fonts logic:
- In dev, serves a middleware that dynamically loads and caches fonts data
- In build, download fonts data (from cache if possible)
The `<Fonts />` component is the only aspect not managed in the vite plugin, since it's exported from `astro:assets`.
The `<Font />` component is the only aspect not managed in the vite plugin, since it's exported from `astro:assets`.

View file

@ -23,8 +23,6 @@ import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type { ModuleLoader } from '../../core/module-loader/loader.js';
import { createViteLoader } from '../../core/module-loader/vite.js';
// TODO: maybe rename Fonts component to Font
interface Options {
settings: AstroSettings;
sync: boolean;
@ -32,7 +30,7 @@ interface Options {
}
/**
* Preload data is used for links generation inside the <Fonts /> component
* Preload data is used for links generation inside the <Font /> component
*/
type PreloadData = Array<{
/**

View file

@ -130,7 +130,7 @@ export default function assets({ settings, sync, logger }: Options): vite.Plugin
import { getImage as getImageInternal } from "astro/assets";
export { default as Image } from "astro/components/${imageComponentPrefix}Image.astro";
export { default as Picture } from "astro/components/${imageComponentPrefix}Picture.astro";
export { default as Fonts } from "astro/components/Fonts.astro";
export { default as Font } from "astro/components/Font.astro";
export { inferRemoteSize } from "astro/assets/utils/inferRemoteSize.js";
export const imageConfig = ${JSON.stringify({ ...settings.config.image, experimentalResponsiveImages: settings.config.experimental.responsiveImages })};

View file

@ -1,5 +1,5 @@
---
import { Fonts } from 'astro:assets'
import { Font } from 'astro:assets'
---
<Fonts family='Roboto' />
<Font family='Roboto' />

View file

@ -1,5 +1,5 @@
---
import { Fonts } from 'astro:assets'
import { Font } from 'astro:assets'
---
<Fonts family='Roboto' preload />
<Font family='Roboto' preload />

View file

@ -9,7 +9,7 @@ describe('astro:fonts', () => {
/** @type {import('./test-utils.js').DevServer} */
let devServer;
describe('<Fonts /> component', () => {
describe('<Font /> component', () => {
// TODO: remove once fonts are stabilized
describe('Fonts are not enabled', () => {
before(async () => {