UNPKG

1.13 kBMarkdownView Raw
1# Bablic-Node-SDK
2
3To install simply use NPM:
4```sh
5$ npm install --save bablic
6```
7
8Config your app:
9
10Javascript:
11```sh
12const {create} = require("bablic");
13app.use(create({
14 siteId: '[your site id]',
15 rootUrl: 'http://[root url of your site]',
16 subDir: true, // if you want to use sub dir for languages like /es/ /fr/
17 seo: {
18 defaultCache: ["http://[url of something you know you need caching to"]
19 }));
20
21app.get('/',function(req,res) {
22 console.log('the current language for the user is',req.bablic.locale);
23 res.render('index.ejs',{});
24});
25
26```
27
28Typescript:
29```sh
30import {create} from "bablic";
31app.use(create({
32 siteId: '[your site id]',
33 rootUrl: 'http://[root url of your site]',
34 subDir: true, // if you want to use sub dir for languages like /es/ /fr/
35 seo: {
36 defaultCache: ["http://[url of something you know you need caching to"]
37 }));
38```
39
40In your layout template file you can add the snippet:
41
42```
43
44<html>
45 <head>
46 <%- bablic.snippetTop %>
47 </head>
48 <body>
49 <%- body %>
50 </body>
51</html>
52
53```
54And use!