@redocly/realm-plugin-asciidoc 0.9.0-next.6 → 0.9.0-next.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.
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useMemo } from 'react';
3
+ import { useThemeHooks } from '@redocly/theme';
4
+ import { getLocaleFromPathname, getPathnameForLocale, withPathPrefix, } from '@redocly/theme/core/utils';
5
+ import Template from '../template.js';
6
+ import { editContentNodes } from './content-nodes.js';
7
+ import { ASCIIDOC_PAGE_DEP_KEY } from './shared.js';
8
+ const ROOT_RELATIVE_URL_ATTRIBUTE = /(\s(href|src)=")(\/[^"]*)(")/gi;
9
+ // Realm Plus serves content assets from this path in every locale.
10
+ const CONTENT_ASSETS_PATH = '/content-assets/';
11
+ function isRootRelative(url) {
12
+ return url.startsWith('/') && !url.startsWith('//');
13
+ }
14
+ export default function RealmPlusAsciidocTemplate() {
15
+ const { usePageSharedData, useL10nConfig } = useThemeHooks();
16
+ const pageProps = usePageSharedData(ASCIIDOC_PAGE_DEP_KEY);
17
+ const { currentLocale, defaultLocale, locales } = useL10nConfig();
18
+ const localPageProps = useMemo(() => {
19
+ if (!pageProps)
20
+ return undefined;
21
+ const toAssetUrl = (url) => (isRootRelative(url) ? withPathPrefix(url) : url);
22
+ // Realm Plus stores page URLs without a locale, so a page link gets the reader's locale, as
23
+ // a Markdown link does. A link that names a locale stays in that locale.
24
+ const toLinkUrl = (url) => {
25
+ if (!isRootRelative(url) || url.startsWith(CONTENT_ASSETS_PATH))
26
+ return toAssetUrl(url);
27
+ if (getLocaleFromPathname(url, defaultLocale, locales) !== defaultLocale) {
28
+ return withPathPrefix(url);
29
+ }
30
+ return withPathPrefix(getPathnameForLocale(url, defaultLocale, currentLocale, locales));
31
+ };
32
+ const contentNodes = structuredClone(pageProps.contentNodes);
33
+ editContentNodes(contentNodes, {
34
+ html: (html) => html.replace(ROOT_RELATIVE_URL_ATTRIBUTE, (_match, before, attribute, url, after) => `${before}${attribute.toLowerCase() === 'href' ? toLinkUrl(url) : toAssetUrl(url)}${after}`),
35
+ imageSrc: toAssetUrl,
36
+ });
37
+ return Object.assign(Object.assign({}, pageProps), { contentNodes });
38
+ }, [pageProps, currentLocale, defaultLocale, locales]);
39
+ return localPageProps ? _jsx(Template, { pageProps: localPageProps }) : null;
40
+ }
41
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/realm-plus/template.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,GACf,MAAM,2BAA2B,CAAC;AAEnC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAA0B,MAAM,aAAa,CAAC;AAE5E,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AACrE,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,yBAAyB;IAC/C,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAAC;IAC7D,MAAM,SAAS,GAAG,iBAAiB,CAAgC,qBAAqB,CAAC,CAAC;IAC1F,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,aAAa,EAAE,CAAC;IAClE,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,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,EAAE,OAAO,CAAC,CAAC,CAAC;IAEvD,OAAO,cAAc,CAAC,CAAC,CAAC,KAAC,QAAQ,IAAC,SAAS,EAAE,cAAc,GAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/realm-plugin-asciidoc",
3
- "version": "0.9.0-next.6",
3
+ "version": "0.9.0-next.7",
4
4
  "description": "AsciiDoc plugin for Redocly Realm",
5
5
  "author": "team@redocly.com",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -29,6 +29,7 @@
29
29
  "styled-components": "^6.4.2"
30
30
  },
31
31
  "devDependencies": {
32
+ "@redocly/realm-plus": "npm:realm-plus@0.1.0",
32
33
  "@types/node": "24.1.0",
33
34
  "@types/react": "^19.2.7",
34
35
  "@vitest/coverage-v8": "4.1.11",
@@ -37,11 +38,22 @@
37
38
  "vitest": "4.1.11"
38
39
  },
39
40
  "peerDependencies": {
40
- "@redocly/realm": "0.139.0-next.6",
41
- "@redocly/theme": "0.71.0-next.3",
41
+ "@redocly/realm": "0.139.0-next.7",
42
+ "@redocly/realm-plus": "*",
43
+ "@redocly/theme": "0.71.0-next.4",
42
44
  "react": "^19.2.7",
43
45
  "react-dom": "^19.2.7"
44
46
  },
47
+ "peerDependenciesMeta": {
48
+ "@redocly/realm-plus": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "nx": {
53
+ "implicitDependencies": [
54
+ "realm-plus"
55
+ ]
56
+ },
45
57
  "scripts": {
46
58
  "clean": "rimraf lib",
47
59
  "compile": "tsgo -p tsconfig.build.json",