Skip to content
This repository was archived by the owner on Feb 25, 2021. It is now read-only.

Commit b264b0f

Browse files
authored
feat: add support for front matter markdown files
* test: add travis config * test: automate vue-cli template init on travis * chore: add nuxtent module * feat: load markdown files via nuxtdown module. Allow loading of markdown files with frontmatter format. * docs(readme): simplify readme * docs(readme): fix link to contribution guidelines * chore: bump version * chore: update node to v10.15.0 * chore: update Vue CLI dependency to v3 * docs(readme): add build status closes #2
1 parent 372add0 commit b264b0f

File tree

20 files changed

+4900
-1782
lines changed

20 files changed

+4900
-1782
lines changed

.gitignore

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,89 @@
11
node_modules/
2-
test/
2+
test/
3+
4+
# Common
5+
6+
7+
# Created by https://www.gitignore.io/api/linux,macos,windows,visualstudiocode
8+
# Edit at https://www.gitignore.io/?templates=linux,macos,windows,visualstudiocode
9+
10+
### Linux ###
11+
*~
12+
13+
# temporary files which can be created if a process still has a handle open of a deleted file
14+
.fuse_hidden*
15+
16+
# KDE directory preferences
17+
.directory
18+
19+
# Linux trash folder which might appear on any partition or disk
20+
.Trash-*
21+
22+
# .nfs files are created when an open file is removed but is still being accessed
23+
.nfs*
24+
25+
### macOS ###
26+
# General
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Icon must end with two \r
32+
Icon
33+
34+
# Thumbnails
35+
._*
36+
37+
# Files that might appear in the root of a volume
38+
.DocumentRevisions-V100
39+
.fseventsd
40+
.Spotlight-V100
41+
.TemporaryItems
42+
.Trashes
43+
.VolumeIcon.icns
44+
.com.apple.timemachine.donotpresent
45+
46+
# Directories potentially created on remote AFP share
47+
.AppleDB
48+
.AppleDesktop
49+
Network Trash Folder
50+
Temporary Items
51+
.apdisk
52+
53+
### VisualStudioCode ###
54+
.vscode/*
55+
!.vscode/settings.json
56+
!.vscode/tasks.json
57+
!.vscode/launch.json
58+
!.vscode/extensions.json
59+
60+
### VisualStudioCode Patch ###
61+
# Ignore all local history of files
62+
.history
63+
64+
### Windows ###
65+
# Windows thumbnail cache files
66+
Thumbs.db
67+
ehthumbs.db
68+
ehthumbs_vista.db
69+
70+
# Dump file
71+
*.stackdump
72+
73+
# Folder config file
74+
[Dd]esktop.ini
75+
76+
# Recycle Bin used on file shares
77+
$RECYCLE.BIN/
78+
79+
# Windows Installer files
80+
*.cab
81+
*.msi
82+
*.msix
83+
*.msm
84+
*.msp
85+
86+
# Windows shortcuts
87+
*.lnk
88+
89+
# End of https://www.gitignore.io/api/linux,macos,windows,visualstudiocode

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.*
1+
10.15.0

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
6+
## 1.0.0 - 2019-01-06
7+
8+
Initial stable release with frontmatter support.
9+

CONTRIBUTING.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Contribution
2+
3+
Contributions are more than welcome.
4+
5+
## Development
6+
7+
This section describes steps for direct contribution to this template.
8+
9+
1. Checkout git repository.
10+
2. Install dependencies.
11+
```sh
12+
$ npm install
13+
```
14+
3. Automatically install and build the template to a test folder.
15+
```sh
16+
$ npm run test
17+
```
18+
19+
Now, whenever you make changes to the source files in `template/`, you can directly test the installation
20+
and the build. It isn't possible to directly build the project inside `template/` due to variables
21+
that get replaced during the vue init steps.
22+
23+
## Commit Message Guidelines
24+
25+
### Commit Message Format
26+
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
27+
format that includes a **type**, a **scope** and a **subject**:
28+
29+
```
30+
<type>(<scope>): <subject>
31+
<BLANK LINE>
32+
<body>
33+
<BLANK LINE>
34+
<footer>
35+
```
36+
37+
The **header** is mandatory and the **scope** of the header is optional.
38+
The **footer** can contain a ticket reference in case the commits don't get squashed.
39+
40+
The body should contain a user friendly description of the change. most likely, the header contains the "What was changed" while the body explains the "Why". See the body as the part that goes to a end-user changelog.
41+
42+
```
43+
docs(changelog): update changelog
44+
```
45+
```
46+
fix(layouts): add additional horizontal space
47+
48+
The layout was improved to look better on big viewports.
49+
```

README.md

Lines changed: 54 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,45 @@
1+
<p align="center"><img width="386" src="https://raw.githubusercontent.com/renestalder/nuxt-netlify-cms-starter-template/master/docs/nuxt-netlify.svg" alt="Nuxt Netlify Logo"></p>
2+
13
# Nuxt.js + Netlify CMS starter template
24

5+
[![Build Status](https://travis-ci.org/renestalder/nuxt-netlify-cms-starter-template.svg?branch=master)](https://travis-ci.org/renestalder/nuxt-netlify-cms-starter-template)
6+
37
> Build server-less, static websites with Vue.js and Netlify CMS.
48
5-
This is a fork of the [Nuxt.js starter project](https://github.com/nuxt-community/starter-template) with the goal, to extend it with [Netlify CMS](https://www.netlifycms.org) for building pre-rendered, server-less websites. See the [Further explanation](#further-explanation) section for more information.
9+
This is a starter template to build static websites with Vue.js and Netlify CMS, based on Nuxt v1.x. What it covers:
10+
11+
* **Setup via Vue CLI** 🏗
12+
Easily setup a nearly blank Nuxt.js project.
13+
*Currently not optimized for Vue CLI v3.0*.
14+
* **Content editing via Netlify CMS** ✏️
15+
Netlify CMS is a client-side CMS connecting directly to your git repository to edit markdown files.
16+
*Also supports other file formats, but this template only works with the default, frontmatter markdown format.*
17+
* **Show content in Vue.js via Nuxtent/Nuxtdown module** 🔍️
18+
The Nuxtdown module (fixed fork from Nuxtent) allows querying the content and show in the UI.
19+
* **Static-site generation via Nuxt.js**
20+
Nuxt.js, the famous framework to build universal Vue.js applications, generates a static-site.
21+
22+
---
23+
24+
<!-- TOC -->
625

7-
Live demo: Coming soon.
26+
- [Nuxt.js + Netlify CMS starter template](#nuxtjs--netlify-cms-starter-template)
27+
- [Prerequisites](#prerequisites)
28+
- [Setup](#setup)
29+
- [Usage](#usage)
30+
- [Configuration](#configuration)
31+
- [Development](#development)
32+
- [Production](#production)
33+
- [Contribution](#contribution)
34+
35+
<!-- /TOC -->
836

937
## Prerequisites
1038

1139
* Make sure to have `node 8.0+` and `npm 5.0+` installed
1240
* You know what Netlify CMS and Nuxt.js is.
1341

14-
## Installation
42+
## Setup
1543

1644
**Step 1** This is a project template for [vue-cli](https://github.com/vuejs/vue-cli).
1745

@@ -22,7 +50,7 @@ $ cd my-project
2250
$ npm install # Or yarn install
2351
```
2452

25-
> Make sure to use a version of vue-cli >= 2.1 (`vue -V`).
53+
> Make sure to use a version of vue-cli >= 2.1 (`vue -V`). It wasn't tested with Vue CLI >= 3.0.
2654
2755
**Step 2** Push to GitHub & to Netlify
2856

@@ -32,11 +60,23 @@ $ npm install # Or yarn install
3260

3361
### Configuration
3462

35-
* `nuxt.config.js` contains the default parameters pls an additional variable to define the route matching between Netlify CMS and Nuxt.js.
36-
* **Netlify CMS**: Please follow the documentation of Netlify CMS to get it up and running with your repository.
63+
* **CMS & content models**
64+
Define content files and fields for your content.
65+
*File*: `static/admin/config.yml`
66+
*Documentation*: [Official Netlify CMS documentation -> Configuration][netlifydocs]
67+
* **Routing & querying**
68+
Out of the box, the UI doesn't have a clue where your content is stored and which dynamic routes belong to which content. Nuxt.js can only map static pages by default. Dynamic routes like blog posts with different file names are not detected. The configuration for this happens by Nuxtdown.
69+
*File*: `nuxtdown.config.js`
70+
*Documentation*: [Nuxtdown Readme][nuxtdownreadme]
71+
* **General website information**
72+
General information like HTML `<head>` tags and page titles are set via Nuxt.js. Don't bother with routing configuration for Nuxt.js, this is solved by Nuxtdown.
73+
*File*: `nuxt.config.js`
74+
*Documentation*: [Official Nuxt.js Documentation -> Configuration][nuxtconfig]
3775

3876
### Development
3977

78+
During development, run the client-side SPA version of your application. Use the `dev` or `serve` task, whatever fits you better. They do the same.
79+
4080
``` bash
4181
# serve with hot reloading at localhost:3000
4282
$ npm run dev
@@ -46,124 +86,20 @@ Go to [http://localhost:3000](http://localhost:3000)
4686

4787
### Production
4888

89+
For production, generate the static-site.
90+
4991
``` bash
5092
# generate a static project
5193
$ npm run generate
5294
```
5395

5496
While the other commands from Nuxt.js remain in this starter kit, we clearly focus on serving static HTML files, thus the `generate` command is our task to create the website for production.
5597

56-
## Further explanation
57-
58-
The goal of this boilerplate is to allow creating websites server-less and enable content management
59-
with a CMS at the same time. It's all about saving time, saving money and especially keep to front-end work, while allowing people to edit content.
60-
61-
### What it does
62-
63-
* [x] **Pre-rendering:** Uses Nuxt.js to pre-render your Vuejs website to static HTML files.
64-
* [x] **Easy dynamic route rendering**: Allows to map glob patterns to your Nuxt.js page paths.
65-
This (partially) removes the need to define all dynamic routes by hand.
66-
* [ ] **Automatic mapping dynamic routes for pre-render:**: No more need to define dynamic routes manually.
67-
Netlify CMS and Nuxt.js sync their routes automatically.
68-
* [x] **CMS:** Allows to edit content without the need of a server, thanks to Netlify CMS.
69-
70-
### How it works
71-
72-
For this particular example we use following libraries and frameworks:
73-
74-
* **Vue.js with Nuxt.js**: Vue.js for building our application and Nuxt.js for pre-rendering it.
75-
In general, this could be anything here as long it can read json or markdown files and is can be
76-
pre-rendered.
77-
* **Netlify CMS**: A CMS which is built on JavaScript and connects to the Git repository.
78-
It defines the content models and edits the content files in the repository.
79-
80-
Basically, we use the default Nuxt.js boilerplate, add Netlify CMS files and extend the Nuxt.js config
81-
to collect all content files and add those routes automatically to your Nuxt.js files.
82-
83-
Nuxt.js doesn't pre-render dynamic routes, e.g. blog/post/my-blog-post-2. But it allows to add the urls to those
84-
pages manually to your config. Since you don't want to add a route to your config everytime you publish a blog post,
85-
we allow to set dynamic paths with a glob in the Nuxt.js config. Those define glob folders are grabbed and
86-
all files are added as routes to the Nuxt.js generate.route config_.
87-
88-
#### Principles
89-
90-
A pragmatic overview what this does.
91-
92-
1. You have a plain Vue.js and Nuxt.js website. That's fine and it works, but you want your pages to
93-
be SEO optimized. So you have two choices: Getting a node server for rendering your website server-side or
94-
you use pre-rendering, which converts all your pages to static HTML pages. This boilerplate does the second one.
95-
2. You add Netlify CMS and connect it to your repository. Now you can create content as json that is stored in
96-
a content folder in your repository.
97-
3. Through webpack, you import the content into your pages and show it to the users.
98-
4. In addition, you run Nuxt.js' generate command to make all this rendered as static HTML files.
99-
5. Everytime a file changes in the repository, the generate command has to be run so the static files of the
100-
website are up to date. _This is not part of this boilerplate. I assume you know how this works with your
101-
favourite CI.
102-
103-
### Why?
104-
105-
Tired of the time investment needed to setup a website that needs to be progressive enhanced,
106-
SEO friendly, accessible and allows to access all content on client-side to benefit from doing additional
107-
UX improvements like page transitions, this is an attempt to make the process for building small or medium sizes
108-
CMS websites fast, easy to edit and easy to use.
109-
110-
You can do all this with CMS like WordPress if you're willing to invest your time:
111-
You have to get an Apache server with PHP, setup WordPress, somehow setup the custom post types
112-
and custom fields (probably by installing ACF), setup the WordPress JSON API, write your templates
113-
in PHP + probably even a second time so you can render them with client-side technology. And then,
114-
at the end, having a website that maybe changes once in a couple of weeks.
115-
116-
This looks like a lot of work for sharing content with the internet.
117-
118-
Second, plain old HTML is still the best. The technology stack in this boilerplate exactly
119-
does that, but gives you the additional tools for content editing and for building advanced web experiences.
120-
121-
In the end, you don't need Vue.js or Nuxt.js. You can get rid of it. You can pre-render your vanilla JavaScript
122-
with Webpack, for sure. You don't need Netlify CMS. Authors could edit Markdown and JSON files directly in the repository.
123-
BUT this is not what we want. We don't want people to get to know Git, we don't want them to edit JSON or Markdown files
124-
without validate their entries.
125-
126-
### Uncertain
127-
128-
#### Build performance with a big amount of pages (e.g. 20'000)
129-
130-
While I've read a while ago that the Nuxt.js documentation is built pre-rendered with up to 20'000 pages.
131-
It's not clear at this point how long such a build takes and how a partial build process could look like.
132-
133-
#### Building different sizes of images
134-
135-
This certainly is an easy one since you could check folders of images and could create a task in webpack or your
136-
CI system to create additional image sizes. Also here, this would have to be a task that partially resizes images
137-
only if they changed.
138-
139-
#### No error check for missing globs
140-
141-
The build might fail all over if you map routes to content that doesn't exist. This will be easy to fix.
142-
143-
### When not to use a static server-less system like this
144-
145-
When your website changes a lot. For example, if you're building news websites whose content changes all 5 minutes,
146-
this would mean, that the whole website is re-generated all 5 minutes. Certainly not the best idea. In this case
147-
you might be better with something more dynamic. But the good part is: If you're building your website on a framework like
148-
Nuxt.js, you can simply switch to server-rendering as soon
149-
as the static, server-less behaviour does not longer fit
150-
your needs. It's as easy as switching two commands in your
151-
build system (and probably changing those window instances that don't work server-side).
152-
153-
## Development
154-
155-
This section describes steps for direct contribution to this template.
98+
## Contribution
15699

157-
1. Checkout git repository.
158-
2. Install dependencies.
159-
```sh
160-
$ npm install
161-
```
162-
3. Automatically install and build the template to a test folder.
163-
```sh
164-
$ npm run test
165-
```
100+
If you're interested in contributing to the project, see [CONTRIBUTING.md][contributing]
166101

167-
Now, whenever you make changes to the source files in `template/`, you can directly test the installation
168-
and the build. It isn't possible to directly build the project inside `template/` due to variables
169-
that get replaced during the vue init steps.
102+
[contributing]: https://github.com/renestalder/nuxt-netlify-cms-starter-template/blob/feature/frontmatter/CONTRIBUTING.md
103+
[netlifydocs]: https://www.netlifycms.org/docs/configuration-options/
104+
[nuxtdownreadme]: https://github.com/joostdecock/nuxtdown-module/blob/master/README.md
105+
[nuxtconfig]: https://nuxtjs.org/guide/configuration

0 commit comments

Comments
 (0)