#frontmatter js
3 messages · Page 1 of 1 (latest)
Hi @gloomy moat. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
You can import a function from a JavaScript file into the frontmatter of your Astro component using the ESM import syntax. Here's an example:
---import { getUser } from './user.js';---
In this example, getUser is a function that's being imported from a JavaScript file named user.js. The import statement should be placed at the top of your frontmatter.
Please note that the path to the JavaScript file should be relative to the component.