question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: Setup your slicemachine project with your custom library

See original GitHub issue

Context

When using the command prismic sm --setup the slice machine CLI will generate a new prismic repository and import in your project a set of default Open Source components.

For nuxt.js : https://github.com/prismicio/vue-essential-slices For next.js : https://github.com/prismicio/essential-slices

We had different request to be able to specify your own custom library instead of the default one

Solution

We will create a new argument for the prismic sm --setup command allowing you to specify your own custom library. (This should be a npm package)

prismic sm --setup --lib my-npm-package

This command will

Generate a new repository and configure your project to be linked to your newly created repository

As the current setup command, the command will create a new repository The CLI command will generate a new prismic repository & add the different files in your codebase to link your project to your prismic endpoint & setup the toolbar

Download your custom library as a dependency

  1. Add & download the dependency in your project
  2. Reference your library in the sm-resolver to use those slices automatically in the Slicezone.

Import your custom slices in your first created custom type.

  1. Generate a new prismic repository
  2. Create a page custom type
  3. Add all slices definition to your page custom type.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
ReeceMcommented, Jun 13, 2021

It would be nice not to have the essential slices installed by default, I don’t think it would have a steep learning curve. I find myself removing the essential-slice libraries as I don’t use them. (May be digging up an old thing here?)

All a new person would see is the magic that it opens up a page possibly and has some slices, unfortunately, it does push it all by default to the Prismic repository created and sometimes that isn’t wanted on say a new or old project. Because now I would need to go and clean those out.

If maybe setting up a template or new project, the tutorials or documentation can mention the use of the essential slices, and the code snippets have the flags there as Alex mentions.

Or during the starting process on setups with the CLI, the person could be presented with the option of one with the libs or without. But adding a description of what they are best for: (Best for first time SM users) and so forth.

(Personally if there is a guided option or flag to opt-in to the essential libraries and some docs on updating the themes that would be great as that would make it possible for first time users to start a page, build and configure. Then if they have the confidence, they can just skip that and start a new fresh on without it to see.)

1reaction
davidparyscommented, Feb 26, 2021

It’ll be cool to also have a --no-lib flag like the --no-prismic one also to just setup the project for using a yet-to-be-coded local library 🙂, so we’ll have:

$ prismic sm --setup                # install essential-slices
$ prismic sm --setup --library      # install said library instead of essential-slices
$ prismic sm --setup --no-library   # install no library

What’s the current behavior of this flag then? (I know we talked about it already but I’m still not sure regarding it) https://www.slicemachine.dev/documentation/the-prismic-cli#specify-library is it just that the models aren’t push to Prismic currently with it?

This could be super useful. I have some projects that don’t require the essential slices.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setup repo with your custom library, Next.js Documentation ...
This command will: Generate a new repository and configure your project to be linked to your newly created repository; Download your custom ......
Read more >
Creating a Project With Slice Machine & Next.js - YouTube
Today Alex is presenting how to set up Slice Machine with Next.js in order to start developing slices - website sections - with...
Read more >
Step-by-step guide on how to create your first slices with Slice ...
Step-by-step guide on how to create your first slices with Slice Machine for the #SliceContestMore info about the SliceContest: ...
Read more >
Prismic & Slice Machine - Crash Course - YouTube
Try Slice Machine now : https:// slicemachine.dev—▻ [Tutorial] Build a Next.js website, while delivering a page builder to your team: ...
Read more >
next-slicezone - npm
Start using next-slicezone in your project by running `npm i next-slicezone`. ... RFC: https://github.com/prismicio/slice-machine/issues/7 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found