nuxt-modules / prismic

Easily connect your Nuxt.js application to your content hosted on Prismic

Home Page:https://prismic.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slice for meta data

cbommart opened this issue · comments

Hello,

Thank for your work.
I have a question for you. I was trying to create a slice to manage meta data to use in Custom Type content. The slice does not render anything so I managed to create a slice ./slices/MetaData/index.vue with only a <script> and with a render() { return undefined; }. The file content :

<script>
export default {
  props: {
    slice: {
      type: Object,
      required: true,
      default() {
        return {};
      },
    },
  },
  head() {
    return {
      // Primary Meta Tags
      title: this.metaTitle,
      meta: [
        {
          hid: 'description',
          name: 'description',
          content: this.metaDescription,
        },
        // ...
    };
  },
  computed: {
    metaTitle() {
      return this.slice.primary.metaTitle;
    },
    metaDescription() {
      return this.slice.primary.metaDescription;
    },
    // ...
  },
  render() {
    return undefined;
  },
};
</script>

Is there any "proper" way to do this ? Or is it planed to be able to create a "functional" slice without render, without storybook ?

commented

Hey @cedricbommart, really interesting use-case you have here and that's definitely something we want to move towards! Right now Slice Machine is dependant on Storybook so doing that without a story, even empty, linked to it sounds complicated. Maybe we should think about functional slices indeed?

cc @hypervillain, @Duaner

commented

Hey, gently closing this question, it's something we're taking into account when working on the future of Slice Machine 🚀