Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 104 additions & 53 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'
import {
ComputedFields,
defineDocumentType,
defineNestedType,
FieldDefs,
makeSource,
} from 'contentlayer2/source-files'
import { extractTocHeadings } from './src/mdx/remark-toc-headings.mjs'
import path from 'path'
import fs from 'fs'
Expand All @@ -7,87 +13,132 @@ const contentDirPath = 'docs'

const branch = process.env.NEXT_PUBLIC_GITHUB_BRANCH || 'main'

const baseFields: FieldDefs = {
title_seo: {
type: 'string',
description:
'The meta title of the doc, this will override the title extracted from the markdown and the nav title',
},
description: {
type: 'string',
description: 'The description of the doc',
},
image: {
type: 'string',
description: 'The image of the doc',
},
image_alt: {
type: 'string',
description: 'The image alt of the doc',
},
disable_edit: {
type: 'boolean',
description: 'Disable the github edit button',
},
}

const computedFields: ComputedFields = {
slug: {
type: 'string',
resolve: (doc) => doc._raw.flattenedPath,
},
toc: { type: 'json', resolve: (doc) => extractTocHeadings(doc.body.raw) },
title: {
type: 'string',
resolve: async (doc) => {
const headings = await extractTocHeadings(doc.body.raw, [1])

return headings[0]?.value
},
},
editUrl: {
type: 'string',
resolve: (doc) =>
`https://github.com/nitrictech/docs/edit/${branch}/docs/${doc._raw.sourceFilePath}`,
},
lastModified: {
type: 'date',
resolve: (doc) => {
// Get the full path to the markdown file
const filePath = path.join(
process.cwd(),
contentDirPath,
doc._raw.sourceFilePath,
)
// Extract and return the last modified date
const stats = fs.statSync(filePath)
return stats.mtime // This is the last modified date
},
},
}

const Doc = defineDocumentType(() => ({
name: 'Doc',
filePathPattern: '**/*.mdx',
filePathPattern: '!**/guides/**/*.mdx',
fields: baseFields,
computedFields,
}))

const Featured = defineNestedType(() => ({
name: 'Featured',
fields: {
title_seo: {
image: {
type: 'string',
description:
'The meta title of the doc, this will override the title extracted from the markdown and the nav title',
'The featured image of the post, not the same as og image. Use 1024x1024 with transparent background.',
required: true,
},
description: {
image_alt: {
type: 'string',
description: 'The description of the doc',
description: 'The featured image alt of the post',
required: true,
},
image: {
type: 'string',
description: 'The image of the doc',
},
}))

const Guide = defineDocumentType(() => ({
name: 'Guide',
filePathPattern: '**/guides/**/*.mdx',
fields: {
...baseFields,
published_at: {
type: 'date',
description: 'The date the guide was published',
required: true,
},
image_alt: {
type: 'string',
description: 'The image alt of the doc',
updated_at: {
type: 'date',
description:
'The date the guide was last updated, will be set to published_at if not set',
},
disable_edit: {
type: 'boolean',
description: 'Disable the github edit button',
featured: {
type: 'nested',
of: Featured,
},
tags: {
type: 'list',
of: {
type: 'string',
},
description: 'The tags of the post, used by guides',
description: 'The tags of the post',
required: true,
},
languages: {
type: 'list',
of: {
type: 'string',
},
description: 'The languages of the content, used by guides',
description: 'The languages of the content',
},
start_steps: {
type: 'markdown',
description: 'The start steps of the doc, used by guides',
},
},
computedFields: {
slug: {
type: 'string',
resolve: (doc) => doc._raw.flattenedPath,
},
toc: { type: 'json', resolve: (doc) => extractTocHeadings(doc.body.raw) },
title: {
type: 'string',
resolve: async (doc) => {
const headings = await extractTocHeadings(doc.body.raw, [1])

return headings[0]?.value
},
},
editUrl: {
type: 'string',
resolve: (doc) =>
`https://github.com/nitrictech/docs/edit/${branch}/docs/${doc._raw.sourceFilePath}`,
},
lastModified: {
type: 'date',
resolve: (doc) => {
// Get the full path to the markdown file
const filePath = path.join(
process.cwd(),
contentDirPath,
doc._raw.sourceFilePath,
)
// Extract and return the last modified date
const stats = fs.statSync(filePath)
return stats.mtime // This is the last modified date
},
description: 'The start steps of the doc',
},
},
computedFields,
}))

export default makeSource({
contentDirPath,
documentTypes: [Doc],
documentTypes: [Doc, Guide],
})
4 changes: 4 additions & 0 deletions docs/guides/dart/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ start_steps: |
cd examples/v1/flutter
flutter pub get
nitric start
featured:
image: /docs/images/guides/flutter/featured.png
image_alt: 'Building a Full Stack Flutter Application in Dart featured image'
published_at: 2024-10-30
---

# Building a Full Stack Flutter Application in Dart
Expand Down
1 change: 1 addition & 0 deletions docs/guides/dart/serverless-rest-api-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
- Key Value Store
languages:
- dart
published_at: 2024-04-24
---

# Building a REST API with Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/deploying/azure-pipelines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ description: Deploy to AWS, Google Cloud or Microsoft Azure using Azure DevOps a
tags:
- CI/CD
- Azure
published_at: 2023-11-01
updated_at: 2024-02-04
---

# Deployment Automation with Azure Pipelines and Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/deploying/github-actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
description: Deploy to AWS, Google Cloud or Microsoft Azure using GitHub Actions and the Nitric CLI
tags:
- CI/CD
published_at: 2023-12-21
updated_at: 2024-08-20
---

# Deployment Automation with GitHub Actions and Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/deploying/gitlab-ci.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
description: Deploy to AWS, Google Cloud or Microsoft Azure using GitLab CI and the Nitric CLI
tags:
- CI/CD
published_at: 2023-11-01
updated_at: 2024-08-20
---

# Deployment Automation with GitLab CI and Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/deploying/google-cloud-build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ description: Deploy to AWS, Google Cloud or Microsoft Azure using Google Cloud B
tags:
- CI/CD
- Google
published_at: 2023-11-01
updated_at: 2024-08-20
---

# Deployment Automation with Google Cloud Build and Nitric
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/go/realtime-messaging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ start_steps: |
cd examples/v1/websocket-app
go mod tidy
nitric start
featured:
image: /docs/images/guides/realtime-messaging/featured.png
image_alt: 'Building a chat app in Go with WebSockets and Nitric featured image'
published_at: 2024-10-16
---

# Building a chat app in Go with WebSockets and Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/go/serverless-rest-api-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
- Key Value Store
languages:
- go
published_at: 2023-08-11
updated_at: 2024-10-03
---

# Building your first API with Nitric
Expand Down
1 change: 1 addition & 0 deletions docs/guides/jvm/serverless-rest-api-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Use the Nitric framework to easily build and deploy JVM REST APIs f
tags:
- API
- Key Value Store
published_at: 2023-10-12
---

<Note>
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/amazon-cognito.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-10-09
updated_at: 2024-05-15
---

# Securing APIs with Amazon Cognito
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/api-with-nextjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-08-28
updated_at: 2024-10-11
---

# Next.js and Nitric example application
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/byo-database.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2022-10-13
updated_at: 2024-06-14
---

# BYO Database
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/debugging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-06-16
updated_at: 2023-08-22
---

# Debugging with Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/expressjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-07-10
updated_at: 2024-03-18
---

# Enhance Express.js Apps with Cloud Resources
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/fastify.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-07-12
updated_at: 2024-03-18
---

# Add Cloud Resources to Fastify Apps
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/graphql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2022-11-17
updated_at: 2024-03-18
---

# Building a GraphQL API with Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/nestjs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2023-07-05
updated_at: 2024-05-15
---

# Nest.js integration with Nitric
Expand Down
1 change: 1 addition & 0 deletions docs/guides/nodejs/nitric-and-drizzle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
languages:
- typescript
- javascript
published_at: 2024-06-14
---

# Nitric SQL Databases with Drizzle
Expand Down
1 change: 1 addition & 0 deletions docs/guides/nodejs/nitric-and-prisma.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tags:
languages:
- typescript
- javascript
published_at: 2024-06-14
---

# Nitric SQL Databases with Prisma
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/nitric-and-supabase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2022-03-26
updated_at: 2024-02-20
---

# Extend Supabase Apps with Nitric
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/nodejs/secure-api-auth0.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2022-05-23
updated_at: 2024-10-11
---

# Securing your API with Auth0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ tags:
languages:
- typescript
- javascript
published_at: 2022-03-28
updated_at: 2024-03-18
---

# APIs with PlanetScale, Prisma and Nitric
Expand Down
Loading
Loading