How to access files

The [`assets`](/assets/) module contains a foreign variable named `files` that holds references to the package's files. You can use this variable to get the full path or URL of a file. Suppose if you want to get the full path of `folder-1/folder-2/foo.ftd` present in dependency package named `other-package`. You need to write the following code:
-- import: other-package/assets

-- ftd.text: Link to foo.ftd
link: $assets.files.folder-1.folder-2.foo.ftd
Lang:
ftd
The `$assets.files.folder-1.folder-2.foo.ftd` reference will return a string with a value like ``-/other-package/folder-1/folder-2/foo.ftd`. For images, the `assets` reference returns a `ftd.image-src` value that includes values for both light and dark modes.

Accessing Image Files

You can define images for both light and dark modes, and the `assets` reference returns a `ftd.image-src` type for them.

A Single Image for Both Light and Dark Mode

To use a single image for both light and dark modes, add the image (e.g., `logo.png`) anywhere in your package (e.g., inside `static` directory), and use the following code to access it:
-- import: /assets

-- ftd.image:
src: $assets.files.static.logo.png
Lang:
ftd
The above code will render the image. The return type of `assets.files.static.logo.png` is `ftd.image-src` with a value like this:
-- ftd.image-src assets.files.static.logo.png:
light: -//static/logo.png
dark: -//static/logo.png
Lang:
ftd

Different images for light and dark mode.

If you want a different images for both light and dark mode, then add an image, say `logo.png` (for light mode) and `logo-dark.png` (for dark mode), somewhere in your package, say inside `static` folder. If you want to use different images for light and dark modes, add the images (e.g., `logo.png` for light mode and `logo-dark.png` for dark mode) anywhere in your package (e.g., inside `static` directory), and use the following code to access them:
-- import: /assets

-- ftd.image:
src: $assets.files.static.logo.png
Lang:
ftd
The above code will render the image. The return type of `assets.files.static.logo.png` is `ftd.image-src` with a value like this:
-- ftd.image-src assets.files.static.logo.png:
light: -//static/logo.png
dark: -//static/logo-dark.png
Lang:
ftd

Support `fastn`!

Enjoying `fastn`? Please consider giving us a star ⭐️ on [GitHub](https://github.com/fastn-stack/fastn) to show your support!
[⭐️](https://github.com/fastn-stack/fastn)

Getting Help

Have a question or need help? Visit our [GitHub Q&A discussion](https://github.com/fastn-stack/fastn/discussions/categories/q-a) to get answers and subscribe to it to stay tuned. Join our [Discord](https://discord.gg/a7eBUeutWD) channel and share your thoughts, suggestion, question etc. Connect with our [community](/community/)!
[💻️](/community/)

Found an issue?

If you find some issue, please visit our [GitHub issues](https://github.com/fastn-stack/fastn/issues) to tell us about it.

Quick links:

- [Install `fastn`](install/) - [Create `fastn` package](create-fastn-package/) - [Expander Crash Course](expander/) - [Syntax Highlighting in Sublime Text](/sublime/)

Join us

We welcome you to join our [Discord](https://discord.gg/a7eBUeutWD) community today. We are trying to create the language for human beings and we do not believe it would be possible without your support. We would love to hear from you.
Copyright © 2023 - [FifthTry.com](https://www.fifthtry.com/)