Do you have to manually restart Gatsbyjs every time you post? - reactjs

I'm using Gatsby.js. It seems like every time I write a new markdown post I have to stop and restart Gastsby with CTL+C and then npm run develop. Is that the normal procedure? It makes it hard to add content if I'm stuck doing that every time.

When adding posts the dev server automatically updates (no need to restart your dev server) I'm guessing it's a custom implementation issue. try following the official tutorial https://www.gatsbyjs.org/tutorial/part-four/ and see how it works for you.
note: the only reason to restart the server relates to changes (e.g. adding a new plugin) you do in your gatsby-config.js

Related

Deploy React app with JSON-server as backend

I made a simple CRUD application that is supposed to be an appointment manager based on Traversy's Task Manager (found here: https://www.youtube.com/watch?v=w7ejDZ8SWv8), and now I'm trying to publish it.
I have found a number of guides but none have helped me. I'll list them below:
https://dev.to/nikita_guliaev/deploying-create-react-app-with-json-server-as-backend-to-github-3pp9
https://github.com/YoussefZidan/fake-server
https://www.youtube.com/watch?v=5cbFLDe4OAA
The one that I believe came the closest to help me do what I want is the first one listed. If I follow it to the letter, all I get is the background but nothing else. I experimented trying to run it on my pc, changing the fetch requests from localhost to https://my-json-server.typicode.com/jmiguelcastellanosj/ap-m/appointments but it didn't work. I removed the homepage property from the package.json file and it worked on my computer (changes didn't persist, but from my understanding that's expected from the service provided by typicode), tried deploying it but it didn't even load the background.
I could describe my other attempts with the other two guides, but other than finding out that heroku exists, I don't think I got much useful learning from them.
Ideally, I would like the changes to persist after reloading the application, but right now that seems like a pipedream considering it doesn't even work once deployed.
I have a feeling that the reason for this app not working is related to the fetch requests (found in Dashboard.js, AddAppointmentForm.js, EditAppointment.js, Appointment.js), but I really don't know.
This is my first time trying to deploy anything, so I have no idea what it is that I'm missing or doing wrong, and having spent days trying and failing at this, I'm at a complete loss on what to do. Help would be greatly appreciated. Thank you.
My repo can be found here: https://github.com/jmiguelcastellanosj/ap-m
Right now it should be able to work locally with json-server as backend.
Before building set your "homepage" in package.json to "https://jmiguelcastellanosj.github.io/ap-m", this will let github pages load your files properly.
Also if your routing doesn't work properly, in each of your routes add "/ap-m" in front of your path (So path='/' becomes path="/ap-m")

Is there a way when I update the site, the cache is refreshed

I am using React, and the service worker is activated and caches the static and everything is fine until now
The problem is when I make changes to the site and deploy the files
The site still displays the old version, which is the one that was cached before.
And I have to clear the data for the site to see the new version , which is the client will not do :(
Is there a way when I update the site, the cache is refreshed ?
btw I am using the initial service worker that comes with react(which uses "workbox") , and I didn't change any thing in it .
I think you will find an answer here. Read the caution disclamer carefully.

Gatsby Dynamic Rebuild Static Pages on Production

I write my first Gatsby Page. I also use Laravel as backend server.
In my project i have many slug pages. I used createPages and api connection to create them. User can add files like images, audio files and pdf. When it happen, page should change a bit content and show this file on specify address. Develop version works fine (i bind button to start npm run refresh). I used gatsby refresh endpoint and add to scripts:
"refresh": "curl -X POST http://localhost:8000/__refresh"
And it's work fine. But i don't know how change this to use it properly on production build. Can anyone help me? Thanks
The ENABLE_GATSBY_REFRESH_ENDPOINT environment variable is only working on development. According to the documentation:
During local development, it can be useful to refresh sourced content
without restarting the development server. To facilitate this, Gatsby
exposes an environment variable called ENABLE_GATSBY_REFRESH_ENDPOINT.
What you need is called a webhook. Basically, a webhook is a way for an application to trigger a change that happens in real-time in a CMS.
Each CMS has its own way of implementing webhooks, but the idea is to trigger a build process once a change in your CMS occurs.

React hot-loading stopped self updating

I'm trying to implement a solution with react and symfony 2.8, but as I'm new to react I'm still in the tutorials step. Once I though I had a good enough knowledge from react I decided to try and integrate React with symfony and I was almost successful in that. I managed to get a symfony view to load react components but was unable to do live edits, and by that I mean, I have to restart webpack and press F5 to reload the page. So I decided to go back to the tutorials I made and see what I was doing wrong. When I start a new react project (by using "create-react-app projectName") to see where I failed, this project had the same problem, I had to reload the webpack so I could see the changes I made, and I know that this project was able to live-edits (because was the first tutorial I made and was working at the time), all I needed to do is to save the document and the page should automatically show the changes I made.
I think that showing the code its not important in this case because it's a fresh project by using the command I said before, but anything you need I can try to explain you or giving the code.

Is there a way a method can be triggered or run during a salesforce package installation process?

I would want to do this to run post installation setup process like adding custom data that is required for the application to run.
One option I am aware of is to Write Installation and Setup instructions for users. Create visualforce page and include a button on this page. Redirect user to this page as the process of Installation and ask the user to click the button.
I only wanted to know If there was a more elegant way to solve the problem and if there is a way to call a method during the installation process.
Salesforce has recently implemented the ability to execute scripts (as Apex) during package Install / Uninstall:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_install_handler.htm
No, we can't have a post installation script for the app. What you are saying is best solution, just keep a custom setting to flag, if initial setup is not done, then redirect to the setup page first, other wise do the normal work.
My question would be revolving around why you need custom data for the app to run? One of the things Salesforce look for when doing a security review of your code and the unit tests you have is to check to see if you are requiring data in your org as this is bad practice. Note that if your app is requiring specific data to run then it cannot be tested properly as the data will not be in the org when running the tests on install.
What is the data you are requiring? Could it be stored in an xml like static resource file or something similar for you to load and parse as it is needed?
Paul

Resources