https://github.com/mr-destructive/frontmatter.vim
Generate Frontmatter in a markdown file by just the name of the SSG
https://github.com/mr-destructive/frontmatter.vim
Last synced: 10 months ago
JSON representation
Generate Frontmatter in a markdown file by just the name of the SSG
- Host: GitHub
- URL: https://github.com/mr-destructive/frontmatter.vim
- Owner: Mr-Destructive
- Created: 2022-01-31T10:19:12.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-07-08T16:36:41.000Z (almost 4 years ago)
- Last Synced: 2025-03-24T15:26:09.306Z (about 1 year ago)
- Language: Lua
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Front-matter.vim
A simple plugin for writing the front-matter for a given SSG generator name.
1. Add the [frontmatter plugin](https://github.com/Mr-Destructive/frontmatter.vim) to your preferred plugin manager's plugins list.
2. Add a key-map that maps to `call Frontmatter()`.
3. Write the SSG(static site generator) name for example `jekyll`.
4. Visually select it and press escape.
5. Press that key map and at the top, the front-matter will be generated with a few keys.
### Example:

#### Vimscript
```vimscript
nnoremap fm :call Frontmatter()
```
#### Lua
```lua
vim.keymap.set("n", "fm", "lua require('frontmatter').Frontmatter()")
```
### Features:
- Supports SSGs like
- jekyll
- Markata
- Hugo
- Hexo
- Gatsby
- Automatically sets current date.
### Customization
The `Frontmatter` function can take in two parameters -> (`type_of_customization`, `{list of frontmatter}` )
1. Type of Customization -> `add` or `list`
2. List of Frontmatter -> A Lua table of strings representing the frontamtter keys
Add a custom keymap in your vimrc, init.vim or init.lua file.
- Add to an already existing frontmatter
- Vim
```vimscript
nnoremap fm :lua require('frontmatter').Frontmatter("add", {'series', 'image_url'})
```
- Lua
```lua
vim.keymap.set('n', 'fm', "lua require('frontmatter').Frontmatter('add',{'series', 'image_url'})")
```
- Create a new set of frontmatter
- Vim
```vimscript
nnoremap fm :lua require('frontmatter').Frontmatter("list", {'layout', 'status', 'series', 'series_description', 'image_url'})
```
- Lua
```lua
vim.keymap.set('n', 'fm', "lua require('frontmatter').Frontmatter('list',{'layout', 'status', 'series', 'image_url'})")
```