Skip to content

Extendable nuxi add with custom templates from modules #56

Closed as duplicate

Description

@ramsesgarate

Describe the feature

(edited by @pi0) Original title: nuxi add content <name>

I am currently creating my website with nuxt content and realized that nuxi does not have a template for content (content pages).

I've been reviewing the code a bit and I would like to contribute with this.

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Activity

  1. ramsesgarate commented on Oct 13, 2022

    @ramsesgarate
    Author

    What does the tag discussion mean? @danielroe

    Greetings

  2. changed the title [-]nuxi add content <name>[/-] [+]Extendable `nuxi add` with custom templates from mudoules[/+] on Oct 14, 2022
  3. pi0 commented on Oct 14, 2022

    @pi0
    Member

    Hi dear @ramsesgarate. I think that's a nice idea and can think of several ways to make it possible from modules injecting their templates. Dicussion tag means we are open to discuss about it and find possible solutions.

  4. changed the title [-]Extendable `nuxi add` with custom templates from mudoules[/-] [+]Extendable `nuxi add` with custom templates from modules[/+] on Oct 14, 2022
  5. ramsesgarate commented on Oct 14, 2022

    @ramsesgarate
    Author

    I understand, I think I got too complicated saying templates haha the truth is I had thought of something a little simpler, based on how it currently works creating pages with nuxi add, for content I would return something like

    return {
        path: `content/${name}.md`,
        contents: `
    # ${name} content v2
    
    [Back home](/)
    `
      }

    This would also be useful if you want to create a page with order prefixes like nuxi add content 1.about, ignore nuxi add content .1.about or partiarls nuxi add content _1.about.

  6. transferred this issue fromnuxt/frameworkon Jan 19, 2023
  7. manchenkoff commented on May 13, 2023

    @manchenkoff

    It would be really nice to have some section like templates in the nuxt.config.ts which expects an array of interfaces from the source code

    interface Template {
      (options: TemplateOptions): { path: string, contents: string }
    }

    then we can load it either from a layer or module, etc.

    Should we expect this feature in one of the subsequent releases? 🤔

  8. transferred this issue fromnuxt/nuxton Jul 6, 2023
  9. OrbisK commented on Jun 18, 2025

    @OrbisK
    Member

    I think this now part of nuxt kit: https://nuxt.com/docs/api/kit/templates

  10. manchenkoff commented on Jun 18, 2025

    @manchenkoff

    I think this now part of nuxt kit: https://nuxt.com/docs/api/kit/templates

    @OrbisK I don't think it is:

    Templates allows to generate extra files during development and build time.
    

    But the initial feature request was to extend Nuxi CLI functionality to generate files from custom templates and not for build time.

    For example, if I want to define a custom version of a composable or plugin with predefined functionality, there is no way to leverage those Kit templates.

    Right now, those templates are hardcoded here - https://github.com/nuxt/cli/blob/main/packages/nuxi/src/utils/templates/index.ts#L29 and later used in add command - https://github.com/nuxt/cli/blob/main/packages/nuxi/src/commands/add.ts#L71

  11. reopened this on Jun 18, 2025
  12. OrbisK commented on Jun 18, 2025

    @OrbisK
    Member

    Yeah, you are right. I misread the topic 👍🏽

  13. manchenkoff commented on Jun 11, 2026

    @manchenkoff

    Hey team! I raised two draft PRs with an example of the implementation for custom templates support, please take a look and let me know if that makes sense to go further 🙏

    cc @danielroe (tagging you since you were auto-assigned to PRs)

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions