diff --git a/README.md b/README.md index 5c64c08..4808b7b 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,12 @@ Any URL like `/year/month/day/anything/` will redirect to this article (and link * `plantuml` (default: true) activate PlantUML diagram rendering * `home` + * `title` (default: GitBlog.md) + the title of your blog, **strongly advised to be changed** + given to the template to complete page title and metadata + * `description` (default: A static blog using Markdown pulled from your git repository) + the description of your blog, **strongly advised to be changed** + given to the template to complete page title and metadata * `index` (default: index.ejs) the name of the home page template on the data directory it will receive `articles`, a list of articles for rendering diff --git a/package.json b/package.json index 2dac4ab..81423c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gitblog.md", - "version": "1.1.3", + "version": "1.1.4", "description": "A static blog using Markdown pulled from your git repository.", "main": "src/server.js", "dependencies": { diff --git a/sample_data/home/error.ejs b/sample_data/home/error.ejs index 9593025..b8ccbdc 100644 --- a/sample_data/home/error.ejs +++ b/sample_data/home/error.ejs @@ -2,7 +2,17 @@ - Error <%= error %> + <%= info.title %> - Error <%= error %> + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + + + diff --git a/sample_data/home/index.ejs b/sample_data/home/index.ejs index 4c48df3..67c0afb 100644 --- a/sample_data/home/index.ejs +++ b/sample_data/home/index.ejs @@ -2,13 +2,23 @@ - GitBlog.md - Home + <%= info.title %> - Home + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + + +
-

GitBlog.md

- A static blog using Markdown pulled from your git repository +

<%= info.title %>

+ <%= info.description %>

Articles in this blog :

<% articles.forEach((article) => { %>
diff --git a/sample_data/home/template.ejs b/sample_data/home/template.ejs index 6acc674..d1a3be3 100644 --- a/sample_data/home/template.ejs +++ b/sample_data/home/template.ejs @@ -2,7 +2,21 @@ - GitBlog.md - <%= article.title %> + <%= info.title %> - <%= article.title %> + + + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <%= `` %> + <% if (article.thumbnail) { %> + <%= `` %> + <%= `` %> + <% } %> + + + diff --git a/src/app.js b/src/app.js index 2dd6093..e0bb3cb 100644 --- a/src/app.js +++ b/src/app.js @@ -36,6 +36,7 @@ module.exports = (config) => { const articles = {}; let lastRSS = ''; + let host; /** * Fetch articles from the data folder and send success as a response @@ -73,6 +74,9 @@ module.exports = (config) => { */ const render = (res, vPath, data, code = 200) => { data.info = { + title: config['home']['title'], + description: config['home']['description'], + host: host, version: pjson.version }; res.render(vPath, data, (err, html) => { @@ -100,6 +104,14 @@ module.exports = (config) => { }); }; + app.use((req, res, next) => { + if (!host) { + host = 'http://' + req.headers.host; + console.log(cons.ok, 'Currently hosted on ' + host); + } + next(); + }); + //log request at result end app.use((req, res, next) => { if (config['access_log']) { diff --git a/src/config.default.json b/src/config.default.json index d5e5518..687ef07 100644 --- a/src/config.default.json +++ b/src/config.default.json @@ -12,6 +12,8 @@ "plantuml": true }, "home": { + "title": "GitBlog.md", + "description": "A static blog using Markdown pulled from your git repository", "index": "index.ejs", "error": "error.ejs", "hidden": [