Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ You can use parentheses to express more complicated boolean expressions. For exa
You can use specialized keywords to qualify your search.
* [Repository qualifier](#repository-qualifier)
* [Organization and user qualifiers](#organization-and-user-qualifiers)
* [Enterprise qualifier](#enterprise-qualifier)
* [Language qualifier](#language-qualifier)
* [Path qualifier](#path-qualifier)
* [Symbol qualifier](#symbol-qualifier)
Expand Down Expand Up @@ -140,6 +141,16 @@ user:octocat
> [!NOTE]
> Code search does not currently support regular expressions or partial matching for organization or user names, so you will have to type the entire organization or user name for the qualifier to work.

### Enterprise qualifier

To search for files within an enterprise, use the `enterprise:` qualifier. For example:

```text
enterprise:octocorp
```

This searches repositories owned by organizations in the `octocorp` enterprise. User-owned repositories are not included.

### Language qualifier

To narrow down to a specific languages, use the `language:` qualifier. For example:
Expand Down
1 change: 1 addition & 0 deletions src/events/components/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export function sendEvent<T extends EventType>({
path_article: getMetaContent('path-article'),
page_document_type: getMetaContent('page-document-type'),
page_type: getMetaContent('page-type'),
content_type: getMetaContent('page-content-type'),
status: Number(getMetaContent('status') || 0),
is_logged_in: isLoggedIn(),

Expand Down
6 changes: 6 additions & 0 deletions src/events/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { languageKeys } from '@/languages/lib/languages-server'
import { allVersionKeys } from '@/versions/lib/all-versions'
import { productIds } from '@/products/lib/all-products'
import { allTools } from '@/tools/lib/all-tools'
import { contentTypesEnum } from '@/frame/lib/frontmatter'

const versionPattern = '^\\d+(\\.\\d+)?(\\.\\d+)?$'

Expand Down Expand Up @@ -100,6 +101,11 @@ const context = {
description: 'Optional page type from the content frontmatter.',
enum: ['overview', 'quick_start', 'tutorial', 'how_to', 'reference', 'rai'], // frontmatter.ts
},
content_type: {
type: 'string',
description: 'Optional content type from the content frontmatter (EDI content models).',
enum: contentTypesEnum,
},
status: {
type: 'number',
description: 'The HTTP response status code of the main page HTML.',
Expand Down
25 changes: 25 additions & 0 deletions src/events/tests/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, test, vi } from 'vitest'

import { post } from '@/tests/helpers/e2etest'
import { contentTypesEnum } from '@/frame/lib/frontmatter'

describe('POST /events', () => {
vi.setConfig({ testTimeout: 60 * 1000 })
Expand Down Expand Up @@ -163,4 +164,28 @@ describe('POST /events', () => {
})
expect(statusCode).toBe(400)
})

test('should accept content_type field', async () => {
const { statusCode } = await checkEvent({
...pageExample,
context: {
...pageExample.context,
content_type: 'how-tos',
},
})
expect(statusCode).toBe(200)
})

test('should accept valid content_type values from EDI content models', async () => {
for (const contentType of contentTypesEnum) {
const { statusCode } = await checkEvent({
...pageExample,
context: {
...pageExample.context,
content_type: contentType,
},
})
expect(statusCode).toBe(200)
}
})
})
1 change: 1 addition & 0 deletions src/events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type EventProps = {
path_article: string
page_document_type: string
page_type: string
content_type: string
status: number
is_logged_in: boolean
dotcom_user: string
Expand Down
1 change: 1 addition & 0 deletions src/frame/components/DefaultLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export const DefaultLayout = (props: Props) => {
/>
)}
{page.type && <meta name="page-type" content={page.type} />}
{page.contentType && <meta name="page-content-type" content={page.contentType} />}
{page.documentType && <meta name="page-document-type" content={page.documentType} />}
{status && <meta name="status" content={status.toString()} />}

Expand Down
2 changes: 2 additions & 0 deletions src/frame/components/context/MainContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export type MainContextT = {
page: {
documentType: string
type?: string
contentType?: string
topics: Array<string>
title: string
fullTitle?: string
Expand Down Expand Up @@ -217,6 +218,7 @@ export const getMainContext = async (req: any, res: any): Promise<MainContextT>
(page && {
documentType,
type: req.context.page.type || null,
contentType: req.context.page.contentType || null,
title: req.context.page.title,
fullTitle: req.context.page.fullTitle || null,
topics: req.context.page.topics || [],
Expand Down
3 changes: 3 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type PageFrontmatter = {
featuredLinks?: FeaturedLinks
changelog?: ChangeLog
type?: string
contentType?: string
topics?: string[]
includeGuides?: string[]
learningTracks?: string[]
Expand Down Expand Up @@ -380,6 +381,8 @@ export type Page = {
complexity?: string[]
industry?: string[]
sidebarLink?: SidebarLink
type?: string
contentType?: string
}

export type SidebarLink = {
Expand Down
Loading