Merge remote-tracking branch 'weaxs/translations-v1' into translations-v1

This commit is contained in:
Aphcity
2024-03-20 18:44:18 +08:00
parent 4a95a42286
commit 4ef29d4697
16 changed files with 670 additions and 629 deletions

View File

@@ -1,30 +1,30 @@
---
title: "Firebase: Views & Likes"
title: "Firebase: 阅读量 & 点赞量"
date: 2020-08-03
draft: false
description: "Learn how to integrate Firebase and get dynamic data for views and likes."
description: "了解 Blowfish 如何继承 Firebase并动态显示阅读量和点赞量。"
slug: "firebase-views"
tags: ["firebase", "views", likes]
series: ["Documentation"]
tags: ["firebase", "阅读量", "点赞量"]
series: ["文档集"]
series_order: 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.
为了能够在网站中获取动态数据,我们支持了对 Firebase 的集成。这将允许你在列表和文章中使用阅读量功能。
1. Go to <a target="_blank" href="https://firebase.com">Firebase website</a> 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 <a target="_blank" href="{{< ref "configuration/#theme-parameters" >}}">this page</a>. You can find an example of the file Firebase will provide below, notice the parameters within the FirebaseConfig object.
1. 访问 <a target="_blank" href="https://firebase.com">Firebase</a> 并创建一个账户
2. 创建一个新项目
3. 选择分析位置
4. Blowfish 是通过 `params.toml` 配置文件中的 firebase 相关参数,来和 firebase 继承的,更多的细节内容可以参考 <a target="_blank" href="{{< ref "configuration/#theme-parameters" >}}">这个页面</a>。你可以在下面找到集成 firebase 的文件示例,请注意 FirebaseConfig 对象内的参数。
```
// Import the functions you need from the SDKs you need
// 从你需要的 SDK 中导入所需的函数
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
// 你 Web 应用的 Firebase 配置
// 对于 Firebase JS SDK v7.20.0 以及更高版本,measurementId 参数是可选的
const firebaseConfig = {
apiKey: "AIzaSyB5tqlqDky77Vb4Tc4apiHV4hRZI18KGiY",
authDomain: "blowfish-21fff.firebaseapp.com",
@@ -35,12 +35,12 @@ const firebaseConfig = {
measurementId: "G-PEDMYR1V0K"
};
// Initialize Firebase
// 初始化 Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
```
5. 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.
5. 设置 Firestore - 选择 Build 并打开 Firestore. 创建一个数据库,并在生产环境中启动。选择服务器位置然后等待其部署完成。启动之后你需要配置规则。只需要复制并粘贴下面的内容,然后点击发布即可。
```
rules_version = '2';
service cloud.firestore {
@@ -51,5 +51,5 @@ service cloud.firestore {
}
}
```
6. Enable anonymous authorization - Select Build and open Authentication. Select get started, click Anonymous and turn it on, save.
7. Enjoy - you can now activate views and likes on Blowfish for all (or specific) articles.
6. 开启匿名授权 - 选择 Build 并打开 Authentication。选择开始点击 Anonymous 并开启,保存。
7. 享受 - 现在可以激活 Blowfish 中文章阅读量和点赞量的功能。