第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用 Gatsby 時(shí)在何處記錄數(shù)據(jù)以及如何將數(shù)據(jù)導(dǎo)入 gatsby.config.js

使用 Gatsby 時(shí)在何處記錄數(shù)據(jù)以及如何將數(shù)據(jù)導(dǎo)入 gatsby.config.js

LEATH 2022-07-08 18:33:29
我跟著Gatsby Docs 關(guān)于 Gatsby中的數(shù)據(jù),他們向我展示了如何在其中的 siteMetadata 塊中創(chuàng)建 graphql 變量gatsby.config.jsmodule.exports = {  siteMetadata: {    title: `Title from siteMetadata`,  },  plugins: [    `gatsby-plugin-emotion`,    {      resolve: `gatsby-plugin-typography`,      options: {        pathToConfigModule: `src/utils/typography`,      },    },  ],}然后可以使用 graphql 查詢訪問它import React from "react"import { graphql } from "gatsby"import Layout from "../components/layout"export default ({ data }) => (  <Layout>    <h1>About {data.site.siteMetadata.title}</h1>    <p>      We're the only site running on your computer dedicated to showing the best      photos and videos of pandas eating lots of food.    </p>  </Layout>)export const query = graphql`  query {    site {      siteMetadata {        title      }    }  }`我想將我的網(wǎng)絡(luò)應(yīng)用程序中的所有數(shù)據(jù)與其余代碼分開,并且全部包含在一個(gè)地方,例如我可能有一個(gè)看起來像的文件navLinks = ["Home", "About", "Contact"]homePageIntro = "Hello! Thank you for visiting my website"logo = 'https://aws.amazon.com/mys3.logo'contactPhoto = 'https://aws.amazon.com/mys3.logo'aboutPageFirstPar = 'This is the first paragraph on the about page'aboutPageSecondPar = 'This is the Second paragraph on the about page'或者將我的文本和鏈接分開到單獨(dú)的文件中可能是更好的做法?我只是覺得將所有數(shù)據(jù)變量插入到 siteMetadata 可能不是最好的方法,但也許我錯(cuò)了?
查看完整描述

1 回答

?
慕婉清6462132

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超2個(gè)贊

您可以將數(shù)據(jù)移動(dòng)到單個(gè) JSON 文件中,然后用于gatsby-transformer-json將其放入 graphql。這樣,您可以使用 graphql 查詢訪問您的數(shù)據(jù)。

PS。您也可以使用useStaticQuery掛鉤。

在此處閱讀更多信息:https ://www.gatsbyjs.org/packages/gatsby-transformer-json/


查看完整回答
反對 回復(fù) 2022-07-08
  • 1 回答
  • 0 關(guān)注
  • 160 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)