From 41996ca804833aa0ddf728b7b89de1c4b7168cce Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 23 Jun 2022 02:42:40 +0200 Subject: [PATCH] Add README on index --- src/routes/index.js | 12 ++++++++---- src/utils/readme.js | 10 ++++++++++ src/views/index.ejs | 3 ++- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/utils/readme.js diff --git a/src/routes/index.js b/src/routes/index.js index 3ebda34..240e5a5 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -1,8 +1,12 @@ -const router = require('express').Router(); +const router = require('express').Router() +const marked = require('marked') + +const readme = require('../utils/readme') // Home Page router.get('/', (_, res) => { - res.render('index'); -}); + readme.data() + .then(data => res.render('index', { readme: marked.parse(data) })) +}) -module.exports = router; +module.exports = router diff --git a/src/utils/readme.js b/src/utils/readme.js new file mode 100644 index 0000000..05b9917 --- /dev/null +++ b/src/utils/readme.js @@ -0,0 +1,10 @@ +const fetch = require('node-fetch') + +async function data () { + return await fetch('https://git.kennel.ml/Anri/Constnium/raw/branch/main/README.md') + .then(res => res.text()) +} + +module.exports = { + data +} diff --git a/src/views/index.ejs b/src/views/index.ejs index faa76ee..dc28d61 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -7,6 +7,7 @@ Constnium - +
+ <%- readme %>