Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Updated for section-to-collection changes #45

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .tina/__generated__/schema.gql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions .tina/__generated__/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ You'll find this pattern in other areas too, wherever you have a "public" page,

### `pages/posts/[filename].tsx`

Posts come from the `content/posts` directory in this repo, and their routes are built with `getStaticPaths` dynamically at build time. Again, editing them with Tina can be done by visiting the "admin" version of their URL, so to edit `http://localhost:3000/posts/vote-for-pedro`, visit `http://localhost:3000/admin/posts/vote-for-pedro`.
Posts come from the `content/posts` directory in this repo, and their routes are built with `getStaticPaths` dynamically at build time. Again, editing them with Tina can be done by visiting the "admin" version of their URL, so to edit `http://localhost:3000/posts/voteForPedro`, visit `http://localhost:3000/admin/posts/voteForPedro`.

### `components`

Expand Down
2 changes: 1 addition & 1 deletion components/helper-components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const Nav = () => {
<a href={`${prefix}/`}>Home</a>
</li>
<li>
<a className="summary" href={`${prefix}/posts/vote-for-pedro`}>
<a className="summary" href={`${prefix}/posts/voteForPedro`}>
Vote for Pedro
</a>
</li>
Expand Down
8 changes: 4 additions & 4 deletions components/landing-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const LandingPage = (props: LandingPage_Doc_Data) => {
switch (block.__typename) {
case "Message_Data":
return (
<>
<React.Fragment key={`block-${block.messageHeader}`}>
<h3>{block.messageHeader}</h3>
<Markdown>{block.messageBody}</Markdown>
</>
</React.Fragment>
);
case "Diagram_Data":
return (
<>
<React.Fragment key={`diagram-${block.diagramID}`}>
<h3>{block.diagramHeading}</h3>
<Markdown>{block.diagramDescription}</Markdown>
<iframe
Expand All @@ -26,7 +26,7 @@ export const LandingPage = (props: LandingPage_Doc_Data) => {
height="450"
src={`https://whimsical.com/embed/${block.diagramID}`}
></iframe>
</>
</React.Fragment>
);
default:
return null;
Expand Down
16 changes: 10 additions & 6 deletions components/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export const BlogPost = (props: Article_Doc_Data) => {
const AuthorSnippet = (props: { author: Authors_Document }) => {
return (
<div className="snippet">
<img
className="avatar"
title={props.author.data.name}
src={props.author.data.avatar}
/>
<h3>By {props.author.data.name}</h3>
{props.author && (
<>
<img
className="avatar"
title={props.author.data.name}
src={props.author.data.avatar}
/>
<h3>By {props.author.data.name}</h3>
</>
)}
<style jsx>{`
.snippet {
display: flex;
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@types/node": "^13.13.1",
"@types/react": "^16.9.43",
"@types/styled-components": "^5.1.3",
"tina-graphql-gateway-cli": "0.2.37"
"tina-graphql-gateway-cli": "0.2.38"
},
"dependencies": {
"next": "10.0.5",
Expand All @@ -22,8 +22,11 @@
"react-markdown": "^5.0.3",
"styled-components": "^5.1.3",
"styled-jsx": "^3.2.5",
"tina-graphql-gateway": "0.2.4",
"tinacms": "^0.40.0",
"tina-graphql-gateway": "0.2.5",
"tinacms": "0.31.0",
"typescript": "^3.8.3"
},
"resolutions": {
"final-form": "4.20.1"
}
}
14 changes: 7 additions & 7 deletions utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ export const createLocalClient = () => {
/**
*
* Takes a path (ex. /posts/my-page) and uses the first item
* as the section and the remaining peices for the relativePath
* as the `collection` and the remaining peices for the relativePath
* arguments
*
*/
export const variablesFromPath = (
path: string,
fallback: { relativePath: string; section: string }
fallback: { relativePath: string; collection: string }
) => {
const arr = path.split("/");
const section = arr[0];
const collection = arr[0];
// FIXME: assumes `.md` as extension, should work with other extensions
const relativePath = `${arr.slice(1).join("/")}.md`;

if (section && relativePath) {
return { section, relativePath };
if (collection && relativePath) {
return { collection, relativePath };
} else {
return fallback;
}
Expand All @@ -68,7 +68,7 @@ export const variablesFromPath = (
// FIXME: infer args from useForm
export const redirectToNewDocument = (
args: {
section: {
collection: {
slug: string;
};
relativePath: string;
Expand All @@ -78,7 +78,7 @@ export const redirectToNewDocument = (
prefix: string
) => {
const redirect = `${window.location.origin}${prefix}/${
args.section.slug
args.collection.slug
}/${args.breadcrumbs.join("/")}`;

window.location.assign(redirect);
Expand Down
55 changes: 24 additions & 31 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1115,12 +1115,12 @@
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed"
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==

"@forestryio/gql@0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@forestryio/gql/-/gql-0.1.2.tgz#d1158fdaea796c89f49d8851f3d0d8286480fbbd"
integrity sha512-pbLsSikSfbRHSEjGkp3GeVIznTqhYSpP64j/whTsNyqoES4vfBN4VSqb3IfBDHyjkKQBH7dD5jIDNMYvS1NNWw==
"@forestryio/gql@0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@forestryio/gql/-/gql-0.1.3.tgz#e29854efa8f3780dd2f05caa23cfe5e929724bac"
integrity sha512-qQWL9pNV9qUX64qMaQKuHX3khqDUqLZBYMmW3vnITNQNZzdzPGaOYhP3Bp1U39f+/1v7BbcpRNqkgzJBJhuHHA==
dependencies:
"@forestryio/graphql-helpers" "0.0.19"
"@forestryio/graphql-helpers" "0.0.20"
"@octokit/auth-app" "^2.6.0"
"@octokit/graphql" "^4.5.6"
"@octokit/rest" "^18.0.6"
Expand Down Expand Up @@ -1152,10 +1152,10 @@
ws "^7.3.1"
yup "^0.29.3"

"@forestryio/graphql-helpers@0.0.19":
version "0.0.19"
resolved "https://registry.yarnpkg.com/@forestryio/graphql-helpers/-/graphql-helpers-0.0.19.tgz#a46bd98fd80528eeac542f32aa7987e1d93f4842"
integrity sha512-Xj0LnN/5capg9VV0nq9pnd6eKLfVrxxJmJkYBCFxR+6EPwlqivPPUU56gRg2jjsb8LA52LBOlxUnTf9LZ5FMeQ==
"@forestryio/graphql-helpers@0.0.20":
version "0.0.20"
resolved "https://registry.yarnpkg.com/@forestryio/graphql-helpers/-/graphql-helpers-0.0.20.tgz#2dadd6b922bb526fb066ace1f027f05933e4550c"
integrity sha512-RwICcq4RwZo2irfxEmtOyWNAp+9aq9mIzU1zjjkMbFQxHCVmtLwNnLNy0UuKoDAt05hA1orEBoB+of9qWtUn1g==
dependencies:
"@types/lodash.get" "^4.4.6"
"@types/lodash.kebabcase" "^4.1.6"
Expand Down Expand Up @@ -5248,17 +5248,10 @@ final-form-arrays@^3.0.1, final-form-arrays@^3.0.2:
resolved "https://registry.yarnpkg.com/final-form-arrays/-/final-form-arrays-3.0.2.tgz#9f3bef778dec61432357744eb6f3abef7e7f3847"
integrity sha512-TfO8aZNz3RrsZCDx8GHMQcyztDNpGxSSi9w4wpSNKlmv2PfFWVVM8P7Yj5tj4n0OWax+x5YwTLhT5BnqSlCi+w==

"final-form@4.18 - 4.19":
version "4.19.1"
resolved "https://registry.yarnpkg.com/final-form/-/final-form-4.19.1.tgz#1aa1a3bf67f7399b54ed6185d56f9a8d74cfda5a"
integrity sha512-C4RldRCUs8YZod91ydtrsT+TOeG3fwU4ip9oBDXhvbWdQ6iXl4cIrTAQkqpWijbnI3XFVA0akV7YTjSFJMJ2uw==
dependencies:
"@babel/runtime" "^7.8.3"

final-form@^4.20.1:
version "4.20.2"
resolved "https://registry.yarnpkg.com/final-form/-/final-form-4.20.2.tgz#c820b37d7ebb73d71169480256a36c7e6e6c9155"
integrity sha512-5i0IxqwjjPG1nUNCjWhqPCvQJJ2R+QwTwaAnjPmFnLbyjIHWuBPU8u+Ps4G3TcX2Sjno+O5xCZJzYcMJEzzfCQ==
final-form@4.20.1, final-form@^4.18.2, final-form@^4.20.1:
version "4.20.1"
resolved "https://registry.yarnpkg.com/final-form/-/final-form-4.20.1.tgz#525a7f7f27f55c28d8994b157b24d6104fc560e9"
integrity sha512-IIsOK3JRxJrN72OBj7vFWZxtGt3xc1bYwJVPchjVWmDol9DlzMSAOPB+vwe75TUYsw1JaH0fTQnIgwSQZQ9Acg==
dependencies:
"@babel/runtime" "^7.10.0"

Expand Down Expand Up @@ -11840,13 +11833,13 @@ timsort@^0.3.0:
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=

tina-graphql-gateway-cli@0.2.37:
version "0.2.37"
resolved "https://registry.yarnpkg.com/tina-graphql-gateway-cli/-/tina-graphql-gateway-cli-0.2.37.tgz#1a66c75de746c75017366ed8779a5854b530dd0b"
integrity sha512-PAXvmRSweZbG0IhBgjIn9ReY3XetEfTNd6ReSgglW6IcAM8ahZU7mMNNnkXPNlB5ECdi0J7ptaEgZnGpAE+Lmg==
tina-graphql-gateway-cli@0.2.38:
version "0.2.38"
resolved "https://registry.yarnpkg.com/tina-graphql-gateway-cli/-/tina-graphql-gateway-cli-0.2.38.tgz#5e15c8f63ca3e71e5c0c182c6b204c3d72fe4514"
integrity sha512-k/Kf5ycXfRvyfjWwRLOHbdRCsQi8pncvk1gBiaBanE0NYhG5yIkjnrENI/5x4JUaDNiJbynZvnsjOpk0C9XzGQ==
dependencies:
"@forestryio/gql" "0.1.2"
"@forestryio/graphql-helpers" "0.0.19"
"@forestryio/gql" "0.1.3"
"@forestryio/graphql-helpers" "0.0.20"
"@graphql-codegen/core" "^1.17.0"
"@graphql-codegen/typescript" "^1.17.0"
"@graphql-codegen/typescript-operations" "^1.17.0"
Expand Down Expand Up @@ -11892,12 +11885,12 @@ tina-graphql-gateway-cli@0.2.37:
yo "^3.1.1"
yup "^0.32.9"

tina-graphql-gateway@0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/tina-graphql-gateway/-/tina-graphql-gateway-0.2.4.tgz#80ed80645c4088f00d711505c6974091826a0b80"
integrity sha512-x5xReKctWsleP/TLBJnZkNwiNXthgDiIpu0f0ib25BTs1IqpZNSrQ7TJE0Ohq4evJAe+JMhbkxVvcXxVQkWhtA==
tina-graphql-gateway@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/tina-graphql-gateway/-/tina-graphql-gateway-0.2.5.tgz#94f5b6444a2e82ddde3a280fdabd25f41e73a139"
integrity sha512-rGkxTGzSjZdO5RuRt9qmt3vVzotmoo8Ua6KIoy0itDfshG3pOsa24sj9qF472LPsSW9jtGPqSF1051YIK5kcMQ==
dependencies:
"@forestryio/graphql-helpers" "0.0.19"
"@forestryio/graphql-helpers" "0.0.20"
"@graphql-codegen/core" "^1.15.4"
"@graphql-codegen/typescript" "^1.15.4"
"@graphql-codegen/typescript-operations" "^1.15.4"
Expand Down