I'm trying to add firebase code into Vuepress so I can embed a simple review app into all the Vuepress pages. Wondering how to do that?
```
<script src="https://www.gstatic.com/firebasejs/5.5.6/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "asdf",
authDomain: "adsf-9e0b6.firebaseapp.com",
databaseURL: "https://asdf-9e0b6.firebaseio.com",
projectId: "sadf-9e0b6",
storageBucket: "adsf-9e0b6.appspot.com",
messagingSenderId: "asdf"
};
firebase.initializeApp(config);
</script>
```
Add something like this in the config.js
within the head array. Note that this adds firebase-app
(core), firebase-auth
, firestore
, and cloud functions
as I'm using 4 modules in my project.
NOTE that I'm also initializing both firebase
and firestore
in here. So I get firestore as a global variable.
When firebase loads, all these will be hoisted to the head section of the app.
head: [
[
"script",
{
src: "https://www.gstatic.com/firebasejs/5.5.6/firebase-app.js"
}
],
[
"script",
{
src: "https://www.gstatic.com/firebasejs/5.5.6/firebase-auth.js"
}
],
[
"script",
{
src: "https://www.gstatic.com/firebasejs/5.5.6/firebase-firestore.js"
}
],
[
"script",
{
src: "https://www.gstatic.com/firebasejs/5.5.6/firebase-functions.js"
}
],
[
"script",
{},
`var config = {
apiKey: "apikey",
authDomain: "app.firebaseapp.com",
databaseURL: "https://app.firebaseio.com",
projectId: "appname",
storageBucket: "appname.appspot.com",
messagingSenderId: "12345"
};
firebase.initializeApp(config);
const firestore = firebase.firestore();
const settings = { /* your settings... */
timestampsInSnapshots: true
};
firestore.settings(settings);`
],
]