Skip to content

Commit 123e44e

Browse files
hejsztynxCopilotkacperzolkiewskiexploIF
authored
docs: project configuration (#712)
# Summary - wired up ESLint and TS, as we now have interactive examples' code visible directly in the docs. - `react-native-enriched-html` is now linked locally. - as the library is resolved locally, the CI build scripts need its dependencies installed,so the root `node_modules` has become available now in the CI scripts. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Kacper Żółkiewski <74975508+kacperzolkiewski@users.noreply.github.com> Co-authored-by: Igor Furgała <74370735+exploIF@users.noreply.github.com>
1 parent 6f9c3f3 commit 123e44e

8 files changed

Lines changed: 98 additions & 488 deletions

File tree

.github/workflows/docs-build.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,20 @@ jobs:
2222
with:
2323
node-version: 22
2424
cache: yarn
25-
cache-dependency-path: docs/yarn.lock
25+
cache-dependency-path: |
26+
yarn.lock
27+
docs/yarn.lock
28+
29+
- name: Install library dependencies (local source)
30+
working-directory: ${{ github.workspace }}
31+
run: yarn install --immutable
2632

2733
- name: Install dependencies
2834
run: yarn install --immutable
2935

36+
- name: Typecheck docs
37+
working-directory: ${{ github.workspace }}
38+
run: yarn typecheck:docs
39+
3040
- name: Build docs
3141
run: yarn build

.github/workflows/docs-publish.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,21 @@ jobs:
2727
with:
2828
node-version: 22
2929
cache: yarn
30-
cache-dependency-path: docs/yarn.lock
30+
cache-dependency-path: |
31+
yarn.lock
32+
docs/yarn.lock
33+
34+
- name: Install library dependencies (local source)
35+
working-directory: ${{ github.workspace }}
36+
run: yarn install --immutable
3137

3238
- name: Install dependencies
3339
run: yarn install --immutable
3440

41+
- name: Typecheck docs
42+
working-directory: ${{ github.workspace }}
43+
run: yarn typecheck:docs
44+
3545
- name: Build docs
3646
run: yarn build
3747

docs/docusaurus.config.js

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// @ts-check
22
// Note: type annotations allow type checking and IDEs autocompletion
33

4-
import { topbarBannerReservationScript } from '@swmansion/t-rex-ui/topbar-banner';
5-
import { TOP_BAR_BANNER } from './src/components/topbarBanner.config.ts';
4+
import { topbarBannerReservationScript } from '@swmansion/t-rex-ui/topbar-banner';
5+
import { TOP_BAR_BANNER } from './src/components/topbarBanner.config.ts';
6+
7+
const path = require('path');
68

79
const lightCodeTheme = require('./src/theme/CodeBlock/highlighting-light.js');
810
const darkCodeTheme = require('./src/theme/CodeBlock/highlighting-dark.js');
@@ -22,6 +24,38 @@ function reactNativeWebPlugin() {
2224
};
2325
}
2426

27+
function enrichedHtmlLocalSourcePlugin() {
28+
const librarySource = path.resolve(__dirname, '../src');
29+
return {
30+
name: 'enriched-html-local-source',
31+
configureWebpack(_config, isServer, utils) {
32+
return {
33+
module: {
34+
rules: [
35+
{
36+
test: /\.tsx?$/,
37+
include: librarySource,
38+
use: [utils.getJSLoader({ isServer })],
39+
},
40+
],
41+
},
42+
resolve: {
43+
alias: {
44+
'react-native-enriched-html$': path.resolve(
45+
librarySource,
46+
'index.tsx'
47+
),
48+
// The react-native-enriched-html has separate react and react-dom dependencies in node_modules,
49+
// so React would otherwise be resolved from the repo root and bundled twice.
50+
'react': path.resolve(__dirname, 'node_modules/react'),
51+
'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
52+
},
53+
},
54+
};
55+
},
56+
};
57+
}
58+
2559
const firstBannerZone = TOP_BAR_BANNER.zones[0];
2660
const bannerReservationHeadTags = firstBannerZone
2761
? [
@@ -31,7 +65,7 @@ const bannerReservationHeadTags = firstBannerZone
3165
innerHTML: topbarBannerReservationScript(
3266
firstBannerZone.zoneId,
3367
firstBannerZone.contentId,
34-
TOP_BAR_BANNER.hiddenPaths,
68+
TOP_BAR_BANNER.hiddenPaths
3569
),
3670
},
3771
]
@@ -99,10 +133,13 @@ const config = {
99133

100134
headTags: bannerReservationHeadTags,
101135

102-
clientModules: [require.resolve('./src/clientModules/topbarBannerRefresh.ts')],
136+
clientModules: [
137+
require.resolve('./src/clientModules/topbarBannerRefresh.ts'),
138+
],
103139

104140
plugins: [
105141
reactNativeWebPlugin,
142+
enrichedHtmlLocalSourcePlugin,
106143
function transpileTRexUiTheme() {
107144
return {
108145
name: 'transpile-t-rex-ui-theme',
@@ -160,9 +197,10 @@ const config = {
160197
dropdownActiveClassDisabled: true,
161198
},
162199
{
163-
href: 'https://github.com/software-mansion/react-native-enriched-html/',
164-
position: 'right',
165-
className: 'header-github',
200+
'href':
201+
'https://github.com/software-mansion/react-native-enriched-html/',
202+
'position': 'right',
203+
'className': 'header-github',
166204
'aria-label': 'GitHub repository',
167205
},
168206
],

docs/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"react": "19.1.1",
3636
"react-dom": "19.1.1",
3737
"react-native": "0.86.0",
38-
"react-native-enriched-html": "1.1.0",
3938
"react-native-web": "0.21.2"
4039
},
4140
"resolutions": {

docs/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"compilerOptions": {
4+
"baseUrl": ".",
5+
"paths": {
6+
"@site/*": ["./*"],
7+
"react-native-enriched-html": ["../src/index.tsx"],
8+
},
9+
},
10+
"exclude": [".docusaurus", "build"],
11+
"include": ["src/examples"],
12+
}

0 commit comments

Comments
 (0)