mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-09 15:35:25 +02:00
Fixed duplicated variables, some changes in navigation functions, changed pages.twig and navigator.twig
This commit is contained in:
parent
6cc223e869
commit
aaf7e99782
7 changed files with 27 additions and 53 deletions
|
@ -93,7 +93,7 @@ class PageOrder {
|
||||||
* @param {string} pageId - page's id
|
* @param {string} pageId - page's id
|
||||||
* @returns {Promise<string | null>} - previous page id
|
* @returns {Promise<string | null>} - previous page id
|
||||||
*/
|
*/
|
||||||
public static async getPreviousNavigationPage(pageId: string): Promise<string | null> {
|
public static async getPreviousNavigationPage(pageId: string): Promise<string> {
|
||||||
const page = await Pages.get(pageId);
|
const page = await Pages.get(pageId);
|
||||||
|
|
||||||
const pageParent = await page.getParent();
|
const pageParent = await page.getParent();
|
||||||
|
@ -133,7 +133,7 @@ class PageOrder {
|
||||||
previousPageId = newOrder._order[newOrder._order.length - 1];
|
previousPageId = newOrder._order[newOrder._order.length - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
return previousPageId;
|
return previousPageId || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -142,7 +142,7 @@ class PageOrder {
|
||||||
* @param {string} pageId - page's id
|
* @param {string} pageId - page's id
|
||||||
* @returns {Promise<string | null>} - next page id
|
* @returns {Promise<string | null>} - next page id
|
||||||
*/
|
*/
|
||||||
public static async getNextNavigationPage(pageId: string): Promise<string | null> {
|
public static async getNextNavigationPage(pageId: string): Promise<string> {
|
||||||
const page = await Pages.get(pageId);
|
const page = await Pages.get(pageId);
|
||||||
const pageParent = await page.getParent();
|
const pageParent = await page.getParent();
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ class PageOrder {
|
||||||
|
|
||||||
nextPageId = order.getSubPageAfter(pageParent._id);
|
nextPageId = order.getSubPageAfter(pageParent._id);
|
||||||
|
|
||||||
return nextPageId;
|
return nextPageId || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get order by page id
|
// Get order by page id
|
||||||
|
@ -183,7 +183,7 @@ class PageOrder {
|
||||||
|
|
||||||
nextPageId = order.getSubPageAfter(pageId);
|
nextPageId = order.getSubPageAfter(pageId);
|
||||||
|
|
||||||
return nextPageId;
|
return nextPageId || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,21 +34,11 @@ router.get('*', verifyToken, async (req: Request, res: Response) => {
|
||||||
|
|
||||||
const pageParent = await page.getParent();
|
const pageParent = await page.getParent();
|
||||||
|
|
||||||
let previousPage;
|
|
||||||
|
|
||||||
let nextPage;
|
|
||||||
|
|
||||||
const previousPageId = await PageOrder.getPreviousNavigationPage(alias.id);
|
const previousPageId = await PageOrder.getPreviousNavigationPage(alias.id);
|
||||||
|
|
||||||
const nextPageId = await PageOrder.getNextNavigationPage(alias.id);
|
const nextPageId = await PageOrder.getNextNavigationPage(alias.id);
|
||||||
|
|
||||||
if (previousPageId){
|
const previousPage = await Page.get(previousPageId);
|
||||||
previousPage = await Page.get(previousPageId);
|
const nextPage = await Page.get(nextPageId);
|
||||||
}
|
|
||||||
|
|
||||||
if (nextPageId) {
|
|
||||||
nextPage = await Page.get(nextPageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.render('pages/page', {
|
res.render('pages/page', {
|
||||||
page,
|
page,
|
||||||
|
|
|
@ -64,21 +64,11 @@ router.get('/page/:id', verifyToken, async (req: Request, res: Response, next: N
|
||||||
|
|
||||||
const pageParent = await page.parent;
|
const pageParent = await page.parent;
|
||||||
|
|
||||||
let previousPage;
|
|
||||||
|
|
||||||
let nextPage;
|
|
||||||
|
|
||||||
const previousPageId = await PageOrder.getPreviousNavigationPage(pageId);
|
const previousPageId = await PageOrder.getPreviousNavigationPage(pageId);
|
||||||
|
|
||||||
const nextPageId = await PageOrder.getNextNavigationPage(pageId);
|
const nextPageId = await PageOrder.getNextNavigationPage(pageId);
|
||||||
|
|
||||||
if (previousPageId) {
|
const previousPage = await Page.get(previousPageId);
|
||||||
previousPage = await Page.get(previousPageId);
|
const nextPage = await Page.get(nextPageId);
|
||||||
}
|
|
||||||
|
|
||||||
if (nextPageId) {
|
|
||||||
nextPage = await Page.get(nextPageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
res.render('pages/page', {
|
res.render('pages/page', {
|
||||||
page,
|
page,
|
||||||
|
|
|
@ -19,15 +19,19 @@ Usage example:
|
||||||
{% set tag = 'a' %}
|
{% set tag = 'a' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<{{tag}}
|
<div class="navigator_wrapper">
|
||||||
{{ name is not empty ? 'name="' ~ name ~ '"': '' }}
|
{% if label and url %}
|
||||||
class="{{ mainClass }} {{ mainClass }}--{{ direction|default('previous') }} {{ class ?? '' }}"
|
<{{ tag }}
|
||||||
{{ url is not empty ? 'href="' ~ url ~ '"' : '' }}
|
{{ name is not empty ? 'name="' ~ name ~ '"': '' }}
|
||||||
>
|
class="{{ mainClass }} {{ mainClass }}--{{ direction|default('previous') }} {{ class ?? '' }}"
|
||||||
<div class="{{mainClass}}__direction">
|
{{ url is not empty ? 'href="' ~ url ~ '"' : '' }}
|
||||||
{{ direction }}
|
>
|
||||||
|
<div class="{{ mainClass }}__direction">
|
||||||
|
{{ direction }}
|
||||||
|
</div>
|
||||||
|
<div class="{{ mainClass }}__label">
|
||||||
|
{{ label }}
|
||||||
|
</div>
|
||||||
|
</{{ tag }}>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="{{mainClass}}__label">
|
|
||||||
{{ label }}
|
|
||||||
</div>
|
|
||||||
</{{tag}}>
|
|
||||||
|
|
|
@ -40,16 +40,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</section>
|
</section>
|
||||||
<footer class="page_footer">
|
<footer class="page_footer">
|
||||||
<div class="navigator_wrapper">
|
{% include 'components/navigator.twig' with {label: previousPage.title, direction: 'previous', url: '/' ~ previousPage.uri} %}
|
||||||
{% if previousPage %}
|
{% include 'components/navigator.twig' with {label: nextPage.title, direction: 'next', url: '/' ~ nextPage.uri} %}
|
||||||
{% include 'components/navigator.twig' with {label: previousPage.title, direction: 'previous', url: '/' ~ previousPage.uri} %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<div class="navigator_wrapper">
|
|
||||||
{% if nextPage %}
|
|
||||||
{% include 'components/navigator.twig' with {label: nextPage.title, direction: 'next', url: '/' ~ nextPage.uri} %}
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</footer>
|
</footer>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
background-color: var(--color-bg-navigation);
|
background-color: var(--color-link-hover);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
padding: 12px 16px 12px 16px;
|
padding: 12px 16px 12px 16px;
|
||||||
color: black;
|
color: black;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
--color-button-warning-hover: #D65151;
|
--color-button-warning-hover: #D65151;
|
||||||
--color-button-warning-active: #BD4848;
|
--color-button-warning-active: #BD4848;
|
||||||
|
|
||||||
--color-bg-navigation: #F3F6F8;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Site layout sizes
|
* Site layout sizes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue