Skip to main content
Post Undeleted by ckhanna
added 6 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

In order to render the server url on link field in Next.jsGraphQL, return the jsonValue from GraphQL as below.

query ContentCardQuery($datasource: String!) {
  datasource: item(path: $datasource, language: "en") {
    id
    name
    ... on About {
      title {
        value
      }
      link {
        jsonValue
      }
    }
  }
}

Thereafter you can refer Link component from Next.js in frontendThis will contains the server link as well as enlisted below.

import {
  Link
} from '@sitecore-jss/sitecore-jss-nextjs';

// Refer the link field jsonValue from GraphQL
<Link
  field={props.link.jsonValue}
/>

enter image description here

Using above way,Note: Make sure you can successfully edit and render links in experience editor as wellset the alwaysIncludeServerUrl setting as it displaystrue for the link provider specified on the website as well.

enter image description here

Hope this helps!!! Let me know in case you have any doubts.

In order to render the link field in Next.js, return the jsonValue from GraphQL as below.

query ContentCardQuery($datasource: String!) {
  datasource: item(path: $datasource, language: "en") {
    id
    name
    ... on About {
      title {
        value
      }
      link {
        jsonValue
      }
    }
  }
}

Thereafter you can refer Link component from Next.js in frontend as below.

import {
  Link
} from '@sitecore-jss/sitecore-jss-nextjs';

// Refer the link field jsonValue from GraphQL
<Link
  field={props.link.jsonValue}
/>

Using above way, you can successfully edit and render links in experience editor as well as it displays on website as well.

Hope this helps!!!

In order to render the server url on link field in GraphQL, return the jsonValue from GraphQL as below.

query ContentCardQuery($datasource: String!) {
  datasource: item(path: $datasource, language: "en") {
    id
    name
    ... on About {
      title {
        value
      }
      link {
        jsonValue
      }
    }
  }
}

This will contains the server link as well as enlisted below.

enter image description here

Note: Make sure you set the alwaysIncludeServerUrl setting as true for the link provider specified on the website.

enter image description here

Hope this helps!!! Let me know in case you have any doubts.

Post Deleted by ckhanna
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

In order to render the link field in Next.js, return the jsonValue from GraphQL as below.

query ContentCardQuery($datasource: String!) {
  datasource: item(path: $datasource, language: "en") {
    id
    name
    ... on About {
      title {
        value
      }
      link {
        jsonValue
      }
    }
  }
}

Thereafter you can refer Link component from Next.js in frontend as below.

import {
  Link
} from '@sitecore-jss/sitecore-jss-nextjs';

// Refer the link field jsonValue from GraphQL
<Link
  field={props.link.jsonValue}
/>

Using above way, you can successfully edit and render links in experience editor as well as it displays on website as well.

Hope this helps!!!