メインコンテンツへスキップ
  1. 資料/

Firebase: Views & Likes

2 分· ·
Firebase Views Likes
Documentation - この記事は連載の一部です
パート 15: この記事

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.

  1. Go to Firebase website and create an account for free
  2. Create a new project
  3. Select analytics location
  4. 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);
  1. 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;
    }
  }
}
  1. Enable anonymous authorization - Select Build and open Authentication. Select get started, click Anonymous and turn it on, save.
  2. Enjoy - you can now activate views and likes on Blowfish for all (or specific) articles.
Documentation - この記事は連載の一部です
パート 15: この記事

関連記事

Advanced Customisation
9 分
高度なタグ Css Docs
Configuration
18 分
Config Docs
Content Examples
10 分
Content Example
Front Matter
4 分
Front Matter Config Docs
Getting Started
7 分
Installation Docs
Homepage Layout
4 分
Homepage Layouts Docs