import { source, stripIndent } from "common-tags"; import type { DocumentationReadHook } from "@slicemachine/plugin-kit"; import type { PluginOptions } from "../types"; export const documentationRead: DocumentationReadHook = async ( data, { options, helpers }, ) => { if (data.kind === "PageSnippet") { const { model } = data.data; const filePath = `${model.repeatable ? "_uid" : model.id}.vue`; let fileContent: string; if (model.repeatable) { fileContent = stripIndent` `; } else { fileContent = stripIndent` `; } if (options.format) { fileContent = await helpers.format( fileContent, helpers.joinPathFromRoot("index.vue"), { prettier: { parser: "vue" }, includeNewlineAtEnd: false, }, ); } return [ { label: "Options API", content: source` ## Create your ${model.label}'s page component Add a new route by creating an \`~/pages/${filePath}\` file. (If the route should be nested in a child directory, you can create the file in a directory, like \`~/pages/marketing/${filePath}\`.) Paste in this code: ${`~~~vue [~/pages/${filePath}]\n${fileContent}\n~~~`} Make sure all of your import paths are correct. See the [install guide](https://prismic.io/docs/nuxt-setup) for more information. `, }, ]; } return []; };