como usa la versión 9 de esta manera puede inicializar la configuración Deberás importar Cloud Firestore a js/firebase.js
documentación https://firebase.google.com/docs/firestore/manage-data/add-data
import { initializeApp } from "firebase/app";
import { getFirestore } from "firebase/firestore";
const firebaseApp = initializeApp({
apiKey: "XXXXXXXXXXXX",
authDomain: "XXXXXXXXXXXXXXX",
projectId: "XXXXXXXXXXXX",
storageBucket: "XXXXXXXXXXXXX",
messagingSenderId: "XXXXXXXXXX",
appId: "XXXXXXXXXXXXXX",
});
Inicialice Firebase
const app = initializeApp(firebaseApp);
Inicialice Cloud Firestore y obtenga una referencia al servicio
const db = getFirestore(app);
export { db };
ahora en js/editor.js para llamar al método set()
import { doc, setDoc } from "firebase/firestore"
import { db } from "js/firebase.js"; <<< revisa si esta ruta esta correcta
publishBtn.addEventListener("click", async () => {
let letters = "abcdefghijklmnñopqrstuvwxyz";
let blogTitle = blogTitleField.value.split(" ").join("-");
let id = "";
for (let i = 0; i < 4; i++) {
id += letters[Math.floor(Math.random() * letters.length)];
let docName = `${blogTitle}-${id}`;
let date = new Date();
console.log("post");
await setDoc(doc(db, "blogs", docName), {
title: blogTitleField.value,
article: articleField.value,
bannerImage: bannerPath,
publishedAt: `${date.getDate()} ${
month[date.getMonth()]
} ${date.getFullYeAR()}`,
})
.then(() => {
console.log("data entered");
location.href = `${docName}`;
})
.catch((err) => {
console.log(err);
});
}
});