erudit 2.0.0-dev.8 → 2.0.0-dev.9
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/.nuxtrc +1 -1
- package/app/app.vue +172 -172
- package/app/components/Loading.vue +23 -23
- package/app/components/SiteAside.vue +382 -382
- package/app/components/SiteMain.vue +35 -35
- package/app/components/ads/BannerTemplate.vue +51 -51
- package/app/components/ads/BottomBanner.vue +45 -45
- package/app/components/ads/LeftBanner.vue +50 -50
- package/app/components/aside/AsideListItem.vue +74 -74
- package/app/components/aside/AsideMajor.vue +56 -56
- package/app/components/aside/AsideMinor.vue +71 -71
- package/app/components/aside/major/PaneContentScroll.vue +23 -23
- package/app/components/aside/major/PaneSwitch.vue +54 -54
- package/app/components/aside/major/PaneSwitchButton.vue +63 -63
- package/app/components/aside/major/SiteInfo.vue +85 -85
- package/app/components/aside/major/panes/Language.vue +79 -79
- package/app/components/aside/major/panes/Pages.vue +34 -34
- package/app/components/aside/major/panes/Search.vue +2 -2
- package/app/components/aside/major/panes/nav/Nav.vue +91 -91
- package/app/components/aside/major/panes/nav/NavBook.vue +86 -86
- package/app/components/aside/major/panes/nav/NavBookLoading.vue +24 -24
- package/app/components/aside/major/panes/nav/NavGlobal.vue +16 -16
- package/app/components/aside/major/panes/nav/fnav/FNav.vue +105 -105
- package/app/components/aside/major/panes/nav/fnav/FNavBook.vue +32 -32
- package/app/components/aside/major/panes/nav/fnav/FNavFlags.vue +40 -40
- package/app/components/aside/major/panes/nav/fnav/FNavFolder.vue +60 -60
- package/app/components/aside/major/panes/nav/fnav/FNavItem.vue +34 -34
- package/app/components/aside/major/panes/nav/fnav/FNavSeparator.vue +80 -80
- package/app/components/aside/major/panes/nav/fnav/FNavTopic.vue +24 -24
- package/app/components/aside/major/panes/other/ItemContent.vue +29 -29
- package/app/components/aside/major/panes/other/ItemGenerator.vue +15 -15
- package/app/components/aside/major/panes/other/ItemTheme.vue +54 -54
- package/app/components/aside/major/panes/other/Other.vue +16 -16
- package/app/components/aside/minor/AsideMinorContributor.vue +4 -4
- package/app/components/aside/minor/AsideMinorNews.vue +11 -11
- package/app/components/aside/minor/AsideMinorPane.vue +15 -15
- package/app/components/aside/minor/AsideMinorTopLink.vue +67 -67
- package/app/components/aside/minor/Contribute.vue +145 -145
- package/app/components/aside/minor/content/AsideMinorContent.vue +92 -92
- package/app/components/aside/minor/topic/AsideMinorTopic.vue +32 -32
- package/app/components/aside/minor/topic/TopicContributors.vue +177 -177
- package/app/components/aside/minor/topic/TopicNav.vue +49 -49
- package/app/components/aside/minor/topic/TopicToc.vue +203 -202
- package/app/components/aside/minor/topic/TopicTocItem.vue +31 -31
- package/app/components/aside/utils/AsideOverlayPane.vue +40 -40
- package/app/components/bitran/BitranContent.vue +63 -64
- package/app/components/bitran/RenderWrapper.vue +10 -12
- package/app/components/contributor/ContributorAvatar.vue +43 -43
- package/app/components/contributor/ContributorListItem.vue +35 -35
- package/app/components/main/topic/MainTopic.vue +79 -79
- package/app/components/main/topic/TopicPartSwitch.vue +118 -118
- package/app/components/main/utils/Breadcrumb.vue +75 -75
- package/app/components/main/utils/ContentDecoration.vue +29 -29
- package/app/components/main/utils/ContentDescription.vue +19 -19
- package/app/components/main/utils/ContentFlag.vue +15 -15
- package/app/components/main/utils/ContentPopover.vue +176 -176
- package/app/components/main/utils/ContentPopovers.vue +105 -105
- package/app/components/main/utils/ContentReferences.vue +75 -75
- package/app/components/main/utils/ContentSection.vue +41 -41
- package/app/components/main/utils/ContentTitle.vue +36 -36
- package/app/components/main/utils/reference/ReferenceGroup.vue +40 -40
- package/app/components/main/utils/reference/ReferenceItem.vue +63 -63
- package/app/components/main/utils/reference/ReferenceSource.vue +109 -109
- package/app/components/preview/Preview.vue +177 -177
- package/app/components/preview/PreviewDisplay.vue +139 -139
- package/app/components/preview/PreviewFooterAction.vue +73 -73
- package/app/components/preview/PreviewLoading.vue +14 -14
- package/app/components/preview/PreviewScreen.vue +99 -99
- package/app/components/preview/display/Alert.vue +50 -50
- package/app/components/preview/display/Custom.vue +18 -18
- package/app/components/preview/display/GenericLink.vue +48 -48
- package/app/components/preview/display/PageLink.vue +20 -20
- package/app/components/preview/display/Unique.vue +49 -49
- package/app/components/transition/Fade.vue +21 -21
- package/app/components/tree/TreeContainer.vue +11 -11
- package/app/components/tree/TreeItem.vue +89 -89
- package/app/composables/bitran.ts +98 -103
- package/app/composables/bitranContent.ts +2 -1
- package/app/composables/contentPage.ts +1 -1
- package/app/composables/phrases.ts +80 -80
- package/app/pages/_test/preview.vue +110 -110
- package/app/pages/article/[...articleId].vue +2 -2
- package/app/pages/book/[...bookId].vue +47 -47
- package/app/pages/group/[...groupId].vue +65 -64
- package/app/pages/index.vue +32 -32
- package/app/pages/members.vue +6 -6
- package/app/pages/practice/[...practice].vue +2 -2
- package/app/pages/summary/[...summaryId].vue +2 -2
- package/app/public/favicon/article.svg +9 -9
- package/app/public/favicon/default.svg +9 -9
- package/app/public/favicon/practice.svg +9 -9
- package/app/public/favicon/summary.svg +9 -9
- package/app/public/logotype.svg +16 -16
- package/app/public/user.svg +9 -9
- package/app/scripts/_immediate.js +3 -3
- package/app/scripts/flag.ts +28 -28
- package/app/scripts/og.ts +27 -27
- package/app/scripts/preview/data/unique.ts +3 -3
- package/app/scripts/preview/display.ts +5 -7
- package/app/scripts/preview/request.ts +2 -2
- package/app/styles/_immediate.css +2 -2
- package/app/styles/_util.scss +49 -49
- package/app/styles/_utils.scss +44 -44
- package/app/styles/default.scss +84 -84
- package/app/styles/partials/_darkMagic.scss +6 -6
- package/app/styles/partials/_fnav.scss +17 -17
- package/app/styles/partials/_preview.scss +6 -6
- package/globalPath.ts +21 -21
- package/globals/bitran.ts +21 -13
- package/globals/erudit.ts +5 -5
- package/globals/register.ts +18 -18
- package/languages/en.ts +95 -95
- package/languages/ru.ts +99 -99
- package/module/config.ts +34 -34
- package/module/imports.ts +46 -46
- package/module/index.ts +47 -35
- package/module/logger.ts +10 -10
- package/module/restart.ts +61 -61
- package/nuxt.config.ts +107 -96
- package/package.json +7 -4
- package/server/api/aside/major/nav/bookIds.ts +5 -5
- package/server/api/aside/major/nav/bookNav/[...bookId].ts +20 -20
- package/server/api/aside/major/nav/global.ts +7 -7
- package/server/api/aside/minor/news.ts +7 -7
- package/server/api/aside/minor/path.ts +78 -78
- package/server/api/bitran/content/[location].ts +7 -7
- package/server/api/bitran/toc/[location].ts +7 -7
- package/server/api/content/data.ts +72 -72
- package/server/api/fake/content.ts +10 -10
- package/server/api/fake/shared/languages.ts +12 -12
- package/server/api/language/functions.ts +12 -12
- package/server/api/language/phrase/[phraseId].ts +19 -19
- package/server/api/language/phraseIds.ts +8 -8
- package/server/api/preview/page/[...parts].ts +51 -51
- package/server/api/preview/unique/[location].ts +55 -55
- package/server/plugin/bitran/content.ts +55 -44
- package/server/plugin/bitran/products/include.ts +28 -27
- package/server/plugin/bitran/products/link.ts +11 -9
- package/server/plugin/bitran/setup.ts +0 -1
- package/server/plugin/bitran/toc.ts +25 -24
- package/server/plugin/bitran/transpiler.ts +46 -0
- package/server/plugin/build/close.ts +10 -10
- package/server/plugin/build/jobs/content/parse.ts +37 -27
- package/server/plugin/build/jobs/language.ts +36 -36
- package/server/plugin/build/process.ts +25 -25
- package/server/plugin/build/rebuild.ts +55 -55
- package/server/plugin/build/setup.ts +21 -21
- package/server/plugin/global.ts +18 -18
- package/server/plugin/importer.ts +12 -12
- package/server/plugin/index.ts +9 -9
- package/server/plugin/logger.ts +23 -23
- package/server/tsconfig.json +7 -7
- package/shared/bitran/context.ts +3 -2
- package/shared/bitran/default.ts +46 -0
- package/shared/bitran/{products/link/render → link}/Link.vue +7 -14
- package/shared/bitran/link/factory.ts +24 -0
- package/shared/bitran/link/languages/en.ts +7 -0
- package/shared/bitran/link/languages/ru.ts +7 -0
- package/shared/bitran/link/renderer.ts +21 -0
- package/shared/bitran/link/shared.ts +17 -0
- package/shared/bitran/{products/link → link}/target.ts +1 -1
- package/shared/bitran/link/transpiler.ts +10 -0
- package/shared/content/context.ts +9 -9
- package/shared/content/data/base.ts +32 -32
- package/shared/content/data/index.ts +5 -5
- package/shared/content/data/type/book.ts +5 -5
- package/shared/content/data/type/group.ts +6 -6
- package/shared/content/data/type/topic.ts +11 -11
- package/shared/content/previousNext.ts +9 -9
- package/shared/link.ts +25 -25
- package/shared/types/language.ts +75 -75
- package/test/bitran/{products/link → link}/target.test.ts +5 -2
- package/tsconfig.json +8 -8
- package/utils/stress.ts +9 -9
- package/server/plugin/bitran/core.ts +0 -51
- package/shared/bitran/alias.ts +0 -17
- package/shared/bitran/products/alias/core/factory.ts +0 -46
- package/shared/bitran/products/alias/core/index.ts +0 -13
- package/shared/bitran/products/alias/render/Alias.vue +0 -10
- package/shared/bitran/products/alias/render/icon.svg +0 -3
- package/shared/bitran/products/alias/render/index.ts +0 -17
- package/shared/bitran/products/alias/render/languages/en.ts +0 -5
- package/shared/bitran/products/alias/render/languages/ru.ts +0 -5
- package/shared/bitran/products/alias/shared.ts +0 -11
- package/shared/bitran/products/heading/core/factory.ts +0 -53
- package/shared/bitran/products/heading/core/index.ts +0 -19
- package/shared/bitran/products/heading/render/Heading.vue +0 -47
- package/shared/bitran/products/heading/render/icon.svg +0 -3
- package/shared/bitran/products/heading/render/index.ts +0 -17
- package/shared/bitran/products/heading/render/languages/en.ts +0 -5
- package/shared/bitran/products/heading/render/languages/ru.ts +0 -5
- package/shared/bitran/products/heading/shared.ts +0 -13
- package/shared/bitran/products/include/core/factory.ts +0 -61
- package/shared/bitran/products/include/core/index.ts +0 -13
- package/shared/bitran/products/include/render/Include.vue +0 -13
- package/shared/bitran/products/include/render/icon.svg +0 -3
- package/shared/bitran/products/include/render/index.ts +0 -18
- package/shared/bitran/products/include/render/languages/en.ts +0 -5
- package/shared/bitran/products/include/render/languages/ru.ts +0 -5
- package/shared/bitran/products/include/shared.ts +0 -15
- package/shared/bitran/products/link/core/factory.ts +0 -20
- package/shared/bitran/products/link/core/index.ts +0 -17
- package/shared/bitran/products/link/render/index.ts +0 -17
- package/shared/bitran/products/link/render/languages/en.ts +0 -5
- package/shared/bitran/products/link/render/languages/ru.ts +0 -5
- package/shared/bitran/products/link/shared.ts +0 -15
- package/test/bitran/alias.test.ts +0 -44
- package/test/bitran/products/alias.test.ts +0 -83
- package/test/bitran/products/heading.test.ts +0 -119
- package/test/bitran/products/include.test.ts +0 -77
- package/test/bitran/products/link/factory.test.ts +0 -30
- /package/shared/bitran/{products/link/render → link}/icon.svg +0 -0
|
@@ -1,132 +1,127 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createBitranCore,
|
|
3
|
-
type GenericProductCore,
|
|
4
|
-
defaultProductCores,
|
|
5
|
-
} from 'bitran/core';
|
|
6
|
-
import {
|
|
7
|
-
createBitranRender,
|
|
8
|
-
createPhrase,
|
|
9
|
-
type ProductRender,
|
|
10
|
-
defaultProductRenders,
|
|
11
|
-
} from 'bitran/render';
|
|
12
|
-
|
|
13
1
|
import eruditConfig from '#erudit/config';
|
|
14
2
|
import bitranConfig from '#erudit/client/bitran';
|
|
15
|
-
import { BitranRenderWrapper } from '#components';
|
|
16
|
-
import type { BitranContext } from '@erudit/shared/bitran/context';
|
|
17
|
-
|
|
18
|
-
// Erudit Bitran Products
|
|
19
|
-
import { headingName } from '@erudit/shared/bitran/products/heading/shared';
|
|
20
|
-
import { heading as headingCore } from '@erudit/shared/bitran/products/heading/core';
|
|
21
|
-
import { heading as headingRender } from '@erudit/shared/bitran/products/heading/render';
|
|
22
|
-
import { aliasName } from '@erudit/shared/bitran/products/alias/shared';
|
|
23
|
-
import { defineAlias as defineAliasCore } from '@erudit/shared/bitran/products/alias/core';
|
|
24
|
-
import { alias as aliasRender } from '@erudit/shared/bitran/products/alias/render';
|
|
25
|
-
import { includeName } from '@erudit/shared/bitran/products/include/shared';
|
|
26
|
-
import { include as includeCore } from '@erudit/shared/bitran/products/include/core';
|
|
27
|
-
import { include as includeRender } from '@erudit/shared/bitran/products/include/render';
|
|
28
|
-
import { linkName } from '@erudit/shared/bitran/products/link/shared';
|
|
29
|
-
import { link as linkCore } from '@erudit/shared/bitran/products/link/core';
|
|
30
|
-
import { link as linkRender } from '@erudit/shared/bitran/products/link/render';
|
|
31
|
-
|
|
32
|
-
export async function useBitran(context: BitranContext) {
|
|
33
|
-
/**
|
|
34
|
-
* TODO:
|
|
35
|
-
* Recreating all products every time make create a significant lag on Bitran content change.
|
|
36
|
-
* Cache products!
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
const formatText = useFormatText();
|
|
40
|
-
|
|
41
|
-
const bitranCore = createBitranCore({
|
|
42
|
-
products: await getProductCores(context),
|
|
43
|
-
});
|
|
44
3
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
4
|
+
import {
|
|
5
|
+
createPhraseCaller,
|
|
6
|
+
getDefaultRenderers,
|
|
7
|
+
getElementIcon,
|
|
8
|
+
type ElementVueRenderers,
|
|
9
|
+
} from '@bitran-js/renderer-vue';
|
|
10
|
+
import {
|
|
11
|
+
defineBitranTranspiler,
|
|
12
|
+
type BitranTranspiler,
|
|
13
|
+
type ElementTranspilers,
|
|
14
|
+
} from '@bitran-js/transpiler';
|
|
15
|
+
import { aliasesName } from '@erudit-js/bitran-elements/aliases/shared';
|
|
16
|
+
import { aliasesTranspiler } from '@erudit-js/bitran-elements/aliases/transpiler';
|
|
17
|
+
import { headingName } from '@erudit-js/bitran-elements/heading/shared';
|
|
18
|
+
import { headingTranspiler } from '@erudit-js/bitran-elements/heading/transpiler';
|
|
19
|
+
import { includeName } from '@erudit-js/bitran-elements/include/shared';
|
|
20
|
+
import { includeTranspiler } from '@erudit-js/bitran-elements/include/transpiler';
|
|
21
|
+
import { linkName } from '@erudit/shared/bitran/link/shared';
|
|
22
|
+
import { linkTranspiler } from '@erudit/shared/bitran/link/transpiler';
|
|
23
|
+
import { aliasesRenderer } from '@erudit-js/bitran-elements/aliases/renderer';
|
|
24
|
+
import { headingRenderer } from '@erudit-js/bitran-elements/heading/renderer';
|
|
25
|
+
import { includeRenderer } from '@erudit-js/bitran-elements/include/renderer';
|
|
26
|
+
import { linkRenderer } from '@erudit/shared/bitran/link/renderer';
|
|
27
|
+
|
|
28
|
+
let bitranTranspiler!: BitranTranspiler;
|
|
29
|
+
let bitranRenderers!: ElementVueRenderers;
|
|
30
|
+
|
|
31
|
+
//
|
|
32
|
+
// Transpiler
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
export async function useBitranTranspiler() {
|
|
36
|
+
if (bitranTranspiler) return bitranTranspiler;
|
|
37
|
+
|
|
38
|
+
const projectTranspilers = await getProjectTranspilers();
|
|
39
|
+
|
|
40
|
+
const defaultTranspilers = {
|
|
41
|
+
[aliasesName]: aliasesTranspiler,
|
|
42
|
+
[includeName]: includeTranspiler,
|
|
43
|
+
[headingName]: headingTranspiler,
|
|
44
|
+
[linkName]: linkTranspiler,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
bitranTranspiler = defineBitranTranspiler({
|
|
48
|
+
...projectTranspilers,
|
|
49
|
+
...defaultTranspilers,
|
|
49
50
|
});
|
|
50
51
|
|
|
51
|
-
return
|
|
52
|
-
bitranCore,
|
|
53
|
-
bitranRender,
|
|
54
|
-
};
|
|
52
|
+
return bitranTranspiler;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
async function
|
|
58
|
-
const
|
|
55
|
+
async function getProjectTranspilers(): Promise<ElementTranspilers> {
|
|
56
|
+
const bitranElements = bitranConfig.elements;
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
bitranConfig.products || {},
|
|
62
|
-
)) {
|
|
63
|
-
projectProductCores[name] = await definition.core();
|
|
64
|
-
}
|
|
58
|
+
if (!bitranElements) return {};
|
|
65
59
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
[
|
|
69
|
-
[headingName]: headingCore,
|
|
70
|
-
[linkName]: linkCore,
|
|
71
|
-
};
|
|
60
|
+
const projectTranspilers: ElementTranspilers = {};
|
|
61
|
+
for (const [name, bitranElement] of Object.entries(bitranElements))
|
|
62
|
+
projectTranspilers[name] = await bitranElement.transpiler();
|
|
72
63
|
|
|
73
|
-
return
|
|
74
|
-
...projectProductCores,
|
|
75
|
-
...eruditProductCores,
|
|
76
|
-
...defaultProductCores,
|
|
77
|
-
};
|
|
64
|
+
return projectTranspilers;
|
|
78
65
|
}
|
|
79
66
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (productRenders) return productRenders;
|
|
67
|
+
//
|
|
68
|
+
// Renderers
|
|
69
|
+
//
|
|
84
70
|
|
|
85
|
-
|
|
71
|
+
export async function useBitranRenderers() {
|
|
72
|
+
if (bitranRenderers) return bitranRenderers;
|
|
86
73
|
|
|
87
|
-
|
|
88
|
-
bitranConfig.products || {},
|
|
89
|
-
)) {
|
|
90
|
-
projectProductRenders[name] = await definition.render();
|
|
91
|
-
}
|
|
74
|
+
const projectRenderers = await getProjectRenderers();
|
|
92
75
|
|
|
93
|
-
const
|
|
94
|
-
[
|
|
95
|
-
[includeName]:
|
|
96
|
-
[headingName]:
|
|
97
|
-
[linkName]:
|
|
76
|
+
const defaultRenderers = {
|
|
77
|
+
[aliasesName]: aliasesRenderer,
|
|
78
|
+
[includeName]: includeRenderer,
|
|
79
|
+
[headingName]: headingRenderer,
|
|
80
|
+
[linkName]: linkRenderer,
|
|
98
81
|
};
|
|
99
82
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
...
|
|
103
|
-
...
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
bitranRenderers = {
|
|
85
|
+
...projectRenderers,
|
|
86
|
+
...defaultRenderers,
|
|
104
87
|
};
|
|
105
88
|
|
|
106
|
-
return
|
|
89
|
+
return bitranRenderers!;
|
|
107
90
|
}
|
|
108
91
|
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
92
|
+
async function getProjectRenderers() {
|
|
93
|
+
const bitranElements = bitranConfig.elements;
|
|
94
|
+
|
|
95
|
+
if (!bitranElements) return {};
|
|
96
|
+
|
|
97
|
+
const projectRenderers: ElementVueRenderers = {};
|
|
98
|
+
for (const [name, bitranElement] of Object.entries(bitranElements))
|
|
99
|
+
projectRenderers[name] = await bitranElement.renderer();
|
|
100
|
+
|
|
101
|
+
return projectRenderers;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//
|
|
105
|
+
// Utils
|
|
106
|
+
//
|
|
107
|
+
|
|
108
|
+
export async function useBitranElementRenderer(productName: string) {
|
|
109
|
+
const renderer =
|
|
110
|
+
(await useBitranRenderers())[productName] ||
|
|
111
|
+
getDefaultRenderers()[productName];
|
|
112
112
|
|
|
113
|
-
if (!
|
|
113
|
+
if (!renderer)
|
|
114
114
|
throw new Error(`Missing Bitran product render "${productName}"!`);
|
|
115
115
|
|
|
116
|
-
return
|
|
116
|
+
return renderer;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
export async function
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
return '<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 512 512"><path fill="currentColor" fill-rule="evenodd" d="M448 64v384H64V64zM256 271.085L121.751 405.333h268.497zM106.666 121.751v268.497L240.915 256zm298.667 0L271.085 256l134.248 134.248zm-15.085-15.085H121.751L256 240.915z"/></svg>';
|
|
119
|
+
export async function useBitranElementIcon(productName: string) {
|
|
120
|
+
const renderer = await useBitranElementRenderer(productName);
|
|
121
|
+
return await getElementIcon(renderer);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
|
-
export async function
|
|
126
|
-
const
|
|
127
|
-
return await
|
|
128
|
-
eruditConfig?.language || 'en',
|
|
129
|
-
productRender.languages,
|
|
130
|
-
`erudit:${productName}`,
|
|
131
|
-
);
|
|
124
|
+
export async function useBitranElementLanguage(productName: string) {
|
|
125
|
+
const renderer = await useBitranElementRenderer(productName);
|
|
126
|
+
return await createPhraseCaller(renderer, eruditConfig?.language || 'en');
|
|
132
127
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import eruditConfig from '#erudit/config';
|
|
2
2
|
|
|
3
|
-
import { createOgImageTags, defaultOgImage } from '
|
|
3
|
+
import { createOgImageTags, defaultOgImage } from '../../app/scripts/og';
|
|
4
4
|
import type { ContentData } from '@shared/content/data';
|
|
5
5
|
|
|
6
6
|
export function useContentPage(contentData: Ref<ContentData>) {
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
type PhraseCaller<T extends EruditPhraseId[]> = {
|
|
2
|
-
[K in T[number]]: EruditPhrases[K];
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
const payloadKey = 'language';
|
|
6
|
-
|
|
7
|
-
interface LanguagePayload {
|
|
8
|
-
strPhrases: Partial<Record<EruditPhraseId, string>>;
|
|
9
|
-
strFunctions: Record<string, string>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const functions: Record<string, Function> = {};
|
|
13
|
-
const functionPhrases: Record<string, Function> = {};
|
|
14
|
-
|
|
15
|
-
const phraseApiRoute = (phraseId: EruditPhraseId) =>
|
|
16
|
-
`/api/language/phrase/${phraseId}`;
|
|
17
|
-
const functionsApiRoute = '/api/language/functions';
|
|
18
|
-
const phraseIdsApiRoute = '/api/language/phraseIds';
|
|
19
|
-
|
|
20
|
-
export function usePhrases<T extends EruditPhraseId[]>(
|
|
21
|
-
...phraseIds: T
|
|
22
|
-
): Promise<PhraseCaller<T>> {
|
|
23
|
-
const nuxt = useNuxtApp();
|
|
24
|
-
const payload: LanguagePayload =
|
|
25
|
-
(nuxt.static.data[payloadKey] ||=
|
|
26
|
-
nuxt.payload.data[payloadKey] ||=
|
|
27
|
-
{});
|
|
28
|
-
|
|
29
|
-
const prerenderAllPromise = prerenderAllPhrases();
|
|
30
|
-
const prepareFunctionsPromise = prepareFunctions(payload);
|
|
31
|
-
|
|
32
|
-
return (async () => {
|
|
33
|
-
await prerenderAllPromise;
|
|
34
|
-
await prepareFunctionsPromise;
|
|
35
|
-
|
|
36
|
-
payload.strPhrases ||= {};
|
|
37
|
-
const phraseCaller: any = {};
|
|
38
|
-
|
|
39
|
-
for (const phraseId of phraseIds) {
|
|
40
|
-
const apiRoute = phraseApiRoute(phraseId);
|
|
41
|
-
const strPhrase = (payload.strPhrases[phraseId] ||= (await $fetch(
|
|
42
|
-
apiRoute,
|
|
43
|
-
)) as string);
|
|
44
|
-
|
|
45
|
-
if (strPhrase.startsWith('~!~FUNC~!~')) {
|
|
46
|
-
const strFunction = strPhrase.replace('~!~FUNC~!~', '');
|
|
47
|
-
functionPhrases[phraseId] ||= new Function(strFunction).bind(
|
|
48
|
-
functions,
|
|
49
|
-
)();
|
|
50
|
-
phraseCaller[phraseId] = functionPhrases[phraseId];
|
|
51
|
-
} else {
|
|
52
|
-
phraseCaller[phraseId] = strPhrase;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return phraseCaller as PhraseCaller<T>;
|
|
57
|
-
})();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
async function prerenderAllPhrases() {
|
|
61
|
-
if (import.meta.dev) return;
|
|
62
|
-
|
|
63
|
-
if (import.meta.client) return;
|
|
64
|
-
|
|
65
|
-
const nuxt = useNuxtApp();
|
|
66
|
-
|
|
67
|
-
const phraseIds = await $fetch(phraseIdsApiRoute);
|
|
68
|
-
nuxt.runWithContext(() =>
|
|
69
|
-
prerenderRoutes(phraseIds.map((phraseId) => phraseApiRoute(phraseId))),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function prepareFunctions(payload: LanguagePayload) {
|
|
74
|
-
if (payload?.strFunctions) return;
|
|
75
|
-
|
|
76
|
-
payload.strFunctions = await $fetch(functionsApiRoute);
|
|
77
|
-
|
|
78
|
-
for (const [funcName, strFunc] of Object.entries(payload.strFunctions))
|
|
79
|
-
functions[funcName] = new Function(strFunc)();
|
|
80
|
-
}
|
|
1
|
+
type PhraseCaller<T extends EruditPhraseId[]> = {
|
|
2
|
+
[K in T[number]]: EruditPhrases[K];
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const payloadKey = 'language';
|
|
6
|
+
|
|
7
|
+
interface LanguagePayload {
|
|
8
|
+
strPhrases: Partial<Record<EruditPhraseId, string>>;
|
|
9
|
+
strFunctions: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const functions: Record<string, Function> = {};
|
|
13
|
+
const functionPhrases: Record<string, Function> = {};
|
|
14
|
+
|
|
15
|
+
const phraseApiRoute = (phraseId: EruditPhraseId) =>
|
|
16
|
+
`/api/language/phrase/${phraseId}`;
|
|
17
|
+
const functionsApiRoute = '/api/language/functions';
|
|
18
|
+
const phraseIdsApiRoute = '/api/language/phraseIds';
|
|
19
|
+
|
|
20
|
+
export function usePhrases<T extends EruditPhraseId[]>(
|
|
21
|
+
...phraseIds: T
|
|
22
|
+
): Promise<PhraseCaller<T>> {
|
|
23
|
+
const nuxt = useNuxtApp();
|
|
24
|
+
const payload: LanguagePayload =
|
|
25
|
+
(nuxt.static.data[payloadKey] ||=
|
|
26
|
+
nuxt.payload.data[payloadKey] ||=
|
|
27
|
+
{});
|
|
28
|
+
|
|
29
|
+
const prerenderAllPromise = prerenderAllPhrases();
|
|
30
|
+
const prepareFunctionsPromise = prepareFunctions(payload);
|
|
31
|
+
|
|
32
|
+
return (async () => {
|
|
33
|
+
await prerenderAllPromise;
|
|
34
|
+
await prepareFunctionsPromise;
|
|
35
|
+
|
|
36
|
+
payload.strPhrases ||= {};
|
|
37
|
+
const phraseCaller: any = {};
|
|
38
|
+
|
|
39
|
+
for (const phraseId of phraseIds) {
|
|
40
|
+
const apiRoute = phraseApiRoute(phraseId);
|
|
41
|
+
const strPhrase = (payload.strPhrases[phraseId] ||= (await $fetch(
|
|
42
|
+
apiRoute,
|
|
43
|
+
)) as string);
|
|
44
|
+
|
|
45
|
+
if (strPhrase.startsWith('~!~FUNC~!~')) {
|
|
46
|
+
const strFunction = strPhrase.replace('~!~FUNC~!~', '');
|
|
47
|
+
functionPhrases[phraseId] ||= new Function(strFunction).bind(
|
|
48
|
+
functions,
|
|
49
|
+
)();
|
|
50
|
+
phraseCaller[phraseId] = functionPhrases[phraseId];
|
|
51
|
+
} else {
|
|
52
|
+
phraseCaller[phraseId] = strPhrase;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return phraseCaller as PhraseCaller<T>;
|
|
57
|
+
})();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function prerenderAllPhrases() {
|
|
61
|
+
if (import.meta.dev) return;
|
|
62
|
+
|
|
63
|
+
if (import.meta.client) return;
|
|
64
|
+
|
|
65
|
+
const nuxt = useNuxtApp();
|
|
66
|
+
|
|
67
|
+
const phraseIds = await $fetch(phraseIdsApiRoute);
|
|
68
|
+
nuxt.runWithContext(() =>
|
|
69
|
+
prerenderRoutes(phraseIds.map((phraseId) => phraseApiRoute(phraseId))),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async function prepareFunctions(payload: LanguagePayload) {
|
|
74
|
+
if (payload?.strFunctions) return;
|
|
75
|
+
|
|
76
|
+
payload.strFunctions = await $fetch(functionsApiRoute);
|
|
77
|
+
|
|
78
|
+
for (const [funcName, strFunc] of Object.entries(payload.strFunctions))
|
|
79
|
+
functions[funcName] = new Function(strFunc)();
|
|
80
|
+
}
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { PreviewDataType } from '
|
|
3
|
-
import { createPreviewError } from '
|
|
4
|
-
import { PreviewRequestType } from '
|
|
5
|
-
import {
|
|
6
|
-
PreviewThemeName,
|
|
7
|
-
showPreview,
|
|
8
|
-
togglePreview,
|
|
9
|
-
} from '
|
|
10
|
-
|
|
11
|
-
function showCustom() {
|
|
12
|
-
showPreview({
|
|
13
|
-
type: PreviewRequestType.Data,
|
|
14
|
-
data: {
|
|
15
|
-
type: PreviewDataType.Custom,
|
|
16
|
-
message: 'This is custom message for preview!',
|
|
17
|
-
footer: {
|
|
18
|
-
//iconName: 'arrow-left',
|
|
19
|
-
iconSvg:
|
|
20
|
-
'<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M6.42436 0H9.57565L14.995 16H11.8276L10.8115 13H5.18855L4.17242 16H1.005L6.42436 0ZM6.20468 10H9.79533L8 4.69952L6.20468 10Z"></path> </g></svg>',
|
|
21
|
-
secondary: 'Secondary raw text',
|
|
22
|
-
primary: 'Primary raw text',
|
|
23
|
-
href: 'https://google.com',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function showAlert(theme: PreviewThemeName) {
|
|
30
|
-
showPreview({
|
|
31
|
-
type: PreviewRequestType.Data,
|
|
32
|
-
data: createPreviewError({
|
|
33
|
-
theme,
|
|
34
|
-
message: 'This is message!',
|
|
35
|
-
title: 'Custom Title',
|
|
36
|
-
pre: JSON.stringify(
|
|
37
|
-
{
|
|
38
|
-
foo: 1337,
|
|
39
|
-
bar: 'Some text',
|
|
40
|
-
},
|
|
41
|
-
null,
|
|
42
|
-
4,
|
|
43
|
-
),
|
|
44
|
-
}),
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
</script>
|
|
48
|
-
|
|
49
|
-
<template>
|
|
50
|
-
<button @click="() => togglePreview()">Toggle Preview</button>
|
|
51
|
-
<div>
|
|
52
|
-
Show:
|
|
53
|
-
<br />
|
|
54
|
-
<button :class="$style.button" @click="showCustom">Custom</button>
|
|
55
|
-
<br />
|
|
56
|
-
<button
|
|
57
|
-
:class="$style.button"
|
|
58
|
-
v-for="theme in PreviewThemeName"
|
|
59
|
-
@click="() => showAlert(theme)"
|
|
60
|
-
>
|
|
61
|
-
Alert {{ theme }}
|
|
62
|
-
</button>
|
|
63
|
-
<br />
|
|
64
|
-
<button
|
|
65
|
-
:class="$style.button"
|
|
66
|
-
@click="
|
|
67
|
-
showPreview({
|
|
68
|
-
type: PreviewRequestType.MissingElement,
|
|
69
|
-
elementId: 'foo-id',
|
|
70
|
-
})
|
|
71
|
-
"
|
|
72
|
-
>
|
|
73
|
-
Missing element
|
|
74
|
-
</button>
|
|
75
|
-
<button
|
|
76
|
-
:class="$style.button"
|
|
77
|
-
@click="
|
|
78
|
-
showPreview({
|
|
79
|
-
type: PreviewRequestType.MissingElement,
|
|
80
|
-
elementId: 'foo-id',
|
|
81
|
-
hashMismatch: { current: 'bar', expected: 'baz' },
|
|
82
|
-
})
|
|
83
|
-
"
|
|
84
|
-
>
|
|
85
|
-
Missing element + hash mismatch
|
|
86
|
-
</button>
|
|
87
|
-
<br />
|
|
88
|
-
<button
|
|
89
|
-
:class="$style.button"
|
|
90
|
-
@click="
|
|
91
|
-
showPreview({
|
|
92
|
-
type: PreviewRequestType.HashMismatch,
|
|
93
|
-
currentHash: 'foo',
|
|
94
|
-
expectedHash: 'bar',
|
|
95
|
-
})
|
|
96
|
-
"
|
|
97
|
-
>
|
|
98
|
-
Hash mismatch
|
|
99
|
-
</button>
|
|
100
|
-
</div>
|
|
101
|
-
</template>
|
|
102
|
-
|
|
103
|
-
<style lang="scss" module>
|
|
104
|
-
.button {
|
|
105
|
-
border: 2px solid var(--border);
|
|
106
|
-
border-radius: 3px;
|
|
107
|
-
padding: 3px;
|
|
108
|
-
margin: 3px;
|
|
109
|
-
}
|
|
110
|
-
</style>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { PreviewDataType } from '../../../app/scripts/preview/data';
|
|
3
|
+
import { createPreviewError } from '../../../app/scripts/preview/data/alert';
|
|
4
|
+
import { PreviewRequestType } from '../../../app/scripts/preview/request';
|
|
5
|
+
import {
|
|
6
|
+
PreviewThemeName,
|
|
7
|
+
showPreview,
|
|
8
|
+
togglePreview,
|
|
9
|
+
} from '../../../app/scripts/preview/state';
|
|
10
|
+
|
|
11
|
+
function showCustom() {
|
|
12
|
+
showPreview({
|
|
13
|
+
type: PreviewRequestType.Data,
|
|
14
|
+
data: {
|
|
15
|
+
type: PreviewDataType.Custom,
|
|
16
|
+
message: 'This is custom message for preview!',
|
|
17
|
+
footer: {
|
|
18
|
+
//iconName: 'arrow-left',
|
|
19
|
+
iconSvg:
|
|
20
|
+
'<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path fill-rule="evenodd" clip-rule="evenodd" d="M6.42436 0H9.57565L14.995 16H11.8276L10.8115 13H5.18855L4.17242 16H1.005L6.42436 0ZM6.20468 10H9.79533L8 4.69952L6.20468 10Z"></path> </g></svg>',
|
|
21
|
+
secondary: 'Secondary raw text',
|
|
22
|
+
primary: 'Primary raw text',
|
|
23
|
+
href: 'https://google.com',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function showAlert(theme: PreviewThemeName) {
|
|
30
|
+
showPreview({
|
|
31
|
+
type: PreviewRequestType.Data,
|
|
32
|
+
data: createPreviewError({
|
|
33
|
+
theme,
|
|
34
|
+
message: 'This is message!',
|
|
35
|
+
title: 'Custom Title',
|
|
36
|
+
pre: JSON.stringify(
|
|
37
|
+
{
|
|
38
|
+
foo: 1337,
|
|
39
|
+
bar: 'Some text',
|
|
40
|
+
},
|
|
41
|
+
null,
|
|
42
|
+
4,
|
|
43
|
+
),
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<button @click="() => togglePreview()">Toggle Preview</button>
|
|
51
|
+
<div>
|
|
52
|
+
Show:
|
|
53
|
+
<br />
|
|
54
|
+
<button :class="$style.button" @click="showCustom">Custom</button>
|
|
55
|
+
<br />
|
|
56
|
+
<button
|
|
57
|
+
:class="$style.button"
|
|
58
|
+
v-for="theme in PreviewThemeName"
|
|
59
|
+
@click="() => showAlert(theme)"
|
|
60
|
+
>
|
|
61
|
+
Alert {{ theme }}
|
|
62
|
+
</button>
|
|
63
|
+
<br />
|
|
64
|
+
<button
|
|
65
|
+
:class="$style.button"
|
|
66
|
+
@click="
|
|
67
|
+
showPreview({
|
|
68
|
+
type: PreviewRequestType.MissingElement,
|
|
69
|
+
elementId: 'foo-id',
|
|
70
|
+
})
|
|
71
|
+
"
|
|
72
|
+
>
|
|
73
|
+
Missing element
|
|
74
|
+
</button>
|
|
75
|
+
<button
|
|
76
|
+
:class="$style.button"
|
|
77
|
+
@click="
|
|
78
|
+
showPreview({
|
|
79
|
+
type: PreviewRequestType.MissingElement,
|
|
80
|
+
elementId: 'foo-id',
|
|
81
|
+
hashMismatch: { current: 'bar', expected: 'baz' },
|
|
82
|
+
})
|
|
83
|
+
"
|
|
84
|
+
>
|
|
85
|
+
Missing element + hash mismatch
|
|
86
|
+
</button>
|
|
87
|
+
<br />
|
|
88
|
+
<button
|
|
89
|
+
:class="$style.button"
|
|
90
|
+
@click="
|
|
91
|
+
showPreview({
|
|
92
|
+
type: PreviewRequestType.HashMismatch,
|
|
93
|
+
currentHash: 'foo',
|
|
94
|
+
expectedHash: 'bar',
|
|
95
|
+
})
|
|
96
|
+
"
|
|
97
|
+
>
|
|
98
|
+
Hash mismatch
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
102
|
+
|
|
103
|
+
<style lang="scss" module>
|
|
104
|
+
.button {
|
|
105
|
+
border: 2px solid var(--border);
|
|
106
|
+
border-radius: 3px;
|
|
107
|
+
padding: 3px;
|
|
108
|
+
margin: 3px;
|
|
109
|
+
}
|
|
110
|
+
</style>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<MainTopic />
|
|
1
|
+
<template>
|
|
2
|
+
<MainTopic />
|
|
3
3
|
</template>
|