Gatsby: 질문 : gatsby-source-filesystem 이름을 기반으둜 μ–΄λ–»κ²Œ μΏΌλ¦¬ν•©λ‹ˆκΉŒ?

에 λ§Œλ“  2017λ…„ 07μ›” 27일  Β·  20μ½”λ©˜νŠΈ  Β·  좜처: gatsbyjs/gatsby

νŽ˜μ΄μ§€ μœ ν˜•λ³„λ‘œ μ—¬λŸ¬ 폴더가 μžˆμŠ΅λ‹ˆλ‹€. 즉. 마크 λ‹€μš΄ νŒŒμΌμ„ ν¬ν•¨ν•˜λŠ” type1, type2 λ“±.

   --type1
   --type2

각 ν΄λ”μ˜ νŒŒμΌμ€ gatsby-transformer-remark μ‚¬μš©ν•˜μ—¬ λ³€ν™˜λ©λ‹ˆλ‹€.
type1, type2 등에 λŒ€ν•œ μ½˜ν…μΈ  만 μΏΌλ¦¬ν•˜κ³  μ‹ΆμŠ΅λ‹ˆλ‹€.
예λ₯Ό λ“€μ–΄ λͺ¨λ“  type1 νŽ˜μ΄μ§€μ˜ λͺ©λ‘μ„ ν¬ν•¨ν•˜λŠ” type1 λͺ©λ‘ νŽ˜μ΄μ§€λ₯Ό μ›ν•©λ‹ˆλ‹€.

gatsby-config.js

   {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages/type1`,
        name: 'type1',
      },
    },
    {
      resolve: 'gatsby-source-filesystem',
      options: {
        path: `${__dirname}/src/pages/type2`,
        name: 'type2',
      },
    },

λ‚΄ 가정은 name 속성을 기반으둜 쿼리 ν•  수 β€‹β€‹μžˆλ‹€λŠ” κ²ƒμž…λ‹ˆλ‹€.

λ‹€μŒκ³Ό 같은 것 :

{
  someQueryForGatsbySourceFilesystem(
    filter: {
      name: {
        eq: "type1"
      }
    }
  ) {
    edges {
      node {
        childMarkdownRemark {
          html
        }
      }
    }
  }
}

allSite 및 allFileκ³Ό 같은 λͺ¨λ“  λ‹€λ₯Έ 쿼리λ₯Ό μ‹œλ„ν–ˆμ§€λ§Œ μ†”λ£¨μ…˜μ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.
λ‚˜λŠ” λ˜ν•œ μ‹œλ„ν–ˆλ‹€

  allSitePlugin(filter: {
    pluginOptions: {
      name: {
        eq: "type1"
      }
    }
  })

μ½˜ν…μΈ λ₯Ό λ Œλ”λ§ν•˜λŠ” 데 μ‚¬μš©ν•  μˆ˜μžˆλŠ” 것을 λ°˜ν™˜ν•˜μ§€ μ•ŠλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

"Cannot query field \"childMarkdownRemark\" on type \"SitePlugin\".",

μ–΄λ–»κ²Œ ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ? 경둜 이름 (예 : type1 폴더 및 마크 λ‹€μš΄ ν™•μž₯μžμ™€ μΌμΉ˜ν•˜λŠ” μ •κ·œμ‹)을 기반으둜 allFile 및 ν•„ν„°λ₯Ό μ‚¬μš©ν•©λ‹ˆκΉŒ?

 allFile(
  filter: {
    absolutePath:{regex:"/(type1)\/.*\\.md$/"}
  }
) {...}
question or discussion

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

@ tsiq-swyx File μ—μ„œ MarkdownRemark κΉŒμ§€ File collection ν•„λ“œλ₯Ό μ „λ‹¬ν•˜κΈ° μœ„ν•΄ 이와 같은 것을 μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
  const { createNodeField } = boundActionCreators

  if (_.get(node, 'internal.type') === `MarkdownRemark`) {
    // Get the parent node
    const parent = getNode(_.get(node, 'parent'))

    // Create a field on this node for the "collection" of the parent
    // NOTE: This is necessary so we can filter `allMarkdownRemark` by
    // `collection` otherwise there is no way to filter for only markdown
    // documents of type `post`.
    createNodeField({
      node,
      name: 'collection',
      value: _.get(parent, 'sourceInstanceName'),
    })

regex μ ‘κ·Ό 방식은 μž‘λ™ν•˜μ§€λ§Œ μ·¨μ•½ν•©λ‹ˆλ‹€.

λͺ¨λ“  20 λŒ“κΈ€

allMarkdownRemark μ‚¬μš©ν•˜μ—¬ 경둜λ₯Ό 필터링 ν•  μˆ˜λ„ μžˆλ‹€κ³  μƒκ°ν–ˆμŠ΅λ‹ˆλ‹€.

{
   allMarkdownRemark(
    sort: { order: DESC, fields: [frontmatter___date]},
    filter: {fileAbsolutePath: {regex: "/(type1)/.*\\.md$/"}}
  ) {
      edges {
        node {
          excerpt(pruneLength: 250)
          id
          frontmatter {
            title
            date(formatString: "MMMM DD, YYYY")
            path
          }
        }
      }
    }
}

파일 λ…Έλ“œμ—λŠ” sourceInstanceName 둜 μ„€μ •λœ μ†ŒμŠ€ μΈμŠ€ν„΄μŠ€ 이름이 μžˆμœΌλ―€λ‘œμ΄λ₯Ό 쿼리에 μ‚¬μš©ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

regexλ₯Ό μ‚¬μš©ν•˜λŠ” 것은 쒋은 μ†”λ£¨μ…˜μ΄κΈ°λ„ν•©λ‹ˆλ‹€. 예λ₯Ό λ“€μ–΄ gatsbyjs.orgμ—μ„œ 많이 μ‚¬μš©ν•©λ‹ˆλ‹€.

BTW, 아직 μ‚¬μš©ν•˜κ³  μžˆμ§€ μ•Šλ‹€λ©΄ GraphiQL은 μ‚¬μš© κ°€λŠ₯ν•œ 데이터λ₯Ό νƒμƒ‰ν•˜λŠ” 데 μ ν•©ν•©λ‹ˆλ‹€.

@KyleAMathews allMarkdownRemark μΏΌλ¦¬μ—μ„œ sourceInstanceName λ₯Ό μ‚¬μš©ν•˜λŠ” 방법이 μžˆμŠ΅λ‹ˆκΉŒ? 이처럼 각 마크 λ‹€μš΄ λ…Έλ“œμ— λŒ€ν•œ 파일 λ…Έλ“œμ˜ sourceInstanceName λ₯Ό 얻을 수 있기λ₯Ό 바라고 μžˆμ—ˆκΈ° λ•Œλ¬Έμ— 파일 κ²½λ‘œμ— μ •κ·œμ‹μ„ μ‚¬μš©ν•˜μ§€ μ•Šκ³ λ„ λ‚΄ ν”„λ‘œμ νŠΈμ—μ„œ λΈ”λ‘œκ·Έ κ²Œμ‹œλ¬Όμ„ 뢄리 ν•  수 β€‹β€‹μžˆμŠ΅λ‹ˆλ‹€.

{
  allMarkdownRemark {
    edges {
      node {
        sourceInstanceName
      }
    }
  }
}

κ·ΈλŸ¬λ‚˜ GraphQL λ””λ²„κ±°λŠ” sourceInstanceName λ₯Ό μ‚¬μš©ν•  수 μ—†μŒμ„ λ³΄μ—¬μ€λ‹ˆλ‹€.

ν”„λ‘œμ νŠΈ 및 λΈ”λ‘œκ·Έ κ²Œμ‹œλ¬Όκ³Ό 같은 μ†ŒμŠ€ μœ ν˜•λ³„λ‘œ 마크 λ‹€μš΄ νŽ˜μ΄μ§€λ₯Ό ν•„ν„°λ§ν•˜λŠ” 것이 μ’‹μŠ΅λ‹ˆλ‹€. 이에 λŒ€ν•œ λ‚˜μ˜ ν˜„μž¬ 해결책은 각 마크 λ‹€μš΄ λ…Έλ“œμ˜ fileAbsolutePath λ₯Ό μ–»λŠ” κ²ƒμž…λ‹ˆλ‹€.

{
  allMarkdownRemark {
    edges {
      node {
        fileAbsolutePath
      }
    }
  }
}

그런 λ‹€μŒ /pages/blog/ λ˜λŠ” /pages/projects/ 와 같은 νŠΉμ • λ¬Έμžμ—΄μ΄ ν¬ν•¨λ˜μ–΄ μžˆλŠ”μ§€ ν…ŒμŠ€νŠΈν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ gatsby μ‚¬μ΄νŠΈ 디렉토리 μžμ²΄μ— λŒ€ν•œ μ ˆλŒ€ κ²½λ‘œμ— μ΄λŸ¬ν•œ λ¬Έμžμ—΄ 쀑 ν•˜λ‚˜κ°€ ν¬ν•¨λ˜μ–΄ 있으면 μ€‘λ‹¨λ©λ‹ˆλ‹€. 이 경우 λͺ¨λ²” μ‚¬λ‘€λ‘œ 무엇을 ꢌμž₯ν•©λ‹ˆκΉŒ? (λ¬Έμ„œμ—μ„œ λ­”κ°€λ₯Ό λ†“μΉœ 경우 μ£„μ†‘ν•©λ‹ˆλ‹€.)

@nwshane 은 allFile μΏΌλ¦¬ν•˜κ³  κ±°κΈ°μ—μ„œ ν•„ν„°λ§ν•©λ‹ˆλ‹€. internal.mediaType 둜 마크 λ‹€μš΄ νŒŒμΌμ„ 필터링 ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

@KyleAMathews allFile 에 λŒ€ν•œ 쿼리λ₯Ό frontmatter에 λŒ€ν•œ μ •λ ¬κ³Ό μ–΄λ–»κ²Œ κ²°ν•©ν•©λ‹ˆκΉŒ? κ°€λŠ₯ν•©λ‹ˆκΉŒ?

λΉ„μŠ·ν•œ 것을 μ•Œμ•„ λ‚΄λ €κ³ ν•©λ‹ˆλ‹€.

ν•˜μœ„ ν΄λ”λ‘œ 필터링 ν•  수 μžˆμŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ frontmatter μ—μ„œ allFile frontmatter 을 (λ₯Ό) λ³Ό 수 μ—†μŠ΅λ‹ˆλ‹€.

screen shot 2018-02-25 at 8 18 51 p m

μ΅œμ‹  정보:

이것은 λ‚˜λ₯Ό μœ„ν•΄ μΌν–ˆμŠ΅λ‹ˆλ‹€.

λ‚˜λŠ” 폴더가 posts 및 pages 폴더 λ‚΄μ˜ content λ‚΄ gatsby-config.js 포인트 content .

export const query = graphql`
  query IndexQuery {
    allMarkdownRemark(
      filter: { fileAbsolutePath: {regex : "\/posts/"} },
      sort: {fields: [frontmatter___date], order: DESC},
    ) {
      totalCount
      edges {
        node {
          id
          frontmatter {
            title
            slug
            date(formatString: "DD MMMM YYYY")
            category
          }
          excerpt
        }
      }
    }
  }
`;

@lukejanicke λ§ˆμ§€λ§‰ μ—…λ°μ΄νŠΈ μ΄ν›„λ‘œ λ…Έλ“œ μ‹œμŠ€ν…œμ— 쑰금 더 λ›°μ–΄ λ“€μ—ˆμŠ΅λ‹ˆλ‹€. allFile λ…Έλ“œλŠ” 마크 λ‹€μš΄ ν•Έλ“€λŸ¬μ— μ˜ν•΄ ꡬ문 λΆ„μ„λ˜κ³  μƒˆ allMarkdownRemark λ…Έλ“œκ°€ μƒμ„±λ©λ‹ˆλ‹€. λ”°λΌμ„œ allFile μ—μ„œλŠ” 마크 λ‹€μš΄ νŒŒμ„œκ°€ μ‹œμž‘λœ 후에 만 β€‹β€‹μƒμ„±λ˜κΈ° λ•Œλ¬Έμ— onCreateNode 후크λ₯Ό 톡해 파일 λ…Έλ“œμ—μ„œ 마크 λ‹€μš΄ λ…Έλ“œλ‘œ μ»¬λ ‰μ…˜ 이름 (파일 μ‹œμŠ€ν…œ μ†ŒμŠ€ ν”ŒλŸ¬κ·ΈμΈ ꡬ성에 지정됨)을 λ³΅μ‚¬ν•˜λŠ” 것이 μ—ˆμŠ΅λ‹ˆλ‹€. 예제λ₯Ό κ²Œμ‹œ ν•  μ½”λ“œλŠ” μ—†μ§€λ§Œ 맀우 λΉ λ₯΄λ©° allMarkdownRemark μ•ˆμ— 필터링 ν•  μˆ˜μžˆλŠ” ν•„λ“œκ°€ μžˆμŠ΅λ‹ˆλ‹€.

@KyleAMathewsκ°€ μ‘°μ–Έ ν•œ 또 λ‹€λ₯Έ κ°€λŠ₯μ„± (제 경우 μ†ŒμŠ€ 이름은 projects )

allFile(filter: {internal: {mediaType: {eq: "text/markdown"}}, sourceInstanceName: {eq: "projects"}}) {
  edges {
    node {
      childMarkdownRemark {
        frontmatter {
            ...
        }
      }
    }
  }
}

@gbouteiller 사싀, frontmatter λ₯Ό μ–»κ³  sourceInstanceName 둜 필터링 ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ¬Έμ œλŠ”μ΄ μ ‘κ·Ό 방식을 μ‚¬μš©ν•˜μ—¬ frontmatter λ‚΄λΆ€μ˜ μ–΄λ–€ 것도 μ •λ ¬ ν•  수 μ—†λ‹€λŠ” frontmatter μ•ˆμ— μ €μž₯λ©λ‹ˆλ‹€.

μ—μ„œ 일을 κΈ°μ€€μœΌλ‘œ μ •λ ¬ ν•  μˆ˜μžˆλŠ” 방법이 μ—†μŠ΅λ‹ˆλ‹€ frontmatter 에 μ˜ν•΄ ν•„ν„° sourceInstanceName κΈ°λ³Έμ μœΌλ‘œλŠ”. sourceInstanceName 은 File λ…Έλ“œμ—μ„œ markdownRemark λ…Έλ“œλ‘œ λ³΅μ‚¬λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μœ μΌν•œ μ˜΅μ…˜μ€ μ •κ·œμ‹μ„ μ‚¬μš©ν•˜κ±°λ‚˜ 이전 κ²Œμ‹œλ¬Όμ— 따라 일뢀 데이터λ₯Ό λ³΅μ‚¬ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€.

정렬이 ν•„μš”ν•˜μ§€ μ•Šμ€ 경우 (λ§Žμ€ κ²½μš°μ— ν•΄λ‹Ή ν•  수 있음) μ ‘κ·Ό 방식이 맀우 ν•©λ¦¬μ μž…λ‹ˆλ‹€. λ‚˜λŠ” λͺ°λžλ‹€ childMarkdownRemark 에 ν•„λ“œλ‘œ μ‚¬μš©ν•  μˆ˜μžˆμ—ˆμŠ΅λ‹ˆλ‹€ file , μ•Œκ³  맀우 유용 곡유λ₯Όμœ„ν•œ 감사이.

"name"ν•„λ“œκ°€ markdownRemark와 잘 μž‘λ™ν•˜μ§€ μ•ŠλŠ”λ‹€λŠ” 사싀에 μ‹€λ§ν–ˆμŠ΅λ‹ˆλ‹€. 이 정보λ₯Ό μ „λ‹¬ν•˜κΈ° μœ„ν•΄ ν•  μˆ˜μžˆλŠ” μž‘μ€ μŠΉλ¦¬κ°€ μžˆμŠ΅λ‹ˆκΉŒ?

νŽΈμ§‘ : 쑰금 μ—‰λ§μœΌλ‘œ λ§Œλ“  ν›„ id ν•„λ“œκ°€ 경둜λ₯Ό λ…ΈμΆœν•˜κ³ μ΄λ₯Ό 기반으둜 필터링 ν•  수 μžˆμŒμ„ κΉ¨λ‹¬μ•˜μŠ΅λ‹ˆλ‹€.

query AllQuery {
    DSes: allMarkdownRemark(
      limit: 3
      filter: { id: { regex: "/_design-systems/" } }
    ) {
      edges {
        node {
          frontmatter {
            title
            date
            company
            link
            image
            description
          }
          fields {
            slug
          }
        }
      }
    }

    Articles: allMarkdownRemark(
      limit: 3
      filter: { id: { regex: "/_articles/" } }
    ) {
      edges {
        node {
          frontmatter {
            title
            date
            company
            link
            image
            description
          }
          fields {
            slug
          }
        }
      }
    }
  }

μ†ŒμŠ€ 파일 μ‹œμŠ€ν…œμ˜ name ν•„λ“œλŠ” μ—¬μ „νžˆ gatsby-transformer-remark에 λŒ€ν•΄ 아무 μž‘μ—…λ„ μˆ˜ν–‰ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. gatsby-transformer-remark κ²°μ½” 이후 쿼리 κ°€λŠ₯ / 필터링 κ°€λŠ₯ν•œ ν•„λ“œλ‘œμ΄λ₯Ό ν†΅κ³Όν•˜λ„λ‘ dxλ₯Ό μ•½κ°„ κ°œμ„ ν•œλ‹€κ³  말할 수 μžˆμŠ΅λ‹ˆλ‹€. gatsby-source-filesystem 없이 μ‘΄μž¬ν•©λ‹ˆλ‹€.

@ tsiq-swyx File μ—μ„œ MarkdownRemark κΉŒμ§€ File collection ν•„λ“œλ₯Ό μ „λ‹¬ν•˜κΈ° μœ„ν•΄ 이와 같은 것을 μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

exports.onCreateNode = ({ node, boundActionCreators, getNode }) => {
  const { createNodeField } = boundActionCreators

  if (_.get(node, 'internal.type') === `MarkdownRemark`) {
    // Get the parent node
    const parent = getNode(_.get(node, 'parent'))

    // Create a field on this node for the "collection" of the parent
    // NOTE: This is necessary so we can filter `allMarkdownRemark` by
    // `collection` otherwise there is no way to filter for only markdown
    // documents of type `post`.
    createNodeField({
      node,
      name: 'collection',
      value: _.get(parent, 'sourceInstanceName'),
    })

regex μ ‘κ·Ό 방식은 μž‘λ™ν•˜μ§€λ§Œ μ·¨μ•½ν•©λ‹ˆλ‹€.

@chmac 이것은 맀우 μ˜λ¦¬ν•˜κ³  μž‘λ™ν•©λ‹ˆλ‹€. μ†”λ£¨μ…˜μ„ κ³΅μœ ν•΄ μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. @KyleAMathews νƒœκ·Έλ₯Ό μ§€μ •ν•΄μ„œ λ―Έμ•ˆν•˜μ§€λ§Œ (νƒœκ·Έ ν•  λ‹€λ₯Έ μ‚¬λžŒμ΄μžˆλŠ” 경우 lmk) 기본적으둜 gatsby-source-filesystem 이 μ΄λŸ¬ν•œ λ°©μ‹μœΌλ‘œ μž‘λ™ ν•  수 μžˆμŠ΅λ‹ˆκΉŒ (sourceInstanceName을 λ…Έλ“œ ν•„λ“œ λ˜λŠ” λ‹€λ₯Έ ν•„λ“œμ— 전달)?

@ tsiq-swyx 100 % ν™•μ‹€ν•˜μ§€λŠ” μ•Šμ§€λ§Œ μƒλ‹Ήνžˆ κ°„λ‹¨ν•œ ν’€ λ¦¬ν€˜μŠ€νŠΈλΌκ³  μƒκ°ν•©λ‹ˆλ‹€! ;-)

λ‚˜λŠ” κ°œμΈ λΉ„ κ΄€λ¦¬μžκ°€ μ΄λŸ¬ν•œ 것듀에 λŒ€ν•΄ κ°•ν•œ μ˜κ²¬μ„ 가지고 μžˆλ‹€κ³  μƒκ°ν•˜λ―€λ‘œ μž„μ˜μ˜ μ›μΉ˜ μ•ŠλŠ” PR을 보내기 전에 λ…Όμ˜ ν•  κ°€μΉ˜κ°€ μžˆλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. :)

μ’‹μ•„, μž‘λ™ν•˜μ§€λ§Œ λ‚΄ createPages λ‚΄λ³΄λ‚΄κΈ°λŠ” ν•˜λ‚˜μ˜ ν…œν”Œλ¦Ώ 만 μ‚¬μš©ν•©λ‹ˆλ‹€.

gatsby-source-filesystem 것이 graphql의 AllFile을 μ „ν˜€ ν•„μš”λ‘œν•˜μ§€ μ•ŠλŠ”λ‹€λŠ” 것은 ν₯λ―Έ λ‘­μŠ΅λ‹ˆλ‹€. ν˜Όλž€μ„ κ°€μ Έμ˜¬ 수 있으며 λ¬Έμ„œμ— λ°˜μ˜λ˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
λ‚˜λŠ” μ‚¬μš©ν•˜κ³ μžˆλ‹€
const { createPage } = actions const result = await graphql(` query { allMarkdownRemark { edges { node { fields { slug } frontmatter { lang } } } } } `)
λ¬Έμ œμ—†μ΄ νŽ˜μ΄μ§€λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ gatsby-source-git 에도 λ™μΌν•œ 원칙이 μ μš©λ˜λŠ”μ§€ ν™•μ‹€ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

κ°μ‚¬ν•©λ‹ˆλ‹€ @chmac

gatsby-source-filesystem 이름을 κΈ°μ€€μœΌλ‘œ νŽ˜μ΄μ§€λ₯Ό λ§Œλ“€μ–΄μ•Όν•©λ‹ˆλ‹€ ...

κ·Έλž˜μ„œ μ—¬κΈ° λ‚΄ 해결책이 μžˆμŠ΅λ‹ˆλ‹€.

const { createFilePath } = require("gatsby-source-filesystem")

exports.onCreateNode = ({ node, actions, getNode }) => {
  const { createNodeField } = actions

  if (node.internal.type === `Mdx` && getNode(node.parent).sourceInstanceName === "careers") {
    const value = createFilePath({ node, getNode })

    createNodeField({
      name: "slug",
      node,
      value: `/careers${value}`
    })
  }
}

이것은 intresting, κ·ΈλŸ¬ν•œ μ˜΅μ…˜μ„ 찾지 λͺ»ν–ˆμŠ΅λ‹ˆλ‹€.

2020 λ…„ 4 μ›” 27 일 μ›”μš”μΌ, Noman Gul [email protected] 은 λ‹€μŒκ³Ό 같이 μΌμŠ΅λ‹ˆλ‹€.

κ°μ‚¬ν•©λ‹ˆλ‹€ @chmac https://github.com/chmac

gatsby-source-filesystem 이름을 기반으둜 νŽ˜μ΄μ§€λ₯Ό λ§Œλ“€μ–΄μ•Όν•©λ‹ˆλ‹€ ...

κ·Έλž˜μ„œ μ—¬κΈ° λ‚΄ 해결책이 μžˆμŠ΅λ‹ˆλ‹€.

const {createFilePath} = require ( "gatsby-source-filesystem")
exports.onCreateNode = ({node, actions, getNode}) => {
const {createNodeField} = μž‘μ—…

if (node.internal.type === Mdx && getNode (node.parent) .sourceInstanceName === "careers") {
const κ°’ = createFilePath ({node, getNode})

createNodeField({
  name: "slug",
  node,
  value: `/careers${value}`
})

}
}

β€”
λŒ“κΈ€μ„ λ‹¬μ•˜ κΈ° λ•Œλ¬Έμ— μˆ˜μ‹  ν•œ κ²ƒμž…λ‹ˆλ‹€.
이 이메일에 직접 λ‹΅μž₯ν•˜κ³  GitHubμ—μ„œ ν™•μΈν•˜μ„Έμš”.
https://github.com/gatsbyjs/gatsby/issues/1634#issuecomment-619670883 ,
λ˜λŠ” ꡬ독 μ·¨μ†Œ
https://github.com/notifications/unsubscribe-auth/AAEQPFX6KR7NUIY33Q7V4MDROTS7PANCNFSM4DUUPK6A
.

λ‚˜λŠ”μ΄ 글을 읽은 ν›„ κ½€ ν”ν•œ 경우라고 μƒκ°ν•˜λŠ” 것과 같은 μƒν™©μ—μžˆλ‹€. 제 생각에 κ°€μž₯ μ’‹κ³  ν•΄ν‚Ήλ˜μ§€ μ•Šμ€ μ†”λ£¨μ…˜μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

{
  allMarkdownRemark(filter: {fileAbsolutePath: {regex: "/projects/"}}) {
    edges {
      node {
        frontmatter {
          title
        }
      }
    }
  }
}

λ‚΄ projects μ½˜ν…μΈ  μœ ν˜•μ€ /content/projects/ μžˆμŠ΅λ‹ˆλ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰