- Published on
 
Add Workflow Field to Blog DocType
- Authors
 
- Name
 - MDolce
 
Table of Contents
Problems we need to solve:
Planning for future project tracking, we need to add a workflow number to the blog document type. The naming convention for workflows is:
clientID-jobnumber#-YYYYMMDDTIMESTAMP-jobTypeTitle
Also, because of this error message:
`Warning: Found 3 problems in 3 documents.
 └──   3 documents contain field data which isn't defined in the document type definition.
     • "01-projects/issue-01-20241181040-01-fix-child-key-prop-warning.mdx" of type "Blog" has the following extra fields:
       • workflow: "202401171630-add-workflow-field-to-blog-doc-type"
     • "01-projects/project-01-20241181040-01-changing-articles-to-projects.mdx" of type "Blog" has the following extra fields:
       • workflow: "202401171630-changing-articles-path"
     • "01-projects/project-02-20241181040-01-add-workflowNum-field-DocType.mdx" of type "Blog" has the following extra fields:
       • workflow: "202401171630-add-workflow-field-to-blog-doc-type" `
Assumptions:
- Add a workflow number to the blog document type in contentlayer.config.js
 - Add to blog 
computed fieldssection - Create a default 
MDXtemplate to ensureFront-Mattercontinuity - Consider creating a Document Type called Workflow 
Field Type 
Solution:
- Add a workflow 
fieldto the blog document type in contentlayer.config.js - Add to workflow to the blog 
computed fieldssection as well 
// Added to blog documentType
   workflow: {type: 'string', required: true},
// Added to Blog computed Fields
   workflow: doc.workflow,
Reference
A path to another document file of a specific types. The path should be relative to the contentDirPath option passed to makeSource
. References are not currently transformed or embedded. They are simply passed through as strings.
Options:
default (string): A default value for the field if it is empty.
of (DocumentType): A document type definition.
Example:
const Category = defineNestedType(() => ({
  name: 'Category',
  filePathPattern: 'categories/*.md',
  fields: {
    title: { type: 'string', required: true },
  },
}))
defineDocumentType(() => ({
  // ...
  fields: {
    category: {
      type: 'reference',
      of: Category,
    },
  },
}))
Your content file would then point the referenced doc, using a path relative to the contentDirPath option passed to makeSource.
---
category: categories/hello-world.md
---
This is presented as is in the output document at this time.
{
  "category": "categories/hello-world.md"
}
REF(s): Contentlayer
May consider this a future case study on understanding how to add reference categories to ContentLayer configuration. Need to understand the context of adding a reference document type and