Support us by giving us a
star on Github 🚀

Import the packages

Importing packages in a project is essential for utilizing external code functionalities and libraries.

Benefits of importing packages/documents at the top of code

`import-at-top`: Import lines goes at the top of the document
We `import` the external packages at the start of the `.ftd` file and there should be no space between two imports. Adding import statements at the top of a code document helps other programmers understand the code's dependencies and requirements. It allows quick identification of necessary modules and libraries. Moreover, this practice prevents naming conflicts and improves code clarity, organization, and maintainability. It is a common convention that helps improve the clarity, organization, and maintainability of the code.
Not Recommended
-- import: <package-1>

-- ds.page: title

page content goes here

;; before component
-- import: <package-2>

package-2 component usage

more content

-- import: <package-n>

more content

-- end: ds.page
Lang:
ftd
Recommended
-- import: <package-1>
-- import: <package-2>
...
-- import: <package-n>

-- ds.page: title

page content goes here

-- end: ds.page
Lang:
ftd

Advantages of exporting components over wrapping them

`using-export`: Use export for wrapper component definitions during Import
When we create component definitions which only refer to different component defined in another package. In such cases, where the component definition is just a wrapper definition of a component defined in another package, then using export feature while importing that package is recommended. It reduces line of codes and readability. **Sample Scenario:** For documentations we use `doc-site` package. In this package we refer the components like **markdown, h0, h1, h2 and h3** from another package called `typography` package. One way is to create components in the `doc-site` and refer to these components in `typography` package.
Not recommended
-- import: fastn-community.github.io/typography as tf

;; code goes here

-- component markdown:
caption or body body:

-- tf.markdown:

$markdown.body

-- end: markdown




-- component h1:
caption title:
optional body body:
optional string id:

-- tf.h1: $h1.title
id: $h1.id

$h1.body

-- end: h1
Lang:
ftd
Recommended
-- import: fastn-community.github.io/typography as tf
export: markdown, h1
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 - fastn.com