erudit 3.0.0-dev.5 → 3.0.0-dev.7

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.
Files changed (81) hide show
  1. package/app/app.vue +1 -1
  2. package/app/components/SiteMain.vue +2 -3
  3. package/app/components/aside/major/panes/nav/fnav/FNavFlags.vue +1 -1
  4. package/app/components/aside/minor/topic/TopicNav.vue +1 -1
  5. package/app/components/aside/minor/topic/TopicToc.vue +1 -1
  6. package/app/components/bitran/BitranContent.vue +10 -3
  7. package/app/components/main/topic/MainTopic.vue +1 -2
  8. package/app/components/main/topic/TopicPartSwitch.vue +1 -1
  9. package/app/components/main/utils/Breadcrumb.vue +1 -6
  10. package/app/components/main/utils/ContentPopovers.vue +12 -6
  11. package/app/components/preview/display/Unique.vue +7 -1
  12. package/app/composables/bitran.ts +37 -33
  13. package/app/composables/bitranContent.ts +16 -4
  14. package/app/composables/bitranLocation.ts +1 -1
  15. package/app/composables/contentRoute.ts +1 -1
  16. package/app/composables/externalApi.ts +1 -1
  17. package/app/pages/group/[...groupId].vue +3 -4
  18. package/app/public/favicon/article.svg +9 -9
  19. package/app/scripts/flag.ts +1 -1
  20. package/app/scripts/preview/data/unique.ts +6 -5
  21. package/bin/erudit.mjs +2 -0
  22. package/globalPath.ts +1 -1
  23. package/globals/bitran.ts +1 -1
  24. package/globals/content.ts +1 -1
  25. package/globals/contributor.ts +1 -1
  26. package/globals/erudit.ts +1 -1
  27. package/module/bitran.ts +2 -2
  28. package/module/config.ts +2 -2
  29. package/module/index.ts +4 -5
  30. package/module/logger.ts +1 -1
  31. package/nuxt.config.ts +1 -40
  32. package/package.json +14 -7
  33. package/server/api/aside/major/nav/global.ts +1 -1
  34. package/server/api/aside/minor/path.ts +1 -2
  35. package/server/api/preview/page/[...parts].ts +3 -2
  36. package/server/api/preview/unique/[location].ts +6 -3
  37. package/server/plugin/bitran/content.ts +49 -42
  38. package/server/plugin/bitran/location.ts +1 -1
  39. package/server/plugin/bitran/products/include.ts +13 -15
  40. package/server/plugin/bitran/products/link.ts +12 -12
  41. package/server/plugin/bitran/toc.ts +21 -29
  42. package/server/plugin/bitran/transpiler.ts +15 -19
  43. package/server/plugin/build/jobs/content/generic.ts +2 -2
  44. package/server/plugin/build/jobs/content/parse.ts +19 -10
  45. package/server/plugin/build/jobs/content/type/group.ts +1 -1
  46. package/server/plugin/build/jobs/content/type/topic.ts +1 -1
  47. package/server/plugin/build/jobs/contributors.ts +2 -2
  48. package/server/plugin/build/jobs/nav.ts +6 -2
  49. package/server/plugin/build/setup.ts +1 -0
  50. package/server/plugin/content/absoluteId.ts +2 -2
  51. package/server/plugin/content/context.ts +6 -2
  52. package/server/plugin/db/entities/Content.ts +1 -1
  53. package/server/plugin/db/entities/Group.ts +1 -1
  54. package/server/plugin/db/entities/Topic.ts +1 -1
  55. package/server/plugin/global.ts +1 -1
  56. package/server/plugin/logger.ts +1 -1
  57. package/server/plugin/nav/node.ts +1 -1
  58. package/server/plugin/repository/content.ts +1 -1
  59. package/server/plugin/repository/topic.ts +1 -1
  60. package/shared/aside/minor.ts +2 -1
  61. package/shared/bitran/stringContent.ts +6 -0
  62. package/shared/content/data/base.ts +1 -1
  63. package/shared/content/data/type/topic.ts +1 -1
  64. package/shared/frontNav.ts +1 -1
  65. package/shared/icons.ts +2 -2
  66. package/shared/link.ts +5 -2
  67. package/tsconfig.json +1 -1
  68. package/shared/bitran/context.ts +0 -8
  69. package/shared/bitran/default.ts +0 -46
  70. package/shared/bitran/link/Link.vue +0 -166
  71. package/shared/bitran/link/factory.ts +0 -24
  72. package/shared/bitran/link/icon.svg +0 -3
  73. package/shared/bitran/link/languages/en.ts +0 -7
  74. package/shared/bitran/link/languages/ru.ts +0 -7
  75. package/shared/bitran/link/renderer.ts +0 -21
  76. package/shared/bitran/link/shared.ts +0 -17
  77. package/shared/bitran/link/target.ts +0 -134
  78. package/shared/bitran/link/transpiler.ts +0 -10
  79. package/shared/bitran/location.ts +0 -166
  80. package/test/bitran/link/target.test.ts +0 -141
  81. package/test/bitran/location.test.ts +0 -143
@@ -4,7 +4,7 @@ import type {
4
4
  ContentReferences,
5
5
  ContentSeo,
6
6
  ContentType,
7
- } from 'erudit-cog/schema';
7
+ } from '@erudit-js/cog/schema';
8
8
 
9
9
  import type { ImageData } from '@erudit/shared/image';
10
10
 
@@ -1,5 +1,5 @@
1
1
  import { Column, Entity, PrimaryColumn } from 'typeorm';
2
- import type { GroupType } from 'erudit-cog/schema';
2
+ import type { GroupType } from '@erudit-js/cog/schema';
3
3
 
4
4
  @Entity('group')
5
5
  export class DbGroup {
@@ -1,5 +1,5 @@
1
1
  import { Column, Entity, PrimaryColumn } from 'typeorm';
2
- import type { TopicPart } from 'erudit-cog/schema';
2
+ import type { TopicPart } from '@erudit-js/cog/schema';
3
3
 
4
4
  @Entity('topic')
5
5
  export class DbTopic {
@@ -1,5 +1,5 @@
1
1
  import type { DataSource } from 'typeorm';
2
- import type { EruditBitranConfig, EruditConfig } from 'erudit-cog/schema';
2
+ import type { EruditBitranConfig, EruditConfig } from '@erudit-js/cog/schema';
3
3
 
4
4
  import type { EruditPhrases } from '@shared/types/language';
5
5
  import type { NavNode, RootNavNode } from '@server/nav/node';
@@ -1,6 +1,6 @@
1
1
  import chalk from 'chalk';
2
2
  import { createConsola } from 'consola';
3
- import { brandColorTitle } from 'erudit-cog/utils/brandNode';
3
+ import { brandColorTitle } from '@erudit-js/cog/utils/brandNode';
4
4
 
5
5
  import eruditConfig from '#erudit/config';
6
6
 
@@ -1,4 +1,4 @@
1
- import type { ContentType } from 'erudit-cog/schema';
1
+ import type { ContentType } from '@erudit-js/cog/schema';
2
2
 
3
3
  export interface NavNode {
4
4
  type: ContentType;
@@ -1,4 +1,4 @@
1
- import type { ContentType } from 'erudit-cog/schema';
1
+ import type { ContentType } from '@erudit-js/cog/schema';
2
2
  import { Like } from 'typeorm';
3
3
 
4
4
  import { ERUDIT_SERVER } from '@server/global';
@@ -1,4 +1,4 @@
1
- import type { TopicPart } from 'erudit-cog/schema';
1
+ import type { TopicPart } from '@erudit-js/cog/schema';
2
2
 
3
3
  import { ERUDIT_SERVER } from '@server/global';
4
4
  import { DbTopic } from '@server/db/entities/Topic';
@@ -1,4 +1,5 @@
1
- import type { BitranLocation } from '../bitran/location';
1
+ import type { BitranLocation } from '@erudit-js/cog/schema';
2
+
2
3
  import type { Toc } from '../bitran/toc';
3
4
  import type { PreviousNextItem } from '../content/previousNext';
4
5
  import type { ContentContributor } from '../contributor';
@@ -0,0 +1,6 @@
1
+ import type { PreRenderData } from '@bitran-js/transpiler';
2
+
3
+ export interface StringBitranContent {
4
+ biCode: string;
5
+ preRenderData?: Record<string, PreRenderData>;
6
+ }
@@ -4,7 +4,7 @@ import type {
4
4
  ContentSeo,
5
5
  ContentType,
6
6
  TopicPart,
7
- } from 'erudit-cog/schema';
7
+ } from '@erudit-js/cog/schema';
8
8
 
9
9
  import type { Context } from '@shared/content/context';
10
10
  import type { PreviousNext } from '@shared/content/previousNext';
@@ -1,4 +1,4 @@
1
- import type { TopicPart } from 'erudit-cog/schema';
1
+ import type { TopicPart } from '@erudit-js/cog/schema';
2
2
 
3
3
  import type { ContentBaseData } from '../base';
4
4
 
@@ -1,4 +1,4 @@
1
- import type { ContentFlag, TopicPart } from 'erudit-cog/schema';
1
+ import type { ContentFlag, TopicPart } from '@erudit-js/cog/schema';
2
2
 
3
3
  export type FrontNavType = 'book' | 'topic' | 'separator' | 'folder';
4
4
 
package/shared/icons.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  isContentType,
3
3
  isTopicPart,
4
+ type BitranLocation,
4
5
  type ContentType,
5
6
  type TopicPart,
6
- } from 'erudit-cog/schema';
7
+ } from '@erudit-js/cog/schema';
7
8
 
8
9
  import type { MyIconName } from '#my-icons';
9
- import type { BitranLocation } from './bitran/location';
10
10
 
11
11
  export const TOPIC_PART_ICON = {
12
12
  article: 'outline/file-lines',
package/shared/link.ts CHANGED
@@ -1,5 +1,8 @@
1
- import type { ContentType, TopicPart } from 'erudit-cog/schema';
2
- import type { BitranLocation } from './bitran/location';
1
+ import type {
2
+ BitranLocation,
3
+ ContentType,
4
+ TopicPart,
5
+ } from '@erudit-js/cog/schema';
3
6
 
4
7
  export function createBitranLocationLink(location: BitranLocation) {
5
8
  let link = `/${location.type}/${location.path}`;
package/tsconfig.json CHANGED
@@ -3,6 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "experimentalDecorators": true,
5
5
  "emitDecoratorMetadata": true,
6
- "types": ["@types/jest"]
6
+ "types": ["@types/jest", "@erudit-js/cog/types"]
7
7
  }
8
8
  }
@@ -1,8 +0,0 @@
1
- import { type Aliases } from '@erudit-js/bitran-elements/aliases/shared';
2
-
3
- import type { BitranLocation } from './location';
4
-
5
- export interface BitranContext {
6
- location: BitranLocation;
7
- aliases: Aliases;
8
- }
@@ -1,46 +0,0 @@
1
- import {
2
- defineBitranElement,
3
- type BitranElements,
4
- } from '@erudit/globals/bitran';
5
-
6
- // Erudit Default Elements
7
- import {
8
- aliasesName,
9
- type AliasesSchema,
10
- } from '@erudit-js/bitran-elements/aliases/shared';
11
- import { aliasesTranspiler } from '@erudit-js/bitran-elements/aliases/transpiler';
12
- import { aliasesRenderer } from '@erudit-js/bitran-elements/aliases/renderer';
13
- import {
14
- includeName,
15
- type IncludeSchema,
16
- } from '@erudit-js/bitran-elements/include/shared';
17
- import { includeTranspiler } from '@erudit-js/bitran-elements/include/transpiler';
18
- import { includeRenderer } from '@erudit-js/bitran-elements/include/renderer';
19
- import {
20
- headingName,
21
- type HeadingSchema,
22
- } from '@erudit-js/bitran-elements/heading/shared';
23
- import { headingTranspiler } from '@erudit-js/bitran-elements/heading/transpiler';
24
- import { headingRenderer } from '@erudit-js/bitran-elements/heading/renderer';
25
- import { linkName, type LinkSchema } from '@erudit/shared/bitran/link/shared';
26
- import { linkTranspiler } from '@erudit/shared/bitran/link/transpiler';
27
- import { linkRenderer } from '@erudit/shared/bitran/link/renderer';
28
-
29
- export const defaultElements: BitranElements = {
30
- [aliasesName]: defineBitranElement<AliasesSchema>({
31
- transpiler: async () => aliasesTranspiler,
32
- renderer: async () => aliasesRenderer,
33
- }),
34
- [includeName]: defineBitranElement<IncludeSchema>({
35
- transpiler: async () => includeTranspiler,
36
- renderer: async () => includeRenderer,
37
- }),
38
- [headingName]: defineBitranElement<HeadingSchema>({
39
- transpiler: async () => headingTranspiler,
40
- renderer: async () => headingRenderer,
41
- }),
42
- [linkName]: defineBitranElement<LinkSchema>({
43
- transpiler: async () => linkTranspiler,
44
- renderer: async () => linkRenderer,
45
- }),
46
- };
@@ -1,166 +0,0 @@
1
- <script lang="ts" setup>
2
- import type { ElementProps } from '@bitran-js/renderer-vue';
3
- import { isContentType, isTopicPart } from 'erudit-cog/schema';
4
-
5
- import { CONTENT_TYPE_ICON, ICON, TOPIC_PART_ICON } from '@erudit/shared/icons';
6
- import type { LinkSchema } from './shared';
7
- import { MyIcon, MyRuntimeIcon } from '#components';
8
- import { showPreview, togglePreview } from '@erudit/app/scripts/preview/state';
9
- import { PreviewRequestType } from '@erudit/app/scripts/preview/request';
10
- import { encodeBitranLocation } from '@erudit/shared/bitran/location';
11
-
12
- const { node } = defineProps<ElementProps<LinkSchema>>();
13
- const { label } = node.parseData;
14
- const linkTarget = node.renderData;
15
-
16
- const baseUrlPath = useBaseUrlPath();
17
- const formatText = useFormatText();
18
-
19
- const Icon = await (async () => {
20
- const type = linkTarget.type;
21
-
22
- if (type === 'unique') {
23
- return h(MyRuntimeIcon, {
24
- name: 'link-icon',
25
- svg: await useBitranElementIcon(linkTarget._productName!),
26
- });
27
- } else if (type === 'absolute') {
28
- return h(MyIcon, { name: 'link' });
29
- } else if (type === 'external') {
30
- return h(MyIcon, { name: 'link-external' });
31
- } else if (type === 'page') {
32
- const pageType = linkTarget.pageType;
33
-
34
- if (isTopicPart(pageType))
35
- return h(MyIcon, { name: TOPIC_PART_ICON[pageType] });
36
- if (isContentType(pageType))
37
- return h(MyIcon, { name: CONTENT_TYPE_ICON[pageType] });
38
-
39
- switch (pageType) {
40
- case 'contributor':
41
- return h(MyIcon, { name: ICON.contributor });
42
- }
43
-
44
- return h(MyIcon, { name: 'link' });
45
- }
46
- })();
47
-
48
- const href = (() => {
49
- switch (linkTarget.type) {
50
- case 'absolute':
51
- case 'external':
52
- return linkTarget.href;
53
- case 'page':
54
- case 'unique':
55
- return linkTarget._href!;
56
- }
57
- })();
58
-
59
- // Prerendering data for previews to work after site build
60
- switch (linkTarget.type) {
61
- case 'page':
62
- prerenderRoutes(`/api/preview/page${linkTarget._href}`);
63
- break;
64
- case 'unique':
65
- prerenderRoutes(
66
- `/api/preview/unique/${encodeBitranLocation(linkTarget._absoluteStrLocation!)}`,
67
- );
68
- break;
69
- }
70
-
71
- const doubleClick = {
72
- timeout: null as any,
73
- startTimeout() {
74
- this.timeout = setTimeout(() => {
75
- this.reset();
76
- }, 400);
77
- },
78
- reset() {
79
- clearTimeout(this.timeout);
80
- this.timeout = null;
81
- },
82
- };
83
-
84
- function linkClick(e: Event) {
85
- // Direct link traversal is disabled, use double click instead!
86
-
87
- e.stopPropagation();
88
- e.preventDefault();
89
-
90
- if (doubleClick.timeout) {
91
- doubleClick.reset();
92
- togglePreview(false);
93
- window.open(baseUrlPath(href), '_blank');
94
- return false;
95
- }
96
-
97
- showPreview({
98
- type: PreviewRequestType.Link,
99
- linkData: node.parseData,
100
- linkTarget,
101
- });
102
-
103
- doubleClick.startTimeout();
104
-
105
- return false;
106
- }
107
- </script>
108
-
109
- <template>
110
- <a
111
- :href="baseUrlPath(href)"
112
- :class="$style.link"
113
- @click="linkClick"
114
- :external="true"
115
- >
116
- <Icon :class="$style.icon" wrapper="span" />
117
- <span :class="$style.label">{{ formatText(label) }}</span>
118
- </a>
119
- </template>
120
-
121
- <style lang="scss" module>
122
- .link {
123
- --linkColor: var(--brand); //light-dark(#3e66a1, #77a0db);
124
-
125
- display: inline-flex;
126
- align-items: center;
127
- gap: 3px;
128
-
129
- position: relative;
130
- top: 1px;
131
-
132
- padding: 0 3px;
133
-
134
- color: var(--linkColor);
135
- text-decoration-thickness: 2px;
136
- text-decoration-style: solid;
137
- text-decoration-color: color-mix(
138
- in srgb,
139
- var(--linkColor),
140
- transparent 75%
141
- );
142
-
143
- border-radius: 5px;
144
-
145
- @include transition(background);
146
-
147
- &:hover,
148
- &:active {
149
- background: color-mix(in srgb, var(--linkColor), transparent 87.5%);
150
- }
151
-
152
- .icon {
153
- flex-shrink: 0;
154
- position: relative;
155
- top: 1px;
156
- font-size: 0.86em;
157
-
158
- text-decoration: none;
159
- color: color-mix(in srgb, var(--linkColor), transparent 10%);
160
- }
161
-
162
- .label {
163
- font-weight: 450;
164
- }
165
- }
166
- </style>
@@ -1,24 +0,0 @@
1
- import {
2
- RegexpInlinerParseFactory,
3
- StringifyFactory,
4
- } from '@bitran-js/transpiler';
5
-
6
- import type { LinkSchema } from './shared';
7
-
8
- export class LinkParser extends RegexpInlinerParseFactory<LinkSchema> {
9
- regexp = /\[(.+?)\]\((.+?)\)/gm;
10
-
11
- override async parseDataFromRegexp(match: RegExpExecArray) {
12
- return {
13
- label: match[1]!,
14
- target: match[2]!,
15
- };
16
- }
17
- }
18
-
19
- export class LinkStringifier extends StringifyFactory<LinkSchema> {
20
- override async stringifyElement(): Promise<string> {
21
- const { parseData } = this.payload();
22
- return `[${parseData.label}](${parseData.target})`;
23
- }
24
- }
@@ -1,3 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512">
2
- <path d="M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z" />
3
- </svg>
@@ -1,7 +0,0 @@
1
- import { defineLanguage } from '@bitran-js/renderer-vue';
2
-
3
- const english = defineLanguage({
4
- _element_title: 'Link',
5
- });
6
-
7
- export default english;
@@ -1,7 +0,0 @@
1
- import { defineLanguage } from '@bitran-js/renderer-vue';
2
-
3
- const russian = defineLanguage({
4
- _element_title: 'Ссылка',
5
- });
6
-
7
- export default russian;
@@ -1,21 +0,0 @@
1
- import {
2
- defineElementVueRenderer,
3
- defineComponent,
4
- defineIcon,
5
- defineLanguages,
6
- } from '@bitran-js/renderer-vue';
7
-
8
- import { LinkNode, type LinkSchema } from './shared';
9
-
10
- export const linkRenderer = defineElementVueRenderer<LinkSchema>({
11
- Node: LinkNode,
12
- component: defineComponent(() => import('./Link.vue')),
13
- icon: defineIcon(() => import('./icon.svg?raw')),
14
- languages: defineLanguages({
15
- en: () => import('./languages/en'),
16
- ru: () => import('./languages/ru'),
17
- }),
18
- createRenderData: async () => {
19
- throw Error('Render data for Links must be built only on server side!');
20
- },
21
- });
@@ -1,17 +0,0 @@
1
- import { InlinerNode, type DefineElementSchema } from '@bitran-js/core';
2
-
3
- import type { LinkTarget } from './target';
4
-
5
- export const linkName = 'link';
6
-
7
- export interface LinkParseData {
8
- target: string;
9
- label: string;
10
- }
11
-
12
- export type LinkSchema = DefineElementSchema<{
13
- ParseData: LinkParseData;
14
- RenderData: LinkTarget;
15
- }>;
16
-
17
- export class LinkNode extends InlinerNode<LinkSchema> {}
@@ -1,134 +0,0 @@
1
- import { isTopicPart } from 'erudit-cog/schema';
2
- import { tryReplaceAlias } from '@erudit-js/bitran-elements/aliases/shared';
3
-
4
- import type { BitranContext } from '@shared/bitran/context';
5
- import {
6
- bitranLocationTypes,
7
- parsePartialBitranLocation,
8
- stringifyBitranLocation,
9
- } from '@shared/bitran/location';
10
-
11
- export type LinkTargetType = 'unique' | 'page' | 'absolute' | 'external';
12
-
13
- interface LinkTargetBase {
14
- type: LinkTargetType;
15
- }
16
-
17
- export interface UniqueLinkTarget extends LinkTargetBase {
18
- type: 'unique';
19
- strlocation: string;
20
- _productName?: string;
21
- _absoluteStrLocation?: string;
22
- _href?: string;
23
- }
24
-
25
- export const linkTargetPageTypes = {
26
- ...bitranLocationTypes,
27
- // Custom page types, that does not have Bitran content
28
- book: true,
29
- };
30
-
31
- export type LinkTargetPageType = keyof typeof linkTargetPageTypes;
32
-
33
- export function isLinkTargetPageType(
34
- pageType: any,
35
- ): pageType is LinkTargetPageType {
36
- return pageType in linkTargetPageTypes;
37
- }
38
-
39
- function pageTypeRequiresPath(type: LinkTargetPageType) {
40
- return linkTargetPageTypes[type];
41
- }
42
-
43
- export interface PageLinkTarget extends LinkTargetBase {
44
- type: 'page';
45
- pageType: LinkTargetPageType;
46
- path?: string;
47
- _href?: string;
48
- }
49
-
50
- export interface AbsoluteLinkTarget extends LinkTargetBase {
51
- type: 'absolute';
52
- href: string;
53
- }
54
-
55
- export interface ExternalLinkTarget extends LinkTargetBase {
56
- type: 'external';
57
- href: string;
58
- }
59
-
60
- export type LinkTarget =
61
- | UniqueLinkTarget
62
- | PageLinkTarget
63
- | AbsoluteLinkTarget
64
- | ExternalLinkTarget;
65
-
66
- export function createLinkTarget(
67
- target: string,
68
- context: BitranContext,
69
- ): LinkTarget {
70
- target = tryReplaceAlias(target, context.aliases);
71
-
72
- if (target.startsWith('/'))
73
- return {
74
- type: 'absolute',
75
- href: target,
76
- };
77
-
78
- try {
79
- new URL(target);
80
- return {
81
- type: 'external',
82
- href: target,
83
- };
84
- } catch {}
85
-
86
- if (target.startsWith('page|')) {
87
- let [, pageType, path] = target.split('|');
88
-
89
- if (!isLinkTargetPageType(pageType))
90
- throw new Error(
91
- `Unknown page type "${pageType}" in link "${target}"!`,
92
- );
93
-
94
- if (!path) {
95
- if (isTopicPart(pageType)) {
96
- if (!isTopicPart(context.location.type))
97
- throw new Error(
98
- `Page link "${target}" is referencing topic part "${pageType}" without path in non-topic context!`,
99
- );
100
-
101
- path = context.location.path;
102
- } else {
103
- if (pageTypeRequiresPath(pageType))
104
- throw new Error(
105
- `Page link "${target}" does not have a path!`,
106
- );
107
- }
108
- }
109
-
110
- return {
111
- type: 'page',
112
- pageType,
113
- path,
114
- };
115
- }
116
-
117
- const location = parsePartialBitranLocation(target, context.location);
118
-
119
- if (
120
- !location.unique &&
121
- isLinkTargetPageType(location.type) &&
122
- !isTopicPart(location.type)
123
- )
124
- return {
125
- type: 'page',
126
- pageType: location.type,
127
- path: location.path,
128
- };
129
-
130
- return {
131
- type: 'unique',
132
- strlocation: stringifyBitranLocation(location),
133
- };
134
- }
@@ -1,10 +0,0 @@
1
- import { defineElementTranspiler } from '@bitran-js/transpiler';
2
-
3
- import { LinkNode, type LinkSchema } from './shared';
4
- import { LinkParser, LinkStringifier } from './factory';
5
-
6
- export const linkTranspiler = defineElementTranspiler<LinkSchema>({
7
- Node: LinkNode,
8
- Parsers: [LinkParser],
9
- Stringifier: LinkStringifier,
10
- });