0

I would like to create a blog with the basic web development tools (html, css, js, nodejs, etc.) using the firebase database/firestore paths to generate the pages links and content. For example, if i have a database like below:

https://i.stack.imgur.com/wElfZ.png

(Sorry, idk why, but wasnt able to upload the image)

Post1 ×Text: text1 ×Title: title1

Post2 ×Text: text2 ×Title: title2

I would like to generate pages like:

www.myblog.com/post1 and www.myblog.com/post2

using the paths child to generate the page content. Is it possible? I would like to use firebase tools because it's fast to implement, easy and free for the contested application. If it's not possible, would have another way to do it?

GusCorreia
  • 75
  • 7
  • You've included a link to a picture of the JSON tree in your question. Please replace that with the actual JSON as text, which you can easily get by clicking the Export JSON link in the overflow menu (⠇) of [your Firebase Database console](https://console.firebase.google.com/project/_/database/data/). Having the JSON as text makes it searchable, allows us to easily use it to test with your actual data and use it in our answer and in general is just a Good Thing to do – Frank van Puffelen Jan 30 '20 at 00:28
  • Thanks Frank... Will follow your advices on my next questions :) – GusCorreia Jan 30 '20 at 00:36

1 Answers1

2

Yup, this sounds feasible.

You'll want to:

  1. use Firebase Hosting rewrites to ensure all relevant URLs end up going to the same HTML+JavaScript page, and then in there,

  2. read the URL from location.href and map it to the corresponding data from the database, and finally

  3. listen to the onhashchange or locationchange event to make sure your code picks up changes in the URL.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807