erudit 4.0.0-dev.5 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/app.vue +34 -34
- package/app/assets/icons/array-check.svg +2 -2
- package/app/assets/icons/array-lines.svg +2 -2
- package/app/assets/icons/array-star.svg +2 -2
- package/app/assets/icons/arrow/from-circle.svg +2 -2
- package/app/assets/icons/arrow/left.svg +2 -2
- package/app/assets/icons/arrow/outward.svg +2 -2
- package/app/assets/icons/arrow/to-circle.svg +2 -2
- package/app/assets/icons/arrow/up-to-right.svg +2 -2
- package/app/assets/icons/aside-open.svg +2 -2
- package/app/assets/icons/asterisk.svg +2 -2
- package/app/assets/icons/book-question.svg +2 -2
- package/app/assets/icons/construction.svg +2 -2
- package/app/assets/icons/draw.svg +2 -2
- package/app/assets/icons/erudit.svg +2 -2
- package/app/assets/icons/file-lines.svg +2 -2
- package/app/assets/icons/files.svg +2 -2
- package/app/assets/icons/folder-open.svg +2 -2
- package/app/assets/icons/folder.svg +2 -2
- package/app/assets/icons/graduation.svg +2 -2
- package/app/assets/icons/handshake.svg +2 -2
- package/app/assets/icons/lines.svg +2 -2
- package/app/assets/icons/plus-circle.svg +2 -2
- package/app/assets/icons/puzzle.svg +2 -2
- package/app/assets/icons/rocket.svg +2 -2
- package/app/assets/icons/search/check.svg +2 -2
- package/app/assets/icons/search/dead.svg +2 -2
- package/app/assets/icons/search/glass.svg +2 -2
- package/app/assets/icons/search/wtf.svg +2 -2
- package/app/assets/icons/sun-moon.svg +2 -2
- package/app/assets/icons/translate.svg +2 -2
- package/app/assets/icons/warning.svg +2 -2
- package/app/components/EruditLink.ts +9 -9
- package/app/components/FancyBold.vue +16 -16
- package/app/components/FancyCard.vue +52 -52
- package/app/components/FancyCardTag.vue +16 -16
- package/app/components/Loading.vue +7 -7
- package/app/components/Prose.vue +55 -55
- package/app/components/ScrollHolder.vue +20 -20
- package/app/components/SmartMedia.vue +107 -107
- package/app/components/ads/Ads.vue +39 -39
- package/app/components/ads/AdsBannerAside.vue +45 -45
- package/app/components/ads/AdsBannerBottom.vue +17 -17
- package/app/components/ads/AdsReplacer.vue +26 -26
- package/app/components/ads/provider/Custom.vue +19 -19
- package/app/components/ads/provider/Yandex.vue +84 -84
- package/app/components/aside/AsideListItem.vue +61 -61
- package/app/components/aside/AsideMajor.vue +8 -8
- package/app/components/aside/AsideMinor.vue +68 -68
- package/app/components/aside/AsidePlainMessage.vue +9 -9
- package/app/components/aside/AsideSwitch.vue +76 -76
- package/app/components/aside/major/PaneHolder.vue +106 -106
- package/app/components/aside/major/PaneSwitcher.vue +68 -68
- package/app/components/aside/major/PaneSwitcherButton.vue +38 -38
- package/app/components/aside/major/PaneTemplate.vue +5 -5
- package/app/components/aside/major/SiteInfo.vue +66 -66
- package/app/components/aside/major/contentNav/PaneBookNav.vue +107 -107
- package/app/components/aside/major/contentNav/PaneGlobalNav.vue +19 -19
- package/app/components/aside/major/contentNav/items/ContentNavBook.vue +21 -21
- package/app/components/aside/major/contentNav/items/ContentNavFolder.vue +91 -91
- package/app/components/aside/major/contentNav/items/ContentNavItem.vue +33 -33
- package/app/components/aside/major/contentNav/items/ContentNavPage.vue +14 -14
- package/app/components/aside/major/contentNav/items/ContentNavSeparator.vue +61 -61
- package/app/components/aside/major/contentNav/items/ContentNavTopic.vue +18 -18
- package/app/components/aside/major/contentNav/items/Flags.vue +50 -50
- package/app/components/aside/major/contentNav/items/ItemTemplate.vue +27 -27
- package/app/components/aside/major/languages/PaneLanguages.vue +55 -55
- package/app/components/aside/major/pages/PanePages.vue +60 -60
- package/app/components/aside/major/search/PaneSearch.vue +156 -156
- package/app/components/aside/major/search/SearchInput.vue +103 -103
- package/app/components/aside/major/search/SearchResult.vue +154 -154
- package/app/components/aside/major/search/SearchStatus.vue +48 -48
- package/app/components/aside/major/search/search.worker.ts +164 -164
- package/app/components/aside/major/settings/BuildTime.vue +25 -25
- package/app/components/aside/major/settings/EngineVersion.vue +14 -14
- package/app/components/aside/major/settings/PaneSettings.vue +17 -17
- package/app/components/aside/major/settings/ThemeSwitcher.vue +55 -55
- package/app/components/aside/major/settings/repository/Repository.vue +33 -33
- package/app/components/aside/major/settings/repository/SecondaryGitHub.vue +71 -71
- package/app/components/aside/minor/AsideMinorPane.vue +5 -5
- package/app/components/aside/minor/AsideMinorPlainHeader.vue +20 -20
- package/app/components/aside/minor/content/AsideMinorContentContributions.vue +47 -47
- package/app/components/aside/minor/content/AsideMinorContentPage.vue +37 -37
- package/app/components/aside/minor/content/AsideMinorContentTopic.vue +61 -61
- package/app/components/aside/minor/content/ButtonPaneContributions.vue +101 -101
- package/app/components/aside/minor/content/ButtonPaneImprove.vue +112 -112
- package/app/components/aside/minor/content/Contribution.vue +36 -36
- package/app/components/aside/minor/content/Toc.vue +163 -163
- package/app/components/aside/minor/content/TocItem.vue +91 -91
- package/app/components/aside/minor/content/TopicPartButton.vue +35 -35
- package/app/components/aside/minor/contributor/AsideMinorContributor.vue +36 -36
- package/app/components/aside/minor/contributor/ItemBook.vue +33 -33
- package/app/components/aside/minor/contributor/ItemContent.vue +17 -17
- package/app/components/aside/minor/news/AsideMinorNews.vue +132 -132
- package/app/components/aside/minor/news/NewsItem.vue +69 -69
- package/app/components/aside/minor/news/RenderNewsElement.vue +42 -42
- package/app/components/aside/minor/news/elements/Mix.vue +11 -11
- package/app/components/aside/minor/news/elements/P.vue +14 -14
- package/app/components/aside/minor/news/elements/Ref.vue +59 -59
- package/app/components/aside/minor/news/elements/Text.vue +18 -18
- package/app/components/indexPage/IndexPagePersons.vue +116 -116
- package/app/components/main/MainAction.vue +26 -26
- package/app/components/main/MainBreadcrumbs.vue +28 -28
- package/app/components/main/MainContentChild.vue +44 -44
- package/app/components/main/MainContentChildren.vue +13 -13
- package/app/components/main/MainDecoration.vue +15 -15
- package/app/components/main/MainDescription.vue +13 -13
- package/app/components/main/MainFlag.vue +129 -129
- package/app/components/main/MainFlags.vue +17 -17
- package/app/components/main/MainGlow.vue +12 -12
- package/app/components/main/MainQuickLink.vue +90 -90
- package/app/components/main/MainQuickLinks.vue +40 -40
- package/app/components/main/MainQuote.vue +149 -149
- package/app/components/main/MainQuoteLoader.vue +86 -86
- package/app/components/main/MainSection.vue +44 -44
- package/app/components/main/MainSectionPreamble.vue +5 -5
- package/app/components/main/MainSubTitle.vue +11 -11
- package/app/components/main/MainTitle.vue +32 -32
- package/app/components/main/MainTopicPartPage.vue +88 -88
- package/app/components/main/MainTopicPartSwitch.vue +67 -67
- package/app/components/main/connections/Deps.vue +30 -30
- package/app/components/main/connections/Externals.vue +80 -80
- package/app/components/main/connections/MainConnections.vue +90 -90
- package/app/components/main/connections/MainConnectionsButton.vue +81 -81
- package/app/components/main/connections/ScrollPane.vue +10 -10
- package/app/components/main/contentStats/Item.vue +28 -28
- package/app/components/main/contentStats/ItemElement.vue +19 -19
- package/app/components/main/contentStats/ItemMaterials.vue +11 -11
- package/app/components/main/contentStats/MainContentStats.vue +50 -50
- package/app/components/preview/Preview.vue +161 -161
- package/app/components/preview/PreviewError.vue +10 -10
- package/app/components/preview/PreviewLoading.vue +5 -5
- package/app/components/preview/PreviewScreen.vue +64 -64
- package/app/components/preview/PreviewScreenButton.vue +39 -39
- package/app/components/preview/screen/ContentPage.vue +47 -47
- package/app/components/preview/screen/DirectLink.vue +23 -23
- package/app/components/preview/screen/Unique.vue +53 -53
- package/app/components/site/SiteAside.vue +67 -67
- package/app/components/site/SiteAsideOverlay.vue +21 -21
- package/app/components/site/SiteMain.vue +13 -13
- package/app/components/transition/Fade.vue +30 -30
- package/app/components/transition/Slide.vue +47 -47
- package/app/components/tree/TreeContainer.vue +5 -5
- package/app/components/tree/TreeItem.vue +36 -36
- package/app/composables/ads.ts +23 -23
- package/app/composables/analytics.ts +102 -102
- package/app/composables/appElements.ts +40 -40
- package/app/composables/aside.ts +28 -28
- package/app/composables/asideMajorPane.ts +135 -135
- package/app/composables/asideMinor.ts +109 -109
- package/app/composables/contentNav.ts +7 -7
- package/app/composables/favicon.ts +103 -103
- package/app/composables/file.ts +4 -4
- package/app/composables/formatText.ts +100 -100
- package/app/composables/loading.ts +26 -26
- package/app/composables/mainContent.ts +31 -31
- package/app/composables/og.ts +184 -184
- package/app/composables/phrases.ts +126 -126
- package/app/composables/preview.ts +53 -53
- package/app/composables/route.ts +6 -6
- package/app/composables/theme.ts +67 -67
- package/app/composables/url.ts +30 -30
- package/app/formatters/ru.ts +14 -14
- package/app/pages/article/[...articleId].vue +12 -12
- package/app/pages/book/[...bookId].vue +56 -56
- package/app/pages/contributor/[contributorId].vue +144 -144
- package/app/pages/contributors.vue +95 -95
- package/app/pages/group/[...groupId].vue +58 -58
- package/app/pages/index.vue +113 -113
- package/app/pages/page/[...pageId].vue +60 -60
- package/app/pages/practice/[...practiceId].vue +12 -12
- package/app/pages/sponsors.vue +88 -88
- package/app/pages/summary/[...summaryId].vue +12 -12
- package/app/plugins/appSetup/client/htmlBranding.ts +6 -6
- package/app/plugins/appSetup/client/welcome.ts +37 -37
- package/app/plugins/appSetup/config.ts +6 -6
- package/app/plugins/appSetup/global.ts +3 -3
- package/app/plugins/appSetup/index.ts +27 -27
- package/app/plugins/prerender.server.ts +40 -40
- package/app/router.options.ts +5 -5
- package/app/scripts/theme.js +30 -30
- package/app/styles/main.css +176 -176
- package/bin/erudit.js +12 -12
- package/modules/erudit/env.ts +8 -8
- package/modules/erudit/globals/content.ts +4 -4
- package/modules/erudit/globals/contributor.ts +1 -1
- package/modules/erudit/globals/eruditConfig.ts +5 -5
- package/modules/erudit/globals/problem.ts +1 -1
- package/modules/erudit/globals/prose.ts +5 -1
- package/modules/erudit/globals/public.ts +18 -18
- package/modules/erudit/index.ts +50 -50
- package/modules/erudit/logger.ts +10 -10
- package/modules/erudit/setup/elements/appTemplate.ts +44 -44
- package/modules/erudit/setup/elements/globalTemplate.ts +82 -82
- package/modules/erudit/setup/elements/globalTypes.ts +259 -259
- package/modules/erudit/setup/elements/setup.ts +163 -163
- package/modules/erudit/setup/elements/shared.ts +10 -10
- package/modules/erudit/setup/elements/tagsTable.ts +28 -28
- package/modules/erudit/setup/fullRestart.ts +61 -61
- package/modules/erudit/setup/globals.ts +210 -206
- package/modules/erudit/setup/publicAssets.ts +43 -43
- package/modules/erudit/setup/runtimeConfig.ts +106 -106
- package/modules/erudit/watcher.ts +20 -20
- package/nuxt.config.ts +102 -102
- package/package.json +5 -5
- package/proxy/prose.app.ts +1 -1
- package/proxy/prose.ts +1 -1
- package/server/api/aside/major/frontNav/book/[...shortId].ts +10 -10
- package/server/api/aside/major/frontNav/global.ts +5 -5
- package/server/api/aside/major/pages.ts +6 -6
- package/server/api/contributor/list.ts +60 -60
- package/server/api/contributor/page/[contributorId].ts +68 -68
- package/server/api/indexPage.ts +81 -81
- package/server/api/language/functions.ts +11 -11
- package/server/api/language/phrase/[phraseKey].ts +35 -35
- package/server/api/main/content/[...contentTypePath].ts +149 -149
- package/server/api/news/batch/[batchIndex].ts +5 -5
- package/server/api/pageSponsors.ts +56 -56
- package/server/api/prerender/content.ts +79 -79
- package/server/api/prerender/default.ts +35 -35
- package/server/api/prerender/files.ts +10 -10
- package/server/api/prerender/frontNav.ts +13 -13
- package/server/api/prerender/language.ts +7 -7
- package/server/api/prerender/news.ts +8 -8
- package/server/api/prerender/quotes.ts +15 -15
- package/server/api/preview/contentPage/[...contentTypePath].ts +63 -63
- package/server/api/preview/contentUnique/[...contentTypePathUnique].ts +73 -73
- package/server/api/problemScript/[...problemScriptPath].ts +88 -88
- package/server/api/quote/data/[quoteId].ts +84 -84
- package/server/api/quote/ids.ts +3 -3
- package/server/erudit/build.ts +132 -132
- package/server/erudit/cameos/build.ts +161 -161
- package/server/erudit/config.ts +13 -13
- package/server/erudit/content/global/build.ts +300 -300
- package/server/erudit/content/global/singleton.ts +5 -5
- package/server/erudit/content/nav/build.ts +459 -459
- package/server/erudit/content/nav/front.ts +125 -125
- package/server/erudit/content/nav/repository/books.ts +37 -37
- package/server/erudit/content/nav/repository/get.ts +33 -33
- package/server/erudit/content/nav/repository/hasChildren.ts +5 -5
- package/server/erudit/content/nav/repository/hasNav.ts +3 -3
- package/server/erudit/content/nav/repository/hasParent.ts +5 -5
- package/server/erudit/content/nav/repository/id.ts +9 -9
- package/server/erudit/content/nav/repository/index.ts +9 -9
- package/server/erudit/content/nav/repository/order.ts +14 -14
- package/server/erudit/content/nav/repository/previousNext.ts +35 -35
- package/server/erudit/content/nav/repository/walk.ts +127 -127
- package/server/erudit/content/nav/setup.ts +13 -13
- package/server/erudit/content/nav/types.ts +24 -24
- package/server/erudit/content/repository/breadcrumbs.ts +24 -24
- package/server/erudit/content/repository/children.ts +47 -47
- package/server/erudit/content/repository/connections.ts +35 -35
- package/server/erudit/content/repository/contentLink.ts +16 -16
- package/server/erudit/content/repository/decoration.ts +23 -23
- package/server/erudit/content/repository/deps.ts +121 -121
- package/server/erudit/content/repository/description.ts +11 -11
- package/server/erudit/content/repository/elementSnippets.ts +105 -105
- package/server/erudit/content/repository/externals.ts +50 -50
- package/server/erudit/content/repository/flags.ts +33 -33
- package/server/erudit/content/repository/seo.ts +12 -12
- package/server/erudit/content/repository/stats.ts +97 -97
- package/server/erudit/content/repository/title.ts +27 -27
- package/server/erudit/content/repository/topicParts.ts +39 -39
- package/server/erudit/content/repository/unique.ts +76 -76
- package/server/erudit/content/resolve/book.ts +29 -29
- package/server/erudit/content/resolve/group.ts +34 -34
- package/server/erudit/content/resolve/index.ts +272 -272
- package/server/erudit/content/resolve/page.ts +80 -80
- package/server/erudit/content/resolve/topic.ts +220 -220
- package/server/erudit/content/resolve/utils/contentError.ts +10 -10
- package/server/erudit/content/resolve/utils/insertContentItem.ts +113 -113
- package/server/erudit/content/resolve/utils/insertContentResolved.ts +126 -126
- package/server/erudit/content/search.ts +146 -146
- package/server/erudit/contributors/build.ts +158 -158
- package/server/erudit/contributors/global.ts +3 -3
- package/server/erudit/contributors/repository/avatarUrl.ts +10 -10
- package/server/erudit/contributors/repository/contributions.ts +171 -171
- package/server/erudit/contributors/repository/count.ts +3 -3
- package/server/erudit/contributors/search.ts +34 -34
- package/server/erudit/db/repository/pushFile.ts +23 -23
- package/server/erudit/db/repository/pushProblemScript.ts +19 -19
- package/server/erudit/db/repository/pushProseLink.ts +40 -40
- package/server/erudit/db/schema/cameos.ts +7 -7
- package/server/erudit/db/schema/content.ts +18 -18
- package/server/erudit/db/schema/contentContributions.ts +15 -15
- package/server/erudit/db/schema/contentDeps.ts +21 -21
- package/server/erudit/db/schema/contentElementStats.ts +20 -20
- package/server/erudit/db/schema/contentProseLinks.ts +23 -23
- package/server/erudit/db/schema/contentSnippets.ts +15 -15
- package/server/erudit/db/schema/contentToc.ts +16 -16
- package/server/erudit/db/schema/contentUniques.ts +19 -19
- package/server/erudit/db/schema/contributors.ts +12 -12
- package/server/erudit/db/schema/files.ts +11 -11
- package/server/erudit/db/schema/groups.ts +6 -6
- package/server/erudit/db/schema/index.ts +17 -17
- package/server/erudit/db/schema/news.ts +7 -7
- package/server/erudit/db/schema/pages.ts +7 -7
- package/server/erudit/db/schema/problemScripts.ts +14 -14
- package/server/erudit/db/schema/sponsors.ts +9 -9
- package/server/erudit/db/schema/topics.ts +9 -9
- package/server/erudit/db/setup.ts +62 -62
- package/server/erudit/db/types.ts +10 -10
- package/server/erudit/global.ts +38 -38
- package/server/erudit/importer.ts +94 -94
- package/server/erudit/index.ts +96 -96
- package/server/erudit/language/list/en.ts +116 -116
- package/server/erudit/language/list/ru.ts +120 -120
- package/server/erudit/language/list.ts +6 -6
- package/server/erudit/language/setup.ts +36 -36
- package/server/erudit/language/types.ts +16 -16
- package/server/erudit/logger.ts +73 -73
- package/server/erudit/news/build.ts +112 -112
- package/server/erudit/news/repository/batch.ts +61 -61
- package/server/erudit/path.ts +19 -19
- package/server/erudit/prose/repository/finalize.ts +68 -68
- package/server/erudit/prose/repository/get.ts +54 -54
- package/server/erudit/prose/repository/resolve.ts +17 -17
- package/server/erudit/prose/storage/callout.ts +16 -16
- package/server/erudit/prose/storage/image.ts +22 -22
- package/server/erudit/prose/storage/link.ts +222 -222
- package/server/erudit/prose/storage/problemScript.ts +23 -23
- package/server/erudit/prose/storage/video.ts +16 -16
- package/server/erudit/prose/transform/bundleProblemScript.ts +6 -6
- package/server/erudit/prose/transform/extensions.ts +15 -15
- package/server/erudit/quote/repository/ids.ts +31 -31
- package/server/erudit/repository.ts +96 -96
- package/server/erudit/sponsors/build.ts +161 -161
- package/server/erudit/sponsors/repository/avatarUrl.ts +10 -10
- package/server/erudit/sponsors/repository/count.ts +4 -4
- package/server/erudit/staticFile.ts +28 -28
- package/server/plugins/augmentCss.ts +17 -17
- package/server/plugins/lang.ts +5 -5
- package/server/plugins/metaViewport.ts +15 -15
- package/server/plugins/theme.ts +13 -13
- package/server/routes/file/[...path].ts +18 -18
- package/server/routes/robots.txt.ts +9 -9
- package/server/routes/search.json.gz.ts +76 -76
- package/server/routes/sitemap.xml.ts +83 -83
- package/shared/search/encoders.ts +20 -20
- package/shared/types/asideMajorPages.ts +4 -4
- package/shared/types/breadcrumbs.ts +9 -9
- package/shared/types/contentChildren.ts +10 -10
- package/shared/types/contentConnections.ts +27 -27
- package/shared/types/contentStats.ts +6 -6
- package/shared/types/elementSnippet.ts +14 -14
- package/shared/types/frontContentNav.ts +38 -38
- package/shared/types/indexPage.ts +20 -20
- package/shared/types/language.ts +191 -191
- package/shared/types/mainContent.ts +69 -69
- package/shared/types/news.ts +13 -13
- package/shared/types/preview.ts +28 -28
- package/shared/types/runtimeConfig.ts +46 -46
- package/shared/types/search.ts +79 -79
- package/shared/utils/contentTypePath.ts +63 -63
- package/shared/utils/icons.ts +11 -11
- package/shared/utils/pages.ts +23 -23
- package/shared/utils/stringColor.ts +13 -13
- package/shared/utils/toStringEqual.ts +21 -21
- package/shared/utils/zip.ts +64 -64
- package/test/shared/utils/zip.test.ts +8 -8
- package/tsconfig.json +17 -17
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
import { eq } from 'drizzle-orm';
|
|
2
|
-
|
|
3
|
-
import type { ContentNavNode } from './types';
|
|
4
|
-
|
|
5
|
-
export async function getGlobalFrontContentNav(): Promise<FrontGlobalContentNav> {
|
|
6
|
-
const bookShortIds = Array.from(ERUDIT.contentNav.id2Books.values()).map(
|
|
7
|
-
(b) => b.shortId,
|
|
8
|
-
);
|
|
9
|
-
|
|
10
|
-
const navItems = await Promise.all(
|
|
11
|
-
Array.from(ERUDIT.contentNav.id2Root.values()).map(
|
|
12
|
-
async (navNode) => await createFrontContentNavItem(navNode, true),
|
|
13
|
-
),
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
return {
|
|
17
|
-
bookShortIds,
|
|
18
|
-
frontNavItems: navItems.filter((item) => item !== undefined),
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function getBookFrontContentNav(
|
|
23
|
-
bookNavNode: ContentNavNode,
|
|
24
|
-
): Promise<FrontContentNavBook> {
|
|
25
|
-
if (bookNavNode.type !== 'book') {
|
|
26
|
-
throw createError({
|
|
27
|
-
status: 400,
|
|
28
|
-
message: `Provided nav node "${bookNavNode.fullId}" is not a book!`,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return (await createFrontContentNavItem(
|
|
33
|
-
bookNavNode,
|
|
34
|
-
false,
|
|
35
|
-
true, // include empty book when directly requesting book nav
|
|
36
|
-
)) as FrontContentNavBook;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function createFrontContentNavItem(
|
|
40
|
-
navNode: ContentNavNode,
|
|
41
|
-
isGlobal: boolean,
|
|
42
|
-
includeIfEmpty = false,
|
|
43
|
-
): Promise<FrontContentNavItem | undefined> {
|
|
44
|
-
const dbContentItem = (await ERUDIT.db.query.content.findFirst({
|
|
45
|
-
columns: {
|
|
46
|
-
title: true,
|
|
47
|
-
navTitle: true,
|
|
48
|
-
flags: true,
|
|
49
|
-
hidden: true,
|
|
50
|
-
},
|
|
51
|
-
where: eq(ERUDIT.db.schema.content.fullId, navNode.fullId),
|
|
52
|
-
}))!;
|
|
53
|
-
|
|
54
|
-
if (ERUDIT.config.public.mode === 'static' && dbContentItem.hidden) {
|
|
55
|
-
if (navNode.type === 'book') {
|
|
56
|
-
if (isGlobal) {
|
|
57
|
-
// We can hide book in global nav.
|
|
58
|
-
return undefined;
|
|
59
|
-
} else {
|
|
60
|
-
// But we should show the book if user is already inside it.
|
|
61
|
-
}
|
|
62
|
-
} else {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const baseItem: FrontContentNavItemBase = {
|
|
68
|
-
shortId: navNode.shortId,
|
|
69
|
-
title: dbContentItem.navTitle || dbContentItem.title,
|
|
70
|
-
flags: dbContentItem.flags || {},
|
|
71
|
-
link: await ERUDIT.repository.content.link(navNode.fullId),
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
async function processChildren() {
|
|
75
|
-
const children = await Promise.all(
|
|
76
|
-
(navNode.children || []).map(
|
|
77
|
-
async (childNavNode) =>
|
|
78
|
-
await createFrontContentNavItem(childNavNode, isGlobal),
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
return children.filter((c): c is FrontContentNavItem => c !== undefined);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
switch (navNode.type) {
|
|
85
|
-
case 'topic':
|
|
86
|
-
return {
|
|
87
|
-
type: 'topic',
|
|
88
|
-
...baseItem,
|
|
89
|
-
};
|
|
90
|
-
case 'page':
|
|
91
|
-
return {
|
|
92
|
-
type: 'page',
|
|
93
|
-
...baseItem,
|
|
94
|
-
};
|
|
95
|
-
case 'group': {
|
|
96
|
-
const dbGroup = (await ERUDIT.db.query.groups.findFirst({
|
|
97
|
-
columns: { separator: true },
|
|
98
|
-
where: eq(ERUDIT.db.schema.groups.fullId, navNode.fullId),
|
|
99
|
-
}))!;
|
|
100
|
-
const children = await processChildren();
|
|
101
|
-
if (children.length === 0 && !includeIfEmpty) {
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
type: 'group',
|
|
106
|
-
separator: dbGroup.separator,
|
|
107
|
-
...baseItem,
|
|
108
|
-
children,
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
case 'book': {
|
|
112
|
-
const children = await processChildren();
|
|
113
|
-
// In global nav we suppress empty books; when directly loading book (includeIfEmpty)
|
|
114
|
-
// we still return it so consumer can show the book shell.
|
|
115
|
-
if (children.length === 0 && !includeIfEmpty) {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
return {
|
|
119
|
-
type: 'book',
|
|
120
|
-
...baseItem,
|
|
121
|
-
children: isGlobal ? [] : children,
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
|
|
3
|
+
import type { ContentNavNode } from './types';
|
|
4
|
+
|
|
5
|
+
export async function getGlobalFrontContentNav(): Promise<FrontGlobalContentNav> {
|
|
6
|
+
const bookShortIds = Array.from(ERUDIT.contentNav.id2Books.values()).map(
|
|
7
|
+
(b) => b.shortId,
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
const navItems = await Promise.all(
|
|
11
|
+
Array.from(ERUDIT.contentNav.id2Root.values()).map(
|
|
12
|
+
async (navNode) => await createFrontContentNavItem(navNode, true),
|
|
13
|
+
),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
bookShortIds,
|
|
18
|
+
frontNavItems: navItems.filter((item) => item !== undefined),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function getBookFrontContentNav(
|
|
23
|
+
bookNavNode: ContentNavNode,
|
|
24
|
+
): Promise<FrontContentNavBook> {
|
|
25
|
+
if (bookNavNode.type !== 'book') {
|
|
26
|
+
throw createError({
|
|
27
|
+
status: 400,
|
|
28
|
+
message: `Provided nav node "${bookNavNode.fullId}" is not a book!`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (await createFrontContentNavItem(
|
|
33
|
+
bookNavNode,
|
|
34
|
+
false,
|
|
35
|
+
true, // include empty book when directly requesting book nav
|
|
36
|
+
)) as FrontContentNavBook;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function createFrontContentNavItem(
|
|
40
|
+
navNode: ContentNavNode,
|
|
41
|
+
isGlobal: boolean,
|
|
42
|
+
includeIfEmpty = false,
|
|
43
|
+
): Promise<FrontContentNavItem | undefined> {
|
|
44
|
+
const dbContentItem = (await ERUDIT.db.query.content.findFirst({
|
|
45
|
+
columns: {
|
|
46
|
+
title: true,
|
|
47
|
+
navTitle: true,
|
|
48
|
+
flags: true,
|
|
49
|
+
hidden: true,
|
|
50
|
+
},
|
|
51
|
+
where: eq(ERUDIT.db.schema.content.fullId, navNode.fullId),
|
|
52
|
+
}))!;
|
|
53
|
+
|
|
54
|
+
if (ERUDIT.config.public.mode === 'static' && dbContentItem.hidden) {
|
|
55
|
+
if (navNode.type === 'book') {
|
|
56
|
+
if (isGlobal) {
|
|
57
|
+
// We can hide book in global nav.
|
|
58
|
+
return undefined;
|
|
59
|
+
} else {
|
|
60
|
+
// But we should show the book if user is already inside it.
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const baseItem: FrontContentNavItemBase = {
|
|
68
|
+
shortId: navNode.shortId,
|
|
69
|
+
title: dbContentItem.navTitle || dbContentItem.title,
|
|
70
|
+
flags: dbContentItem.flags || {},
|
|
71
|
+
link: await ERUDIT.repository.content.link(navNode.fullId),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
async function processChildren() {
|
|
75
|
+
const children = await Promise.all(
|
|
76
|
+
(navNode.children || []).map(
|
|
77
|
+
async (childNavNode) =>
|
|
78
|
+
await createFrontContentNavItem(childNavNode, isGlobal),
|
|
79
|
+
),
|
|
80
|
+
);
|
|
81
|
+
return children.filter((c): c is FrontContentNavItem => c !== undefined);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
switch (navNode.type) {
|
|
85
|
+
case 'topic':
|
|
86
|
+
return {
|
|
87
|
+
type: 'topic',
|
|
88
|
+
...baseItem,
|
|
89
|
+
};
|
|
90
|
+
case 'page':
|
|
91
|
+
return {
|
|
92
|
+
type: 'page',
|
|
93
|
+
...baseItem,
|
|
94
|
+
};
|
|
95
|
+
case 'group': {
|
|
96
|
+
const dbGroup = (await ERUDIT.db.query.groups.findFirst({
|
|
97
|
+
columns: { separator: true },
|
|
98
|
+
where: eq(ERUDIT.db.schema.groups.fullId, navNode.fullId),
|
|
99
|
+
}))!;
|
|
100
|
+
const children = await processChildren();
|
|
101
|
+
if (children.length === 0 && !includeIfEmpty) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
type: 'group',
|
|
106
|
+
separator: dbGroup.separator,
|
|
107
|
+
...baseItem,
|
|
108
|
+
children,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
case 'book': {
|
|
112
|
+
const children = await processChildren();
|
|
113
|
+
// In global nav we suppress empty books; when directly loading book (includeIfEmpty)
|
|
114
|
+
// we still return it so consumer can show the book shell.
|
|
115
|
+
if (children.length === 0 && !includeIfEmpty) {
|
|
116
|
+
return undefined;
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
type: 'book',
|
|
120
|
+
...baseItem,
|
|
121
|
+
children: isGlobal ? [] : children,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import type { ContentNavNode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function getBooks(): ContentNavNode[] {
|
|
4
|
-
return Array.from(ERUDIT.contentNav.id2Books.values());
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function getBookIds(idType: 'full' | 'short' = 'full'): string[] {
|
|
8
|
-
return getBooks().map((book) =>
|
|
9
|
-
idType === 'short' ? book.shortId : book.fullId,
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function getBookFor(
|
|
14
|
-
nodeOrId: ContentNavNode | string,
|
|
15
|
-
): ContentNavNode | undefined {
|
|
16
|
-
const node =
|
|
17
|
-
typeof nodeOrId === 'string'
|
|
18
|
-
? ERUDIT.contentNav.getNode(nodeOrId)
|
|
19
|
-
: nodeOrId;
|
|
20
|
-
|
|
21
|
-
if (!node) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const nodeFullId = node.fullId;
|
|
26
|
-
let longestMatch: ContentNavNode | undefined;
|
|
27
|
-
|
|
28
|
-
for (const book of ERUDIT.contentNav.id2Books.values()) {
|
|
29
|
-
if (nodeFullId.startsWith(book.fullId)) {
|
|
30
|
-
if (!longestMatch || book.fullId.length > longestMatch.fullId.length) {
|
|
31
|
-
longestMatch = book;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return longestMatch;
|
|
37
|
-
}
|
|
1
|
+
import type { ContentNavNode } from '../types';
|
|
2
|
+
|
|
3
|
+
export function getBooks(): ContentNavNode[] {
|
|
4
|
+
return Array.from(ERUDIT.contentNav.id2Books.values());
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function getBookIds(idType: 'full' | 'short' = 'full'): string[] {
|
|
8
|
+
return getBooks().map((book) =>
|
|
9
|
+
idType === 'short' ? book.shortId : book.fullId,
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getBookFor(
|
|
14
|
+
nodeOrId: ContentNavNode | string,
|
|
15
|
+
): ContentNavNode | undefined {
|
|
16
|
+
const node =
|
|
17
|
+
typeof nodeOrId === 'string'
|
|
18
|
+
? ERUDIT.contentNav.getNode(nodeOrId)
|
|
19
|
+
: nodeOrId;
|
|
20
|
+
|
|
21
|
+
if (!node) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const nodeFullId = node.fullId;
|
|
26
|
+
let longestMatch: ContentNavNode | undefined;
|
|
27
|
+
|
|
28
|
+
for (const book of ERUDIT.contentNav.id2Books.values()) {
|
|
29
|
+
if (nodeFullId.startsWith(book.fullId)) {
|
|
30
|
+
if (!longestMatch || book.fullId.length > longestMatch.fullId.length) {
|
|
31
|
+
longestMatch = book;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return longestMatch;
|
|
37
|
+
}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import type { ContentNavNode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function getNode(fullOrShortId: string): ContentNavNode | undefined {
|
|
4
|
-
let foundNode: ContentNavNode | undefined =
|
|
5
|
-
ERUDIT.contentNav.id2Node.get(fullOrShortId);
|
|
6
|
-
|
|
7
|
-
if (foundNode) {
|
|
8
|
-
return foundNode;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const fullId = ERUDIT.contentNav.short2Full.get(fullOrShortId);
|
|
12
|
-
if (fullId) {
|
|
13
|
-
foundNode = ERUDIT.contentNav.id2Node.get(fullId);
|
|
14
|
-
if (foundNode) {
|
|
15
|
-
return foundNode;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function getNodeOrThrow(fullOrShortId: string): ContentNavNode {
|
|
23
|
-
const foundNode = getNode(fullOrShortId);
|
|
24
|
-
|
|
25
|
-
if (!foundNode) {
|
|
26
|
-
throw createError({
|
|
27
|
-
statusCode: 404,
|
|
28
|
-
statusMessage: `Content nav node not found: "${fullOrShortId}"!`,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return foundNode;
|
|
33
|
-
}
|
|
1
|
+
import type { ContentNavNode } from '../types';
|
|
2
|
+
|
|
3
|
+
export function getNode(fullOrShortId: string): ContentNavNode | undefined {
|
|
4
|
+
let foundNode: ContentNavNode | undefined =
|
|
5
|
+
ERUDIT.contentNav.id2Node.get(fullOrShortId);
|
|
6
|
+
|
|
7
|
+
if (foundNode) {
|
|
8
|
+
return foundNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const fullId = ERUDIT.contentNav.short2Full.get(fullOrShortId);
|
|
12
|
+
if (fullId) {
|
|
13
|
+
foundNode = ERUDIT.contentNav.id2Node.get(fullId);
|
|
14
|
+
if (foundNode) {
|
|
15
|
+
return foundNode;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function getNodeOrThrow(fullOrShortId: string): ContentNavNode {
|
|
23
|
+
const foundNode = getNode(fullOrShortId);
|
|
24
|
+
|
|
25
|
+
if (!foundNode) {
|
|
26
|
+
throw createError({
|
|
27
|
+
statusCode: 404,
|
|
28
|
+
statusMessage: `Content nav node not found: "${fullOrShortId}"!`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return foundNode;
|
|
33
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentNavNode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function hasChildren(node: ContentNavNode): boolean {
|
|
4
|
-
return (node.children?.length ?? 0) > 0;
|
|
5
|
-
}
|
|
1
|
+
import type { ContentNavNode } from '../types';
|
|
2
|
+
|
|
3
|
+
export function hasChildren(node: ContentNavNode): boolean {
|
|
4
|
+
return (node.children?.length ?? 0) > 0;
|
|
5
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function hasNav(): boolean {
|
|
2
|
-
return ERUDIT.contentNav.id2Node.size > 0;
|
|
3
|
-
}
|
|
1
|
+
export function hasNav(): boolean {
|
|
2
|
+
return ERUDIT.contentNav.id2Node.size > 0;
|
|
3
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContentNavNode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function hasParent(node: ContentNavNode): boolean {
|
|
4
|
-
return !!node.parent;
|
|
5
|
-
}
|
|
1
|
+
import type { ContentNavNode } from '../types';
|
|
2
|
+
|
|
3
|
+
export function hasParent(node: ContentNavNode): boolean {
|
|
4
|
+
return !!node.parent;
|
|
5
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function toFullId(fullOrShortId: string) {
|
|
2
|
-
const node = ERUDIT.contentNav.getNode(fullOrShortId);
|
|
3
|
-
return node && node.fullId;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export function toShortId(fullOrShortId: string) {
|
|
7
|
-
const node = ERUDIT.contentNav.getNode(fullOrShortId);
|
|
8
|
-
return node && node.shortId;
|
|
9
|
-
}
|
|
1
|
+
export function toFullId(fullOrShortId: string) {
|
|
2
|
+
const node = ERUDIT.contentNav.getNode(fullOrShortId);
|
|
3
|
+
return node && node.fullId;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function toShortId(fullOrShortId: string) {
|
|
7
|
+
const node = ERUDIT.contentNav.getNode(fullOrShortId);
|
|
8
|
+
return node && node.shortId;
|
|
9
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from './books';
|
|
2
|
-
export * from './get';
|
|
3
|
-
export * from './walk';
|
|
4
|
-
export * from './hasChildren';
|
|
5
|
-
export * from './hasParent';
|
|
6
|
-
export * from './hasNav';
|
|
7
|
-
export * from './id';
|
|
8
|
-
export * from './previousNext';
|
|
9
|
-
export * from './order';
|
|
1
|
+
export * from './books';
|
|
2
|
+
export * from './get';
|
|
3
|
+
export * from './walk';
|
|
4
|
+
export * from './hasChildren';
|
|
5
|
+
export * from './hasParent';
|
|
6
|
+
export * from './hasNav';
|
|
7
|
+
export * from './id';
|
|
8
|
+
export * from './previousNext';
|
|
9
|
+
export * from './order';
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function orderIds(contentIds: string[]): string[] {
|
|
2
|
-
const idsSet = new Set(contentIds);
|
|
3
|
-
const orderedIds: string[] = [];
|
|
4
|
-
|
|
5
|
-
ERUDIT.contentNav.walkSync((node) => {
|
|
6
|
-
if (idsSet.has(node.fullId)) {
|
|
7
|
-
orderedIds.push(node.fullId);
|
|
8
|
-
} else if (idsSet.has(node.shortId)) {
|
|
9
|
-
orderedIds.push(node.shortId);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
return orderedIds;
|
|
14
|
-
}
|
|
1
|
+
export function orderIds(contentIds: string[]): string[] {
|
|
2
|
+
const idsSet = new Set(contentIds);
|
|
3
|
+
const orderedIds: string[] = [];
|
|
4
|
+
|
|
5
|
+
ERUDIT.contentNav.walkSync((node) => {
|
|
6
|
+
if (idsSet.has(node.fullId)) {
|
|
7
|
+
orderedIds.push(node.fullId);
|
|
8
|
+
} else if (idsSet.has(node.shortId)) {
|
|
9
|
+
orderedIds.push(node.shortId);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
return orderedIds;
|
|
14
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import type { ContentNavNode } from '../types';
|
|
2
|
-
|
|
3
|
-
export function getPreviousNext(node: ContentNavNode) {
|
|
4
|
-
const currentFullId = node.fullId;
|
|
5
|
-
|
|
6
|
-
let previous: ContentNavNode | undefined;
|
|
7
|
-
let next: ContentNavNode | undefined;
|
|
8
|
-
let currentFound = false;
|
|
9
|
-
|
|
10
|
-
for (const navNode of ERUDIT.contentNav.id2Node.values()) {
|
|
11
|
-
if (currentFound) {
|
|
12
|
-
next = navNode;
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (navNode.fullId === currentFullId) {
|
|
17
|
-
currentFound = true;
|
|
18
|
-
} else {
|
|
19
|
-
previous = navNode;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// If current inside book then next can't point outside of book
|
|
24
|
-
if (next) {
|
|
25
|
-
const currentBook = ERUDIT.contentNav.getBookFor(node);
|
|
26
|
-
if (currentBook) {
|
|
27
|
-
const nextBook = ERUDIT.contentNav.getBookFor(next);
|
|
28
|
-
if (!nextBook || nextBook.fullId !== currentBook.fullId) {
|
|
29
|
-
next = undefined;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return { previous, next };
|
|
35
|
-
}
|
|
1
|
+
import type { ContentNavNode } from '../types';
|
|
2
|
+
|
|
3
|
+
export function getPreviousNext(node: ContentNavNode) {
|
|
4
|
+
const currentFullId = node.fullId;
|
|
5
|
+
|
|
6
|
+
let previous: ContentNavNode | undefined;
|
|
7
|
+
let next: ContentNavNode | undefined;
|
|
8
|
+
let currentFound = false;
|
|
9
|
+
|
|
10
|
+
for (const navNode of ERUDIT.contentNav.id2Node.values()) {
|
|
11
|
+
if (currentFound) {
|
|
12
|
+
next = navNode;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (navNode.fullId === currentFullId) {
|
|
17
|
+
currentFound = true;
|
|
18
|
+
} else {
|
|
19
|
+
previous = navNode;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// If current inside book then next can't point outside of book
|
|
24
|
+
if (next) {
|
|
25
|
+
const currentBook = ERUDIT.contentNav.getBookFor(node);
|
|
26
|
+
if (currentBook) {
|
|
27
|
+
const nextBook = ERUDIT.contentNav.getBookFor(next);
|
|
28
|
+
if (!nextBook || nextBook.fullId !== currentBook.fullId) {
|
|
29
|
+
next = undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return { previous, next };
|
|
35
|
+
}
|