Skip to content

Commit

Permalink
refactor(examples): refactor example directory
Browse files Browse the repository at this point in the history
  • Loading branch information
lihbr committed May 20, 2021
1 parent b0ada1d commit 01051cb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "XvoFFREAAM0WGBng",
"uid": "test",
"type": "page",
"url": null,
"href": "https://example.cdn.prismic.io/api/v2/documents/search",
"tags": [],
"first_publication_date": "2020-06-29T15:13:27+0000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { asDate } = require("@prismicio/helpers");

const doc = require("./.document.mock.json");
// An hypothetic document from Prismic...
const doc = require("../document.mock.json");

const date = asDate(doc.data.date);
console.log(date.toUTCString());
Expand Down
9 changes: 9 additions & 0 deletions examples/javascript/resolve-documents-links.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const { asLink, documentToLinkField } = require("@prismicio/helpers");

// An hypothetic document from Prismic...
const doc = require("../document.mock.json");

const linkResolver = doc => `/${doc.uid}`;

const docLink = asLink(documentToLinkField(doc), linkResolver);
console.log(docLink);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { asLink } = require("@prismicio/helpers");

const doc = require("./.document.mock.json");
// An hypothetic document from Prismic...
const doc = require("../document.mock.json");

const linkResolver = doc => `/${doc.uid}`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { asDate } from "@prismicio/helpers";

import doc from "./.document.mock.json";
// An hypothetic document from Prismic...
import doc from "../document.mock.json";

const date = asDate(doc.data.date);
console.log(date.toUTCString());
Expand Down
13 changes: 13 additions & 0 deletions examples/typescript/resolve-documents-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import {
asLink,
documentToLinkField,
LinkResolverFunction
} from "@prismicio/helpers";

// An hypothetic document from Prismic...
import doc from "../document.mock.json";

const linkResolver: LinkResolverFunction = doc => `/${doc.uid}`;

const docLink = asLink(documentToLinkField(doc), linkResolver);
console.log(docLink);
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { asLink } from "@prismicio/helpers";
import { asLink, LinkResolverFunction } from "@prismicio/helpers";

import doc from "./.document.mock.json";
// An hypothetic document from Prismic...
import doc from "../document.mock.json";

const linkResolver = doc => `/${doc.uid}`;
const linkResolver: LinkResolverFunction = doc => `/${doc.uid}`;

const relation = asLink(doc.data.relation, linkResolver);
console.log(relation);
Expand Down

0 comments on commit 01051cb

Please sign in to comment.