1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-08-09 23:45:25 +02:00

Removed iframe, added default index page, made startPage optional parameter

This commit is contained in:
slaveeks 2022-09-09 21:55:06 +03:00
parent c94273b76a
commit 089831a607
5 changed files with 39 additions and 26 deletions

View file

@ -5,7 +5,6 @@
"Guides",
{"title": "CodeX", "uri": "https://codex.so"}
],
"landingFrameSrc": "https://codex.so/editor?frame=1",
"startPage": "",
"misprintsChatId": "12344564",
"yandexMetrikaId": "",

View file

@ -1,5 +1,8 @@
import express, { Request, Response } from 'express';
import verifyToken from './middlewares/token.js';
import PagesOrder from '../controllers/pagesOrder.js';
import Pages from '../controllers/pages.js';
const router = express.Router();
@ -7,10 +10,22 @@ const router = express.Router();
router.get('/', verifyToken, async (req: Request, res: Response) => {
const config = req.app.locals.config;
// Check if config consists startPage
if (config.startPage) {
return res.redirect(config.startPage);
} else {
const pageOrder = await PagesOrder.getRootPageOrder();
// Check if page order consists
if (pageOrder.order.length > 0) {
// Get the first parent page
const page = await Pages.get(pageOrder.order[0]);
res.redirect(page.uri!);
} else {
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
}
}
res.render('pages/index', { isAuthorized: res.locals.isAuthorized });
});
export default router;

View file

@ -14,11 +14,13 @@
</script>
<body class="landing-body">
{% include "components/header.twig" %}
<div class="landing-loader" id="frame-loader">
{{ svg('loader') }}
<div class="content">
{{ svg('frog') }}
<p>
Its time to create the first page!
</p>
{% include 'components/button.twig' with {label: 'Add page', icon: 'plus', size: 'small', url: '/page/new'} %}
</div>
<iframe class="landing-frame" src="{{ config.landingFrameSrc }}" seamless frameborder="0" onload="this.style.opacity = 1; setTimeout(document.getElementById('frame-loader').remove(), 500)"></iframe>
{% if config.yandexMetrikaId is not empty %}
<script type="text/javascript" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};

View file

@ -1,6 +1,3 @@
/**
* Index page landing iframe
*/
.landing-body {
display: flex;
flex-direction: column;
@ -8,23 +5,14 @@
height: 100%;
}
.landing-loader {
position: absolute;
left: 50%;
top: 50%;
z-index: -1;
transform: translate(-50%, -50%);
.content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: auto;
& > svg {
width: 80px;
height: 80px;
width: 70px;
height: 70px;
}
}
.landing-frame {
width: 100%;
height: 100%;
opacity: 0;
transition: opacity 500ms ease;
will-change: opacity;
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 51 KiB