Go to file
2021-07-28 15:27:24 +02:00
assets/css Added a default theme. 2021-07-28 15:27:24 +02:00
content Added a default theme. 2021-07-28 15:27:24 +02:00
.gitignore Initial commit 2021-07-27 16:56:40 +02:00
config.json Basic CMS done. 2021-07-27 21:04:57 +02:00
index.js Added some tiny QoL things. 2021-07-27 21:57:48 +02:00
LICENSE Initial commit 2021-07-27 16:56:40 +02:00
package-lock.json Added some tiny QoL things. 2021-07-27 21:57:48 +02:00
package.json Added some tiny QoL things. 2021-07-27 21:57:48 +02:00
README.md Added some tiny QoL things. 2021-07-27 21:57:48 +02:00

qwik cms

This is a really basic CMS. But it will get the job done. It basically operates really simple. It checks what path a client is trying to access and checks if there is a corresponding file for that. After that it renders the file if it exists (if not it sends a 404 error).

Installation

Requirements:

  • node
  • npm

Instructions:

git clone https://git.qwik.space/BurnyLlama/qwik-cms
cd qwik-cms
npm i
node index.js

Extra info

Even tho it can be annoying, I would recommend looking through what code this will run on your PC/server. Otherwise you would have to take my word for it, which could be a bad idea. (Although I can promise you that there is no malicious code or dependency in this project AFAIK.)

The project depends on the following packages (installed when you ran npm i):

  • express (a web server framework)
  • nunjucks (a templating engine)
  • chokidar (reload templates if they change on disk)
  • fs (used for filesystem operations)

Maintenence

I recommend forking (or just cloning) this repository if you want a long-term solution for stuff like multiple people working on the site.

How do I create pages?

Let's say you want a page on the path /foo, then you can create the corresponding file in two places:

  • {contentDir}/pages/foo.njk
  • {contentDir}/pages/foo/index.njk

/foo/bar would be in either of:

  • {contentDir}/pages/foo/bar.njk
  • {contentDir}/pages/foo/bar/index.njk

If both files exist the first one specified is rendered. {contentDir} is configured in config.json and its default is content/.

The documents are written in the nunjucks templating language which means you can use imports/includes/etc for code reusability.

Configuration

The default configuration looks like this:

{
    "contentDir": "content",
    "assetsDir": "assets",

    "serverPort": "8789",
    "serverName": "qwik"
}

The file is called config.json.

Descriptions

contentDir

Specifies which directory the content is in.

Default: content

assetsDir

Specifies which directory the assets are in. These items will be statically available on (your site's) /assets/. I recommend storing CSS, images, etc. here.

Default: assets

serverPort

The port the server should run on.

Default: 8789

serverName

This can be accessed in any page/template by using {{ serverName }}

Default: qwik

Future features

I have some ideas on things that would be good to implement, one of which is plugins/extensions that can provide extra functionality.

As an example, it would be cool to be able to implement sidebars that contains all pages (if you're making a blog or wiki/documentation).

It would also be nice to have a plugin that could auto update (and restart) the server if you make changes to a git repository. (You could do this with cronjobs in theory, but this should be the server's responsibility.)