The Lenra's static website framework.
Report Bug
·
Request Feature
This framework is fully configurable and let you use your own server or even page renderer. To understand how to configure your project, look at the configuration section.
Look at the framework section to better understand how it works.
To create your first website follow the next steps:
# Install the dependency
npm i lenra-io/lesta
# create the view directory
mkdir -p src/views
# create your first view file
echo "html
body
h1 Hello world" > src/views/index.pug
Debug it with an Express server:
npx lesta express
Or generate it for an Nginx server:
npx lesta nginx
Lesta is made to be fully configurable. To make it easier for the users, there are two configuration levels:
The JSON configuration allows you to define many things, like the file paths.
It can be defined in a lesta
property of your package.json
file.
There is default values for the configurations:
Field | Type | Description |
---|---|---|
staticDir |
string | The static files base directory |
i18nDir |
string | The internationalisation files base directory |
viewsDir |
string | The view files base directory |
buildDir |
string | The build target directory |
languages |
string[] | The list of managed languages by priority |
enableDefaultLanquage |
boolean | Define if the first language is the default |
translationStrategy |
string? | Define the strategy to manage page translation |
port |
integer | The listened server port |
robots |
RobotsConfiguration | The robots.txt manager configuration |
nginx |
NginxConfiguration | The nginx generator configuration |
Many other configuration keys can be defined to manage new components configurations.
Lesta can also handle new elements by defining a Lesta configurator in the lesta.config.js
file at the base of the project.
The elements defined in this file would override the default configurators ones (except for the generators map which is merged).
Here are the overridable elements:
getManagers
: returns the website PathManagersgenerators
: the generators map. The keys of this map are the allowed values by the Lesta CLI.getConfiguration
: returns the website Configuration
The framework is using many components to handle the generation of the websites.
It's the main element of the framework. A Website needs a Configuration and a PathManager list.
To start or build a Website, just call the generate
method with the desired Generator.
A path manager is based on two methods:
getManagedPaths
: list all the paths managed by the PathManagerbuild
: builds the content of the given path
There is three built-in PathManagers:
- PageManager: handles pages. See the dedicated section to learn more.
- RobotsManager: handles the search engines
robots.txt
files. - SitemapManager: handles the search engines sitemap files.
It handles the website pages for a given rendering technology. A Website can have many PageManagers.
A page manager needs a pageLister
function that lists the website pages and a pageRenderer
function that renders the pages.
By default, the PageManager will handle pug
files using the pugPageLister and pugPageRenderer.
It is a function that will use the Configuration and the PathManagers to start or generate the Website.
Here are the built-in Generators:
- express: starts an Express server to serve the Website
- nginx: generates the website content and an Nginx configuration file.
Lesta is usable through a command line interface. You can pass it the Generator you want to use.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please open an issue with the tag "enhancement". Don't forget to give the project a star if you liked it! Thanks again!
Distributed under the MIT License. See LICENSE for more information.
Lenra - @lenra_dev - contact@lenra.io
Project Link: https://github.com/lenra-io/lesta