@lexibase/rdx-core 3.3.0 → 3.5.0

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.
@@ -1,5 +1,5 @@
1
- import { D as DocumentLinkOptions } from '../document-links-BQXyBubK.js';
2
- export { r as remarkDocumentLinks } from '../document-links-BQXyBubK.js';
1
+ import { D as DocumentLinkOptions } from '../document-links-CuuelWKE.js';
2
+ export { r as remarkDocumentLinks } from '../document-links-CuuelWKE.js';
3
3
  export { default as rehypeDocumentationHeadings } from 'rehype-slug';
4
4
  import rehypeShiki from '@shikijs/rehype';
5
5
  import { RdxProject, RDXConfig } from '@lexibase/rdx-types';
package/dist/mdx/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  remarkDocumentLinks
3
- } from "../chunk-GR2GL7HT.js";
3
+ } from "../chunk-KRVOWYZS.js";
4
4
  import {
5
5
  remarkDocumentationComponents
6
6
  } from "../chunk-6WNFE2QG.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexibase/rdx-core",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "description": "Content indexing and document utilities for RDX documentation projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,7 +56,7 @@
56
56
  "remark-stringify": "^11.0.0",
57
57
  "shiki": "^4.5.0",
58
58
  "unified": "^11.0.5",
59
- "@lexibase/rdx-types": "2.7.0"
59
+ "@lexibase/rdx-types": "2.8.0"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/node": "^22.15.3",
@@ -1,75 +0,0 @@
1
- // src/project/localization.ts
2
- import path from "path";
3
- function getLocalizedProject(project, locale) {
4
- const selected = project.localization?.locales.find(
5
- (entry) => entry.path === locale
6
- );
7
- if (!selected) throw new Error(`Unknown documentation language: ${locale}`);
8
- return {
9
- ...project,
10
- locale: selected,
11
- config: { ...project.config, lang: selected.code },
12
- sources: project.sources.map((source) => {
13
- const primary = source.localization?.docs[project.localization.defaultLocale] ?? source.fallbackDocsDir ?? source.docsDir;
14
- const translated = source.localization?.docs[selected.code] ?? (!source.localization && !source.version && selected.folder ? `locale/${selected.folder}/docs` : void 0);
15
- const isPrimary = selected.code === project.localization.defaultLocale;
16
- return {
17
- ...source,
18
- docsDir: isPrimary ? primary : translated ?? primary,
19
- fallbackDocsDir: isPrimary ? void 0 : primary,
20
- fallbackOnly: !isPrimary && !translated,
21
- basePath: `/${selected.path}/docs`
22
- };
23
- })
24
- };
25
- }
26
- function getContentSources(project) {
27
- return project.localization && !project.locale ? project.localization.locales.flatMap(
28
- (locale) => getLocalizedProject(project, locale.path).sources
29
- ) : project.sources;
30
- }
31
- function getDocsHref(project, source = project.sources[0], slug = "") {
32
- const base = source.basePath ?? (project.localization ? `/${project.localization.locales.find((entry) => entry.code === project.localization.defaultLocale).path}/docs` : "/docs");
33
- return [
34
- base,
35
- source.routePrefix,
36
- ...slug.split("/").filter(Boolean).map(encodeURIComponent)
37
- ].filter(Boolean).join("/");
38
- }
39
- function getLanguageLinks(project, source, slug = "") {
40
- if (!project.localization) return [];
41
- const visible = new Set(
42
- (project.sources[0]?.localization?.locales ?? project.localization.locales).map((locale) => locale.code)
43
- );
44
- for (const locale of source.localization?.locales ?? [])
45
- visible.add(locale.code);
46
- if (project.locale) visible.add(project.locale.code);
47
- return project.localization.locales.filter((locale) => visible.has(locale.code)).map((locale) => {
48
- const view = getLocalizedProject(project, locale.path);
49
- return {
50
- code: locale.code,
51
- label: source.localization?.locales.find(
52
- (entry) => entry.code === locale.code
53
- )?.label ?? locale.label,
54
- href: getDocsHref(
55
- view,
56
- view.sources.find((entry) => entry.id === source.id),
57
- slug
58
- )
59
- };
60
- });
61
- }
62
- function isFallbackPage(project, source, sourcePath) {
63
- return !!source.fallbackDocsDir && !path.relative(
64
- path.resolve(project.rootDir, source.fallbackDocsDir),
65
- sourcePath
66
- ).startsWith("..");
67
- }
68
-
69
- export {
70
- getLocalizedProject,
71
- getContentSources,
72
- getDocsHref,
73
- getLanguageLinks,
74
- isFallbackPage
75
- };