Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import a Google font in Astro.
Astro
import [1] from '@astrojs/google-fonts';
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular 'GoogleFont' instead of plural.
Swapping the order of words in the import name.
✗ Incorrect
The correct import is GoogleFonts from '@astrojs/google-fonts'.
2fill in blank
mediumComplete the code to add the Roboto font with weights 400 and 700.
Astro
<GoogleFonts fonts=[1] /> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using capitalized font name key.
Passing weights as strings instead of numbers.
Not wrapping weights in an array.
✗ Incorrect
The font name is lowercase roboto and weights are numbers in an array.
3fill in blank
hardFix the error in the font preload attribute to improve performance.
Astro
<GoogleFonts preload=[1] /> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing preload as a string instead of boolean.
Using quotes around true or false.
✗ Incorrect
The preload attribute expects a boolean true or false, not a string.
4fill in blank
hardFill both blanks to specify subsets and display strategy for font optimization.
Astro
<GoogleFonts fonts=[1] subsets=[2] />
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subsets as an object instead of an array.
Mixing font names and subsets in the same prop.
✗ Incorrect
Use the font object for fonts and an array of subsets like ["latin"] for subsets.
5fill in blank
hardFill all three blanks to optimize font loading with display strategy and preload enabled.
Astro
<GoogleFonts fonts=[1] display=[2] preload=[3] />
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around boolean preload.
Passing display as a boolean instead of string.
Incorrect font object syntax.
✗ Incorrect
Use the font object for fonts, a string like "swap" for display, and boolean true for preload.