How to share your Frontity project
Last updated
Was this helpful?
Last updated
Was this helpful?
When you create a Frontity project most of the times you'll end up creating a custom theme:
Because you need some specific design and features for your project
Because you directly want to create a theme that can be reused by others (like or )
Whatever the case is, you may want the community:
To be able to check the code of your theme
To be able to install it locally so it can be debugged β this will help the community to help you with any issue you may have with your project/theme
To be able to install it as an npm package (eventually) so it can be easily reused in some other projects
Here you have a few things to consider to ease contributions and support from the community to your theme
In Frontity, themes are packages that can be published in npm so they can be installed and used in any other Frontity project
The suggested structure for developing new themes that works with Frontity is the following one
In this structure, the theme you're developing is a local dependency of the main package.json
This structure implies having a main Frontity project (root package.json
) and some packages (each one with its own package.json
) under the packages
folder
So, to create a custom theme project we recommend you to:
Create a Frontity project β npx frontity create awesome-theme-project
Create a Frontity package (your theme) β npx frontity create-package awesome-theme
These files in the root represents the Frontity project that can be launched and that will allow to see the theme (or any other package) in action
In the root folder you'll find the following:
frontity.setting.js
For example:
node_modules
packages
package.json
This package.json
is used when you publish a package in npm, but this Frontity project is not meant to be published
With this structure you can develop your theme as a package inside the packages
folder.
Each one of these packages will have its own package.json
and these packages are the ones meant to be published (npm publish
)
This structure allows to:
Launch the project using the theme locally
Publish the theme independently
So any developer can clone this project, launch the Frontity project locally, have a look at how the theme looks like & behave and make contributions (pull requests) to your repository (that can be eventually merged into the main repository).
And also, the owner of the theme still can publish those new updates independently (from the theme folder, packages/awesome-theme
in this case)
GitHub repositories containing Frontity projects with the structure explained above, can be directly opened in CodeSandbox by using one of the following URL structures:
From the root of the project we can do
This command will install the dependencies of the Frontity project and the dependencies of its dependencies, just as any other npm package
All needed dependencies (the ones defined for the Frontity project and the ones defined for the theme) are installed
Once we have all the dependencies installed you can do (from the root)
This will launch the Frontity project using this theme
This type of dependency is automatically defined if you create the package (theme) w/ the Frontity command npx frontity create-package awesome-theme
Β» Read more about
A file containing the settings for your project (among other settings you'll usually define the use of this theme)
A folder, where the dependencies of the project are installed
A folder where your local packages live
And a with the configuration & dependencies for the Frontity project.
In Frontity you can create a new package by doing npx frontity create-package <my package name>
(from the root of the Frontity project)
Β» Read more about
For example this repo can be opened directly in CodeSandbox with links like:
Let's take as an example of a Frontity theme available:
As ready to be installed and used as a theme in any Frontity project
In a ready to be cloned and launched locallly, and also ready to accept contributions from the community via
Once we we can see the project follows the structure of a typical Frontity project
So, as Frontity Chakra Theme is also one of the dependencies () is:
npm install <folder>
As we can see frontity-chakra-theme
is published as
How did published this theme once he finished it? Just by doing: