Skip to content

Commit 9bf82cc

Browse files
authored
Merge pull request #8391 from fkatsuhiro/fix/conflicting-links-and-entries-build-logic
fix(docs): Conflicting links and entries in API reference page
2 parents fe45eb6 + 48db7df commit 9bf82cc

File tree

26 files changed

+556
-527
lines changed

26 files changed

+556
-527
lines changed

packages/docs/src/routes/api/index.tsx

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { $, component$, useOn, useSignal, useStore, useTask$, isBrowser } from '@builder.io/qwik';
22
import { Link } from '@builder.io/qwik-city';
3-
43
import { toSnakeCase } from '../../utils/utils';
54

65
// TODO: load the content of these files using fs instead of importing them
@@ -140,32 +139,45 @@ export const ApiMemberWrapper = component$(({ id, data, filters }: any) => {
140139
});
141140

142141

143-
export const ApiMemberList = component$(({ id, data, filters }: any) => (
144-
<ul class="grid sm:grid-cols-2 lg:grid-cols-3 pb-5">
145-
{data.members.map((member: any) => {
146-
const kind = toSnakeCase(member.kind);
147-
148-
if (!member.name) {
149-
return;
150-
}
151-
152-
const name = member.name.toLowerCase()
153-
.replace(/[^a-zA-Z0-9]/g, '')
154-
.replace(/ /g, '-');
155-
156-
157-
return (
158-
<li
159-
key={`${id}-member-${member.id}-${kind}`}
160-
data-kind={kind}
161-
data-kind-label={kind.substring(0, 1).toUpperCase()}
162-
class={`api-item list-none text-xs ${
163-
(kind in filters && !filters[kind] && 'hidden') || ''
164-
}`}
165-
>
166-
<Link href={`${data.id}#${name}`}>{member.name}</Link>
167-
</li>
168-
);
169-
})}
170-
</ul>
171-
));
142+
export const ApiMemberList = component$(({ id, data, filters }: any) => {
143+
const nameCounts = data.members.reduce((acc: Record<string, number>, m: any) => {
144+
if (m.name) {
145+
const normalizedName = m.name.toLowerCase();
146+
acc[normalizedName] = (acc[normalizedName] || 0) + 1;
147+
}
148+
return acc;
149+
}, {});
150+
return (
151+
<ul class="grid sm:grid-cols-2 lg:grid-cols-3 pb-5">
152+
{data.members.map((member: any) => {
153+
const kind = toSnakeCase(member.kind);
154+
155+
if (!member.name) {
156+
return;
157+
}
158+
159+
const name = member.name.toLowerCase()
160+
.replace(/[$]/g, '_')
161+
.replace(/[^a-zA-Z0-9_]/g, '')
162+
.replace(/ /g, '-');
163+
164+
const anchorId = nameCounts[member.name.toLowerCase()] > 1
165+
? `${name}-${kind}`
166+
: name;
167+
168+
return (
169+
<li
170+
key={`${id}-member-${member.id}-${kind}`}
171+
data-kind={kind}
172+
data-kind-label={kind.substring(0, 1).toUpperCase()}
173+
class={`api-item list-none text-xs ${
174+
(kind in filters && !filters[kind] && 'hidden') || ''
175+
}`}
176+
>
177+
<Link href={`${data.id}#${anchorId}`}>{member.name}</Link>
178+
</li>
179+
);
180+
})}
181+
</ul>
182+
);
183+
});

packages/docs/src/routes/api/qwik-city-middleware-aws-lambda/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/aws-lambda API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/aws-lambda
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(opts: AwsOpt): {
@@ -60,7 +60,7 @@ AwsOpt
6060

6161
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/aws-lambda/index.ts)
6262

63-
## PlatformAwsLambda
63+
<h2 id="platformawslambda">PlatformAwsLambda</h2>
6464

6565
```typescript
6666
export interface PlatformAwsLambda extends Object
@@ -70,7 +70,7 @@ export interface PlatformAwsLambda extends Object
7070
7171
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/aws-lambda/index.ts)
7272
73-
## QwikCityAwsLambdaOptions
73+
<h2 id="qwikcityawslambdaoptions">QwikCityAwsLambdaOptions</h2>
7474
7575
```typescript
7676
export interface QwikCityAwsLambdaOptions extends ServerRenderOptions

packages/docs/src/routes/api/qwik-city-middleware-azure-swa/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/azure-swa API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/azure-swa
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(
@@ -44,7 +44,7 @@ AzureFunction
4444

4545
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/azure-swa/index.ts)
4646

47-
## PlatformAzure
47+
<h2 id="platformazure">PlatformAzure</h2>
4848

4949
```typescript
5050
export interface PlatformAzure extends Partial<Context>
@@ -54,7 +54,7 @@ export interface PlatformAzure extends Partial<Context>
5454
5555
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/azure-swa/index.ts)
5656
57-
## QwikCityAzureOptions
57+
<h2 id="qwikcityazureoptions">QwikCityAzureOptions</h2>
5858
5959
```typescript
6060
export interface QwikCityAzureOptions extends ServerRenderOptions

packages/docs/src/routes/api/qwik-city-middleware-cloudflare-pages/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/cloudflare-pages API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/cloudflare-pages
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(opts: QwikCityCloudflarePagesOptions): (
@@ -50,7 +50,7 @@ opts
5050

5151
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/cloudflare-pages/index.ts)
5252

53-
## PlatformCloudflarePages
53+
<h2 id="platformcloudflarepages">PlatformCloudflarePages</h2>
5454

5555
```typescript
5656
export interface PlatformCloudflarePages
@@ -118,7 +118,7 @@ Request
118118

119119
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/cloudflare-pages/index.ts)
120120

121-
## QwikCityCloudflarePagesOptions
121+
<h2 id="qwikcitycloudflarepagesoptions">QwikCityCloudflarePagesOptions</h2>
122122

123123
```typescript
124124
export interface QwikCityCloudflarePagesOptions extends ServerRenderOptions

packages/docs/src/routes/api/qwik-city-middleware-firebase/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/firebase API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/firebase
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(
@@ -44,7 +44,7 @@ opts
4444

4545
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/firebase/index.ts)
4646

47-
## PlatformFirebase
47+
<h2 id="platformfirebase">PlatformFirebase</h2>
4848

4949
```typescript
5050
export interface PlatformFirebase extends Object
@@ -54,7 +54,7 @@ export interface PlatformFirebase extends Object
5454
5555
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/firebase/index.ts)
5656
57-
## QwikCityFirebaseOptions
57+
<h2 id="qwikcityfirebaseoptions">QwikCityFirebaseOptions</h2>
5858
5959
```typescript
6060
export interface QwikCityFirebaseOptions extends ServerRenderOptions

packages/docs/src/routes/api/qwik-city-middleware-netlify-edge/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/netlify-edge API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/netlify-edge
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(
@@ -44,7 +44,7 @@ opts
4444

4545
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/netlify-edge/index.ts)
4646

47-
## PlatformNetlify
47+
<h2 id="platformnetlify">PlatformNetlify</h2>
4848

4949
```typescript
5050
export interface PlatformNetlify extends Partial<Omit<Context, 'next' | 'cookies'>>
@@ -54,7 +54,7 @@ export interface PlatformNetlify extends Partial<Omit<Context, 'next' | 'cookies
5454
5555
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/netlify-edge/index.ts)
5656
57-
## QwikCityNetlifyOptions
57+
<h2 id="qwikcitynetlifyoptions">QwikCityNetlifyOptions</h2>
5858
5959
```typescript
6060
export interface QwikCityNetlifyOptions extends ServerRenderOptions

packages/docs/src/routes/api/qwik-city-middleware-node/index.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: \@builder.io/qwik-city/middleware/node API Reference
44

55
# [API](/api) &rsaquo; @builder.io/qwik-city/middleware/node
66

7-
## createQwikCity
7+
<h2 id="createqwikcity">createQwikCity</h2>
88

99
```typescript
1010
export declare function createQwikCity(opts: QwikCityNodeRequestOptions): {
@@ -58,15 +58,15 @@ opts
5858

5959
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/node/index.ts)
6060

61-
## NodeRequestNextFunction
61+
<h2 id="noderequestnextfunction">NodeRequestNextFunction</h2>
6262

6363
```typescript
6464
export interface NodeRequestNextFunction
6565
```
6666

6767
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/node/index.ts)
6868

69-
## PlatformNode
69+
<h2 id="platformnode">PlatformNode</h2>
7070

7171
```typescript
7272
export interface PlatformNode
@@ -138,7 +138,7 @@ _(Optional)_
138138

139139
[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-city/src/middleware/node/index.ts)
140140

141-
## QwikCityNodeRequestOptions
141+
<h2 id="qwikcitynoderequestoptions">QwikCityNodeRequestOptions</h2>
142142

143143
```typescript
144144
export interface QwikCityNodeRequestOptions extends ServerRenderOptions

0 commit comments

Comments
 (0)