From d0788d1b075f7519160e1bd440eb5bd248313b77 Mon Sep 17 00:00:00 2001 From: Nilu Date: Wed, 25 Mar 2020 16:01:08 +0100 Subject: [PATCH 1/6] Remove numbers from urls --- content/02-understand-prisma/01-introduction.mdx | 9 ++++----- .../02-understand-prisma/06-prisma-under-the-hood.mdx | 6 +++--- gatsby-node.js | 3 ++- src/components/sidebar/treeNode.tsx | 6 +++++- src/components/toc.tsx | 5 +++-- src/utils/urlGenerator.ts | 3 +++ 6 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/utils/urlGenerator.ts diff --git a/content/02-understand-prisma/01-introduction.mdx b/content/02-understand-prisma/01-introduction.mdx index 1b2935d6ec..c3c32dab8d 100644 --- a/content/02-understand-prisma/01-introduction.mdx +++ b/content/02-understand-prisma/01-introduction.mdx @@ -14,18 +14,17 @@ Prisma is an [open source]() database toolkit. It mainly consists of the followi - **Prisma Client**: An auto-generated and type-safe query builder for Node.js and TypeScript. - **Prisma Migrate** (experimental): A declarative schema migration system. -- **Prisma Studio** (experimental): A GUI to view and edit data in your database. +- **Prisma Studio** (experimental): A GUI to view and edit data in your database. Prisma Client can be used in _any_ Node.js or TypeScript application. This can be a [REST API](), a [GraphQL API]() a gRPC API or anything else that needs a database. - Every project that uses Prisma is further based on a [Prisma schema file]() which contains your database connection, client generators and a representation of your database schema as a delarative Prisma [data model](). ## Why Working with relational databases is a major bottleneck in application development. Debugging SQL queries or complex ORM objects often consume hours of development time. -Prisma makes it easy for developers to reason about their database queries by providing a clean and type-safe API for submitting database queries which returns _plain old JavaScript objects_. +Prisma makes it easy for developers to reason about their database queries by providing a clean and type-safe API for submitting database queries which returns _plain old JavaScript objects_. ### Problems with SQL, ORMs and other database tools @@ -59,7 +58,7 @@ This is way more convenient and comes closer to the mental model developers have As an application developer, the mental model you have for your data is that of an _object_. The mental model for data in SQL on the other hand are _tables_. -The divide between these two different representations of data is often referred to as the [object-relational impedance mismatch](). The object-relational impedance mismatch also is a major reason why many developers don't like working with traditional ORMs. +The divide between these two different representations of data is often referred to as the [object-relational impedance mismatch](). The object-relational impedance mismatch also is a major reason why many developers don't like working with traditional ORMs. As an example, consider how data is organized and relationships are handled with each apprach: @@ -124,4 +123,4 @@ With Prisma Migrate, the workflow looks slightly different: ![](https://imgur.com/sovxPh9.png) -To dive deeper, please refer to the respective docs page. \ No newline at end of file +To dive deeper, please refer to the respective docs page. diff --git a/content/02-understand-prisma/06-prisma-under-the-hood.mdx b/content/02-understand-prisma/06-prisma-under-the-hood.mdx index df11ef7513..aebbe71866 100644 --- a/content/02-understand-prisma/06-prisma-under-the-hood.mdx +++ b/content/02-understand-prisma/06-prisma-under-the-hood.mdx @@ -10,7 +10,7 @@ This page gives an overview of the Prisma internals and how it works "under the Note that **this page does not contain any practical information that is relevant for _using_ Prisma**. It rather aims at providing a _mental model_ for what the Prisma toolkit _actually_ is and how the different tools that are available to developers are structured. -If you're new to Prisma, be sure to check out the [Quickstart]() and [Intrododuction]() pages first. +If you're new to Prisma, be sure to check out the [Quickstart]() and [Intrododuction]() pages first. ## Modules and interfaces @@ -44,10 +44,10 @@ _Interfaces_ offer a way to actually _use_ the functionality of a module. The mo ## Prisma engines -At the core of each module, there typically is a [Prisma engine](https://github.com/prisma/prisma-engines) that implements the core set of functionality. Engines are implemented in [Rust](https://www.rust-lang.org/) and expose a low-level API that is used by the higher-level interfaces. +At the core of each module, there typically is a [Prisma engine](https://github.com/prisma/prisma-engines) that implements the core set of functionality. Engines are implemented in [Rust](https://www.rust-lang.org/) and expose a low-level API that is used by the higher-level interfaces. A Prisma engine is the **direct interface to the database**, any higher-level interfaces always communicate with the database _through_ the engine-layer. As an example, Prisma Client connects to the [query engine]() in order to read and write data in a database: -![](https://i.imgur.com/Nwwx5Cv.png) \ No newline at end of file +![](https://i.imgur.com/Nwwx5Cv.png) diff --git a/gatsby-node.js b/gatsby-node.js index dbdf63c33c..df60d1997d 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,4 +1,5 @@ const path = require(`path`); +// const urlGenerator = require(`./src/utils/urlGenerator`) // const { createFilePath } = require(`gatsby-source-filesystem`); exports.onCreateNode = ({ node, getNode, actions }) => { @@ -67,7 +68,7 @@ exports.createPages = ({ graphql, actions }) => { `).then(result => { result.data.allMdx.edges.forEach(({ node }) => { createPage({ - path: node.fields.slug ? node.fields.slug : '/', + path: node.fields.slug ? node.fields.slug.replace(/\d+-/g, "") : '/', component: path.resolve(`./src/layouts/articleLayout.tsx`), context: { id: node.fields.id, diff --git a/src/components/sidebar/treeNode.tsx b/src/components/sidebar/treeNode.tsx index 1b18826dbf..ebb5fbff01 100644 --- a/src/components/sidebar/treeNode.tsx +++ b/src/components/sidebar/treeNode.tsx @@ -3,6 +3,7 @@ import styled from 'styled-components'; import ArrowRight from '../../icons/ArrowRight'; import ArrowDown from '../../icons/ArrowDown'; import Link from '../link'; +import { urlGenerator } from '../../utils/urlGenerator'; const List = styled.ul` list-style: none; @@ -133,7 +134,10 @@ const TreeNode = ({ return ( {title && label !== 'index' && ( - + {hasExpandButton ? (