From 8fb3173a110cd2052e62a46b9aa115b42d965a28 Mon Sep 17 00:00:00 2001 From: Alberto Pasqualetto <39854348+albertopasqualetto@users.noreply.github.com> Date: Fri, 22 Jul 2022 16:27:50 +0200 Subject: [PATCH 1/2] docs/docs/node-apis --- docs/docs/node-apis.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/docs/node-apis.md b/docs/docs/node-apis.md index ea951b5..8e81f1e 100644 --- a/docs/docs/node-apis.md +++ b/docs/docs/node-apis.md @@ -1,39 +1,39 @@ --- -title: Gatsby Node APIs -description: Documentation on Node APIs used in Gatsby build process for common uses like creating pages +title: API di Node in Gatsby +description: Documentazione della API di Node usate nel processo di compilazione per utenti comuni come creare pagine jsdoc: ["src/utils/api-node-docs.ts"] apiCalls: NodeAPI --- -Gatsby gives plugins and site builders many APIs for controlling your site's data in the GraphQL data layer. +Gatsby fornisce ai plugin e compilatori di sito molte API per controllare i dati del tuo sito nel livello dati di GraphQL. -## Async plugins +## Plugin asincroni -If your plugin performs async operations (disk I/O, database access, calling remote APIs, etc.) you must either return a promise (explicitly using `Promise` API or implicitly using `async`/`await` syntax) or use the callback passed to the 3rd argument. Gatsby needs to know when plugins are finished as some APIs, to work correctly, require previous APIs to be complete first. See [Debugging Async Lifecycles](/docs/debugging-async-lifecycles/) for more info. +Se i tuoi plugin effettuano operazioni asincrone (I/O su disco, accesso a database, chiamare API remote, ecc.), devi ritornare una Promise (usando esplicitamente l'API `Promise` o implicitamente usando la sintassi `async`/`await`) o usando la callback passata al terzo argomento. Gatsby necessita di sapere quando i plugin hanno concluso l'operazione, come alcune APIs, per funzionare correttamente, necessitano prima che altre APIs usate precedentemente siano concluse. Vedi [Debuggare cicli asincroni](/docs/debugging-async-lifecycles/) per maggiori informazioni. ```javascript // Async/await exports.createPages = async () => { - // do async work + // fai qualcosa di asincrono const result = await fetchExternalData() } // Promise API exports.createPages = () => { return new Promise((resolve, reject) => { - // do async work + // fai qualcosa di asincrono }) } // Callback API exports.createPages = (_, pluginOptions, cb) => { - // do async work + // fai qualcosa di asincrono cb() } ``` -If your plugin does not do async work, you can just return directly. +Se il tuo plugin non esegue alcuna operazione asincorna, puoi ritornare direttamente. -## Usage +## Uso -Implement any of these APIs by exporting them from a file named `gatsby-node.js` in the root of your project. +Implementa una qualsiasi di queste APIs esportandole da una file chiamato `gatsby-node.js` nella radice del tuo progetto. \ No newline at end of file From 56d0e601bbde4dfb942efec956a148ff7db69cad Mon Sep 17 00:00:00 2001 From: Alberto Pasqualetto <39854348+albertopasqualetto@users.noreply.github.com> Date: Fri, 30 Sep 2022 23:25:44 +0200 Subject: [PATCH 2/2] API --- docs/docs/node-apis.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/node-apis.md b/docs/docs/node-apis.md index 8e81f1e..bf4095a 100644 --- a/docs/docs/node-apis.md +++ b/docs/docs/node-apis.md @@ -9,7 +9,7 @@ Gatsby fornisce ai plugin e compilatori di sito molte API per controllare i dati ## Plugin asincroni -Se i tuoi plugin effettuano operazioni asincrone (I/O su disco, accesso a database, chiamare API remote, ecc.), devi ritornare una Promise (usando esplicitamente l'API `Promise` o implicitamente usando la sintassi `async`/`await`) o usando la callback passata al terzo argomento. Gatsby necessita di sapere quando i plugin hanno concluso l'operazione, come alcune APIs, per funzionare correttamente, necessitano prima che altre APIs usate precedentemente siano concluse. Vedi [Debuggare cicli asincroni](/docs/debugging-async-lifecycles/) per maggiori informazioni. +Se i tuoi plugin effettuano operazioni asincrone (I/O su disco, accesso a database, chiamare API remote, ecc.), devi ritornare una Promise (usando esplicitamente l'API `Promise` o implicitamente usando la sintassi `async`/`await`) o usando la callback passata al terzo argomento. Gatsby necessita di sapere quando i plugin hanno concluso l'operazione, in quanto alcune API, per funzionare correttamente, necessitano prima che altre API usate precedentemente siano concluse. Vedi [Debuggare cicli asincroni](/docs/debugging-async-lifecycles/) per maggiori informazioni. ```javascript // Async/await @@ -36,4 +36,4 @@ Se il tuo plugin non esegue alcuna operazione asincorna, puoi ritornare direttam ## Uso -Implementa una qualsiasi di queste APIs esportandole da una file chiamato `gatsby-node.js` nella radice del tuo progetto. \ No newline at end of file +Implementa una qualsiasi di queste API esportandole da una file chiamato `gatsby-node.js` nella radice del tuo progetto.