mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-19 13:19:42 +02:00
Added default index page, default startPage, removed iframe (#250)
* Removed iframe, added default index page, made startPage optional parameter * Renamed class for landing content * Added paddings for message in index page, removed iframe link from index * Renamed landing to greeting * rm extra margins, upd svg Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
This commit is contained in:
parent
ba40b4f3d9
commit
e1fd9a77f6
7 changed files with 50 additions and 39 deletions
|
@ -5,7 +5,6 @@
|
||||||
"Guides",
|
"Guides",
|
||||||
{"title": "CodeX", "uri": "https://codex.so"}
|
{"title": "CodeX", "uri": "https://codex.so"}
|
||||||
],
|
],
|
||||||
"landingFrameSrc": "https://codex.so/editor?frame=1",
|
|
||||||
"startPage": "",
|
"startPage": "",
|
||||||
"misprintsChatId": "12344564",
|
"misprintsChatId": "12344564",
|
||||||
"yandexMetrikaId": "",
|
"yandexMetrikaId": "",
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
import express, { Request, Response } from 'express';
|
import express, { Request, Response } from 'express';
|
||||||
import verifyToken from './middlewares/token.js';
|
import verifyToken from './middlewares/token.js';
|
||||||
|
import PagesOrder from '../controllers/pagesOrder.js';
|
||||||
|
import Pages from '../controllers/pages.js';
|
||||||
|
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
@ -7,10 +10,22 @@ const router = express.Router();
|
||||||
router.get('/', verifyToken, async (req: Request, res: Response) => {
|
router.get('/', verifyToken, async (req: Request, res: Response) => {
|
||||||
const config = req.app.locals.config;
|
const config = req.app.locals.config;
|
||||||
|
|
||||||
|
// Check if config consists startPage
|
||||||
if (config.startPage) {
|
if (config.startPage) {
|
||||||
return res.redirect(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;
|
export default router;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
<head>
|
<head>
|
||||||
<title>{{ config.title }}</title>
|
<title>{{ config.title }}</title>
|
||||||
<link rel="stylesheet" href="/dist/main.css" />
|
<link rel="stylesheet" href="/dist/main.css" />
|
||||||
<link rel="preload" href="{{ config.landingFrameSrc }}" as="document">
|
|
||||||
<link rel="icon" type="{{ favicon.type }}" href="{{ favicon.destination }}">
|
<link rel="icon" type="{{ favicon.type }}" href="{{ favicon.destination }}">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<meta property="og:title" content="{{ config.title }}" />
|
<meta property="og:title" content="{{ config.title }}" />
|
||||||
|
@ -12,13 +11,15 @@
|
||||||
</head>
|
</head>
|
||||||
<script>
|
<script>
|
||||||
</script>
|
</script>
|
||||||
<body class="landing-body">
|
<body class="greeting-body">
|
||||||
{% include "components/header.twig" %}
|
{% include "components/header.twig" %}
|
||||||
<div class="landing-loader" id="frame-loader">
|
<div class="greeting-content">
|
||||||
{{ svg('loader') }}
|
{{ svg('frog') }}
|
||||||
|
<p class="greeting-content__message">
|
||||||
|
It’s time to create the first page!
|
||||||
|
</p>
|
||||||
|
{% include 'components/button.twig' with {label: 'Add page', icon: 'plus', size: 'small', url: '/page/new'} %}
|
||||||
</div>
|
</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 %}
|
{% if config.yandexMetrikaId is not empty %}
|
||||||
<script type="text/javascript" >
|
<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)};
|
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||||||
|
|
25
src/frontend/styles/components/greeting.pcss
Normal file
25
src/frontend/styles/components/greeting.pcss
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
.greeting-body {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.greeting-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
margin: auto;
|
||||||
|
|
||||||
|
& > svg {
|
||||||
|
width: 62px;
|
||||||
|
height: 71px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__message {
|
||||||
|
margin: 0;
|
||||||
|
padding: 26px 0 26px 0;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,30 +0,0 @@
|
||||||
/**
|
|
||||||
* Index page landing iframe
|
|
||||||
*/
|
|
||||||
.landing-body {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.landing-loader {
|
|
||||||
position: absolute;
|
|
||||||
left: 50%;
|
|
||||||
top: 50%;
|
|
||||||
z-index: -1;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
|
|
||||||
& > svg {
|
|
||||||
width: 80px;
|
|
||||||
height: 80px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.landing-frame {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 500ms ease;
|
|
||||||
will-change: opacity;
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@
|
||||||
@import './components/header.pcss';
|
@import './components/header.pcss';
|
||||||
@import './components/writing.pcss';
|
@import './components/writing.pcss';
|
||||||
@import './components/page.pcss';
|
@import './components/page.pcss';
|
||||||
@import './components/landing.pcss';
|
@import './components/greeting.pcss';
|
||||||
@import './components/auth.pcss';
|
@import './components/auth.pcss';
|
||||||
@import './components/error.pcss';
|
@import './components/error.pcss';
|
||||||
@import './components/button.pcss';
|
@import './components/button.pcss';
|
||||||
|
|
1
src/frontend/svg/frog.svg
Normal file
1
src/frontend/svg/frog.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 12 KiB |
Loading…
Add table
Add a link
Reference in a new issue