GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Provide a resolve key on fields to generate a default value when one is not provided · Issue #275 · contentlayerdev/contentlayer

Provide a resolve key on fields to generate a default value when one is not provided #275

New issue
Copy link
New issue
Copy link
Open
Open
Provide a resolve key on fields to generate a default value when one is not provided#275
Copy link
Labels
featureNew feature or requestNew feature or requestmeta: never-stalepkg/source-files
Milestone
Pre-1.0

Description

@ispringle
ispringle
opened on Jul 27, 2022
Issue body actions

My idea is to add a resolve key to the fields, so that when a value is not provided for that field the resolve function will fire, which then creates a default value for the field instead.

So for example I might have the following:

  fields: {
    title: {
      type: 'string',
      description: 'The title of the post',
      required: true,
    },
    url: {
      type: 'string',
      description: 'The URL of the post',
      required: false,
      resolve: (doc: any) => `/${doc._raw.flattenedPath}`,
  },
...

With this I can provide a URL value in the frontmatter of the markdown file if I am interested in providing a very specific URL for something, but otherwise it will generate the field automatically.

Activity

  1. schickling
    added
    featureNew feature or requestNew feature or request
    pkg/source-files
    on Aug 1, 2022
  2. schickling
    added this to the Pre-1.0 milestone on Aug 1, 2022
  3. schickling commented on Aug 1, 2022

    @schickling
    schickling
    on Aug 1, 2022
    Collaborator
    More actions

    Thanks a lot for suggesting this feature/improvement. I agree it's a useful idea. I'll try to incorporate this suggestion in the coming releases.

  4. schickling
    added
    meta: never-stale
    on Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestNew feature or requestmeta: never-stalepkg/source-files

    Type

    No type

    Projects

    No projects

      Milestone

      • Pre-1.0No due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.