For miniPress plugins and themes are the same thing. There is virtually no difference between a theme and a plugin. However, the term plugin is more technical than the term theme. Everyone knows what a theme does: It changes the look and feel of your site. When I say “hey look at this cool plugin I made” you don’t know a thing about what to expect.
That is why within this documentation we still differentiate between plugins and themes – but only for educational purposes.
From a technical point of view plugins and themes are identical.
Usage
You create a post by adding a markdown file inside your posts-directory. A post is a almost normal markdown page.
WARNING
Make sure that your posts have a frontmatter title-attribute.
Here is a hello world-post:
---title: Hello World
---
Hello Blog!
<!-- more -->
I am the **actual** content of the post.
Using the `more`-comment is optional.
The blog-plugin will add a posts-attribute to $minipress.site. You can use this attribute to create a list of your posts.
Options
@minipress/plugin-blog can be configured in case the defaults don’t work for you.
posts – default: $cwd/posts: Absolute path to a directory which contains your posts.
path – default: /blog/: Path (with trailing and leading /) under which your blog will be available. A value of /blog/ means that miniPress expects your blog posts to be available at https://your-host.tld/$build.base/blog/$post.
comparePosts: A function which compares two posts. This is used to sort your posts. The default comparePosts-function orderes your posts by date.
@minipress/plugin-excerpt extracts excerpts and makes them available as components that can be rendered everywhere.
TIP
@minipress/plugin-excerpt is usually only used indirectly because it is already preconfiguered once you are using @minipress/plugin-blog. In case you are curious or just want to use @minipress/plugin-excerpt directly read ahead.
Usage
With the excerpt-pluing installed you can now create excerpts like this:
# My Page
I am part of the excerpt.
<!-- more -->
The main content goes here.
# My Page
I am part of the excerpt.
<!-- more -->
The main content goes here.
Everything before <!-- more --> is considered part of the excerpt and everything after <!-- more --> is considered to be part of the main content.
The excerpt-pluing makes the excerpt available on the page-object. You can access the excerpt of the current page with
{{ $minipress.page.excerpt }}.
WARNING
Using {{ $minipress.page.excerpt }} on a page will output the rendered excerpt as text. If you want to display the rendered excerpt you should use the Excerpt-component.
The Excerpt-Component
You can display the rendered excerpt of any page by using the Excerpt-component. This component is automatically installed by the excerpt-pluing. By default, Excerpt will render the excerpt of the current page. You can use the ofPageWithKey-prop to render the excerpt of any page:
Rendered excerpt of page with *key*`plugins--excerpt-sample`:
<ExcerptofPageWithKey="plugins--excerpt-sample"/>
Show Rendered Excerpt
I am part of the excerpt.
You can use any feature in excerpts bold text, underlined text and custom containers:
Then you can access your package.json-file like this:
## My Package Name
Last Modified: {{ $minipress.site.pkg.name }}
$minipress.site.pkg gives you access to your whole package.json-file. By default @minipress/plugin-package-json will use the package.json that is located in cwd. You can override that by passing an absolute path as the second argument of use(…).
You define a custom container by specifying four things:
type: The type is basically just what you will end up writing in your markdown files in order to create a container. For example: If you set type to tip then
::: tip
:::
will create an empty tip-container.
defaultTitle: A container can have a title. Everything that comes after ::: type (in the same line) is the title of your container. In case no title is specified you can render a default title which is what you can specify with defaultTitle.
renderBefore: A function that should return a string that will be rendered before the actual container-content. You have access to the current title that is used.
renderAfter: A function that should return a string that will be rendered after the actual container-content.
The @minipress/plugin-component-documentation package allows you to easily render documentation for almost any of your custom Vue components. It does that by parsing your *.vue-files. Under the hood this plugin uses Vuese to do that.
It will be rendered right above the actual component documentation
but still inside the documentation-element (so that you can target
it with CSS selectors if you want).
:::
::: component-documentation-for NameOfAnyGlobalComponent
You can add text here if you want.
It will be rendered right above the actual component documentation
but still inside the documentation-element (so that you can target
it with CSS selectors if you want).
:::
This is a description of the component. If you are using the default renderer (minipress-markdown) you can use multiline strings and even markdown almost everywhere. For example you can show usage examples of your component right here:
This is a description of the component. If you are using the default renderer (minipress-markdown) you can use multiline strings and even markdown almost everywhere. For example you can show usage examples of your component right here:
By default the renderer used is called minipress-markdown. There are a couple of differences between vuese-markdown and minipress-markdown:
minipress-markdown supports markdown: You can use any markdown feature inside your (multiline) comments.
minipress-markdown is styleable: The miniPress renderer adds additional CSS classes to whatever it renders so that you can target the rendered output with your custom styles.
minipress-markdown does not use h-tags: The miniPress also does not use any <h>-tags (e.g.: <h1>, …). This can be good or bad. It is bad because then your documentation does not show up in the table of contents. The advantage is that it also does not mess with your table of contents.
You can use @minipress/plugin-summary-container to render a nice summary + details element. You can use it for many things like displaying code samples or to embed advanced information that should be not shown by default. This is how a summary container can look like:
This is a summary. Click me! 😉
Congratulations! 🥳 You made it. This is what is referred to as the details of the summary container. You can add have any content here. You can use any markdown feature. You can also display code samples here:
const x ='hello world'
console.log(x)
Isn’t that sweet?
You can create a summary container like this:
::: summary This is a summary. Click me! 😉
Congratulations! 🥳 Your actual content **goes** here.
:::
@minipress/plugin-deploy-to-gh-pages adds a new command to the CLI. The command is called deploy-to-gh-pages. In order to deploy your site to GitHub Pages, just execute this command.
@minipress/plugin-deploy-to-gh-pages can be configured in case the defaults don’t work for you.
skipGenerate – default: false: By default @minipress/plugin-deploy-to-gh-pages will generate a static build of your site and then deploy it. If you want to skip the generation process set skipGenerate to true.
ghpagesOptions: Under the hood @minipress/plugin-deploy-to-gh-pages uses the gh-pages-package to do the heavy lifting. gh-pages can be configured by setting certain options. Whatever you specify in ghpagesOptions will be passed as is to gh-pages.
The @minipress/plugin-component-demo-plugin allows you to render live demos of your components. This plugin also makes it easy to display the code for your demos.
A demo is a *.vue-file which demos one of your components. By default every *.vue-file inside cwd/demos will be made available as a demo automatically.
A plugin is a normal NPM package. Its entry point (main-file) should export an object with an apply-function. The apply-function will be called by miniPress early on:
options: The plugin options passed to the plugin by the consumer. This can be undefined in case no options have been specified. There is no fallback to {}.
It is the duty of the plugin developer to do the right thing inside apply. You may use any public method on the minipress-instance in case you have special needs. The minipress-instance opens the door to a very poweful meachnism: hooks.
You can use hooks to hook into almost every aspect of miniPress. Hooks are called by miniPress – you only have to register for all the hooks you want and wait to be called. Just like at the doctors office. Sit still. Don’t say a word.
Called during the render process (see src/vue-renderer for details). This is called multiple times – at least once for each page. Every time a page is rendered – at some point we need to create the <head>-element. This hook allows you to modify the head of each page.
An app enhancer is similar to a dynamic module. The difference is that app enhancers are automatically imported and called by miniPress very early on. This allows you to access the Vue-constructor or do other things I can’t think of right now.
This property returns the @hapi/joi default export. Joi is exposed on the miniPress-instance for convenience purposes only. You can use it to create new schemas.