Firebase: Views & Likes
Documentation - This article is part of a series.
Part 15: This Article
In order to be able to support dynamic data across your website we’ve added the support to integrate Firebase. This will allow you to use the views feature across lists and posts.
- Go to Firebase website and create an account for free
- Create a new project
- Select analytics location
- Setup firebase in Blowfish by getting the variables for your project and setting them inside
params.toml
file. More details can be found in this page. You can find an example of the file Firebase will provide below, notice the parameters within the FirebaseConfig object.
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries
// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {
apiKey: "AIzaSyB5tqlqDky77Vb4Tc4apiHV4hRZI18KGiY",
authDomain: "blowfish-21fff.firebaseapp.com",
projectId: "blowfish-21fff",
storageBucket: "blowfish-21fff.appspot.com",
messagingSenderId: "60108104191",
appId: "1:60108104191:web:039842ebe1370698b487ca",
measurementId: "G-PEDMYR1V0K"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
- Setup Firestore - Select Build and open Firestore. Create a new database and choose to start in production mode. Select server location and wait. Once that is started you need to configure the rules. Just copy and paste the file below and press publish.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
- Enable anonymous authorization - Select Build and open Authentication. Select get started, click Anonymous and turn it on, save.
- Enjoy - you can now activate views and likes on Blowfish for all (or specific) articles.
Documentation - This article is part of a series.
Part 15: This Article