2022-10-13 14:59:02 +01:00
|
|
|
import express from 'express'
|
2022-10-14 13:21:45 +01:00
|
|
|
import yaml from 'js-yaml'
|
2022-10-18 08:20:54 +01:00
|
|
|
import fs from 'node:fs'
|
2022-11-10 14:49:01 +00:00
|
|
|
import * as dotenv from 'dotenv'
|
2022-10-14 13:21:45 +01:00
|
|
|
|
|
|
|
console.log('🔧 Configuring socialtree...')
|
2022-10-13 14:59:02 +01:00
|
|
|
|
2022-11-10 14:49:01 +00:00
|
|
|
dotenv.config()
|
2022-10-13 14:59:02 +01:00
|
|
|
const app = express()
|
2022-12-30 00:57:42 +00:00
|
|
|
const port = process.env.PORT || 3000
|
2022-10-13 20:59:07 +01:00
|
|
|
const engine = 'ejs'
|
2022-10-13 14:59:02 +01:00
|
|
|
|
2023-01-17 08:45:36 +00:00
|
|
|
const customMainPartialThemes = [ // Array of themes that require a custom main partial
|
2023-01-07 22:16:27 +00:00
|
|
|
'98'
|
2023-01-06 22:21:17 +00:00
|
|
|
]
|
|
|
|
|
2022-10-13 14:59:02 +01:00
|
|
|
app.set('view engine', engine)
|
|
|
|
app.set('views', './src/views')
|
2022-10-18 08:20:54 +01:00
|
|
|
app.use(express.static('src/dist'))
|
2022-10-28 13:39:35 +01:00
|
|
|
app.use(express.static('assets'))
|
2022-10-13 14:59:02 +01:00
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
2022-10-28 13:39:35 +01:00
|
|
|
let config = yaml.load(fs.readFileSync('assets/config/config.yml'), 'utf8')
|
2022-10-13 20:37:37 +01:00
|
|
|
res.render('index', {
|
2022-10-14 13:21:45 +01:00
|
|
|
name: config.name,
|
2022-10-15 20:13:48 +01:00
|
|
|
filenameProfilePic: config.profilePic ? config.profilePic : 'profilepic.jpg',
|
2022-11-11 14:49:08 +00:00
|
|
|
summaryText: config.summaryText ? config.summaryText: '',
|
2022-10-18 08:20:54 +01:00
|
|
|
links: config.links,
|
2022-10-28 07:57:30 +01:00
|
|
|
smallLinks: config.smallLinks,
|
2022-12-30 00:57:42 +00:00
|
|
|
theme: config.theme,
|
2023-01-06 22:21:17 +00:00
|
|
|
roundPB: config.roundPB,
|
2023-01-17 08:45:36 +00:00
|
|
|
customMainPartialThemes: customMainPartialThemes
|
2022-10-13 20:37:37 +01:00
|
|
|
})
|
2022-10-13 14:59:02 +01:00
|
|
|
})
|
|
|
|
|
2022-12-30 00:57:42 +00:00
|
|
|
app.listen(port, () => console.log(`🚀 Socialtree started on port ${port}, with view engine ${engine}`))
|