Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
2d2b121
document new notification behavior
mchammer01 Feb 1, 2021
25ef40b
tidy up
mchammer01 Feb 1, 2021
2dc3839
fix inline formatting
mchammer01 Feb 1, 2021
b674598
Apply suggestions from code review
mchammer01 Feb 2, 2021
5109b56
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 2, 2021
cf1a0e7
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 11, 2021
36bf562
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 18, 2021
2177ad1
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 22, 2021
c1f20bc
fix incorrect Liquid versioning
mchammer01 Feb 22, 2021
8ab785e
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Feb 22, 2021
85c2faa
repo sync
Octomerger Mar 15, 2021
d25ee7d
add content about workflow availability
mchammer01 Mar 15, 2021
537ad75
reword
mchammer01 Mar 15, 2021
ba7db08
apply versioning
mchammer01 Mar 15, 2021
7b05542
fix ordered list formatting
mchammer01 Mar 15, 2021
e2bf0fd
address review comment
mchammer01 Mar 15, 2021
4d124dc
Preview for slash command early access doc updates (#18232)
Mar 15, 2021
522728f
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 15, 2021
edd7500
repo sync
Octomerger Mar 15, 2021
83f1e3a
[SEO] Correct footer links (#18136)
skullface Mar 15, 2021
9eccffe
[March 15] Dependabot version updates support for private registries …
hubwriter Mar 15, 2021
beef176
empty commit for preview (#18256)
Mar 15, 2021
c535420
decorate script fix (#18201)
rachmari Mar 16, 2021
5994a4f
add 2.21.16 release notes
bwestover Mar 16, 2021
11af364
add 2.22.8 release notes
bwestover Mar 16, 2021
3051487
add 3.0.2 release notes
bwestover Mar 16, 2021
9b58c6d
try adding back quotes
bwestover Mar 16, 2021
b1f4b29
Revert "try adding back quotes"
bwestover Mar 16, 2021
3a7cb3b
space_invader
bwestover Mar 16, 2021
149addd
Merge branch 'main' of github.com:github/docs-internal into patch-rel…
bwestover Mar 16, 2021
b45ace3
encode a colon
bwestover Mar 16, 2021
2bf7faf
Update data/release-notes/3-0/2.yml
bwestover Mar 16, 2021
f7f3e11
update versioning
mchammer01 Mar 16, 2021
1e0ff90
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 16, 2021
42c894f
Merge branch '3634-dependabot-combined-notification' of github.com:gi…
mchammer01 Mar 16, 2021
9ebe58a
Merge branch '3634-dependabot-combined-notification' of github.com:gi…
mchammer01 Mar 16, 2021
ff2f58a
yet more versioning updates
mchammer01 Mar 16, 2021
6f3f214
Update github-sponsors-additional-terms.md (#17937)
Mar 16, 2021
b304674
Merge branch 'main' into patch-release-notes-2021-03-16
sarahs Mar 16, 2021
f425ada
Merge pull request #18258 from github/patch-release-notes-2021-03-16
sarahs Mar 16, 2021
fc38a40
check for openapi type property (#18257)
rachmari Mar 16, 2021
8f63a44
Update OpenAPI Descriptions (#18249)
github-openapi-bot Mar 16, 2021
0240147
Group user docs on code security into a new "product" (#18196)
felicitymay Mar 16, 2021
8d757ee
Move team discussions content to orgs category (#18217)
emilyistoofunky Mar 16, 2021
60bd45b
Merge branch 'main' into repo-sync
rachmari Mar 16, 2021
fecda83
repo sync
Octomerger Mar 16, 2021
a34dcc4
Actions for Project Management (#17849)
Mar 16, 2021
c6f0298
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 16, 2021
52aeeab
repo sync
Octomerger Mar 16, 2021
f2d8ccb
Add missing Audit Log events for GitHub Actions (#17616)
Mar 17, 2021
54ef0fd
[Ready to ship, March 16] New types of push notifications for GitHub …
ethanpalm Mar 17, 2021
b18d884
Adding additional information for workflow_runs (#18235)
asciimike Mar 17, 2021
ea6adac
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 17, 2021
8b6dc9f
repo sync
Octomerger Mar 17, 2021
6a7e93f
Revert "Group user docs on code security into a new "product" (#18196…
felicitymay Mar 17, 2021
1bc1e84
Code scanning: uploading results as PR checks (#18050)
shati-patel Mar 17, 2021
fb5dec6
Clarify the availability of GHAS licenses for dotcom (#18246)
felicitymay Mar 17, 2021
cd2a217
do not error if frontmatter includes next GHES release or hardcoded next
sarahs Mar 17, 2021
5006cda
add tests
sarahs Mar 17, 2021
4aa879e
Update Packages support overview diagram (#18231)
jmarlena Mar 17, 2021
1d04403
rerun CI
sarahs Mar 17, 2021
56d8ebd
Merge branch 'main' into support-next-release-in-frontmatter
sarahs Mar 17, 2021
443d028
Merge pull request #18281 from github/support-next-release-in-frontma…
sarahs Mar 17, 2021
0192f59
[March 17] Remove all notes about ubuntu-latest migration and fix lab…
AlenaSviridenko Mar 17, 2021
b1b8cb8
add topic frontmatter to articles (#18245)
rachmari Mar 17, 2021
17f09e0
Add target completion date status commmand (#18286)
chiedo Mar 17, 2021
02ee72f
add topics attribute to search (#18212)
rachmari Mar 17, 2021
2e07070
Add filters params to search endpoint (#18289)
heiskr Mar 17, 2021
0c8bf6f
Branch was updated using the 'autoupdate branch' Actions workflow.
Octomerger Mar 17, 2021
7dc3c71
repo sync
Octomerger Mar 17, 2021
ddb0c20
Update search example with topics with white space (#18290)
rachmari Mar 17, 2021
7deb7a8
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
55cbdbf
Update content/github/finding-security-vulnerabilities-and-errors-in-…
mchammer01 Mar 18, 2021
680ad2e
Merge branch 'main' into 3045-workflow-availability
mchammer01 Mar 18, 2021
3623ef0
Merge pull request #18253 from github/3045-workflow-availability
mchammer01 Mar 18, 2021
3d90904
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
44cf73d
Add workflow to triage ready-for-doc-review PRs (#18226)
shati-patel Mar 18, 2021
fa42d8d
Adding enterprise release note for bug fix (#18265)
belaltaher8 Mar 18, 2021
6de2bf3
Add How We Work boards automation (#18298)
chiedo Mar 18, 2021
35fdf0d
Merge How We Work Workflows and Fix bugs (#18299)
chiedo Mar 18, 2021
c416d31
Merge branch 'main' into 3634-dependabot-combined-notification
mchammer01 Mar 18, 2021
31a9ea6
Merge pull request #17590 from github/3634-dependabot-combined-notifi…
mchammer01 Mar 18, 2021
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
Prev Previous commit
Next Next commit
add topics attribute to search (#18212)
  • Loading branch information
rachmari authored Mar 17, 2021
commit 02ee72fa25b01b75d176c4f2eeabf05d4feaa4ba
6 changes: 3 additions & 3 deletions content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ includeGuides:
- Optional.

### `topics`
- Purpose: Indicate the topics covered by the article.
- Type: `String`
- Optional.
- Purpose: Indicate the topics covered by the article. The topics are used to filter guides on some landing pages. For example, the guides at the bottom of [this page](https://docs.github.com/en/actions/guides) can be filtered by topics and the topics are listed under the guide intro. Topics are also added to all search records that get created for each page. The search records contain a `topics` property that is used to filter search results by topics. For more information, see the [Search](/contributing/search.md) contributing guide. Refer to the content models for more details around adding topics. A full list of existing topics is located in the [allowed topics file](/data/allowed-topics.js). If topics in article frontmatter and the allow-topics list become out of sync, the [topics CI test](/tests/unit/search/topics.js) will fail.
- Type: Array of `String`s
- Optional: Topics are preferred for each article, but, there may be cases where existing articles don't yet have topics or a adding a topic to a new article may not add value.

### `contributor`
- Purpose: Indicate an article is contributed and maintained by a third-party organization, typically a GitHub Technology Partner.
Expand Down
5 changes: 4 additions & 1 deletion contributing/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ To see all existing search-related issues and pull requests, visit [github.com/g
## How to search

The site search is part of every version of docs.github.com. On any page, you can use the search box to search the documents we've indexed.
You can also query our search endpoint directly at: https://docs.github.com/search?language=en&version=dotcom&query=jekyll
You can also query our search endpoint directly at: https://docs.github.com/search?language=en&version=dotcom&query=jekyll+topics:actions

Using the attribute `topics` in your query will only return results that have the matching topic value. You can find a full list of topics in [the allowed topics file](/data/allowed-topics.js). The `topics` attribute is configured as a [`filter only` facet in Algolia](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/).

This endpoint responds in JSON format, and fronts Algolia and Lunr. We recommend using this endpoint over directly integrating with Algolia or Lunr, as the endpoint will be more stable.

## Production deploys
Expand Down
84 changes: 84 additions & 0 deletions data/allowed-topics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// This is an AllowList of topics that are approved for use in `topics`
// frontmatter property. If a new topic is added to a Markdown file it must
// also be added to this file.

// The purpose of this list is to ensure we prevent typos and put a process in
// place to keep a curated list of topics. This list also serves as a list of
// available topics filters when using the search endpoint
// (see /contributing/search#how-to-search)
// If you'd like to add a new topic, consult the topic guidelines in the
// content model, add the entry to this list, and ensure you loop in the
// content and/or content strategy team for review.

module.exports = [
'2fa',
'Action development',
'Amazon ECS',
'Ant',
'Azure App Service',
'Azure Pipelines',
'CD',
'CI',
'CircleCI',
'Containers',
'Docker',
'Fundamentals',
'GitLab',
'Google Kubernetes Engine',
'Gradle',
'Java',
'JavaScript',
'Jenkins',
'Maven',
'Migration',
'Node',
'Packaging',
'Powershell',
'Project management',
'Publishing',
'Python',
'Ruby',
'Security',
'Travis CI',
'Workflows',
'access management',
'accounts',
'api',
'billing',
'cli',
'codespaces',
'community',
'desktop',
'device verification',
'early access',
'enterprise',
'events',
'github',
'github apps',
'github search',
'identity',
'issues',
'jobs',
'legal',
'marketplace',
'mobile',
'notifications',
'oauth apps',
'open source',
'organizations',
'pages',
'permissions',
'policy',
'profile',
'profiles',
'projects',
'pull requests',
'repositories',
'security',
'sponsors',
'ssh',
'sso',
'teams',
'usernames',
'webhooks'
]
3 changes: 3 additions & 0 deletions includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
{% if page.intro %}
<meta name="description" content="{{ page.introPlainText }}">
{% endif %}
{% if page.topics %}
<meta name="keywords" content="{{ page.topics | join: ',' }}">
{% endif %}
{% if page.hidden %}
<meta name="robots" content="noindex" />
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions javascripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ function tmplSearchResult ({ url, breadcrumbs, heading, title, content }) {
{ href: url, class: 'no-underline' },
div(
{ class: 'search-result-breadcrumbs d-block text-gray-dark opacity-60 text-small pb-1' },
// Remove redundant title from the end of breadcrumbs
markify((breadcrumbs || '').replace(` / ${title}`, ''))
// Breadcrumbs in search records don't include the page title
markify(breadcrumbs || '')
),
div(
{ class: 'search-result-title d-block h4-mktg text-gray-dark' },
Expand Down
3 changes: 2 additions & 1 deletion lib/search/algolia-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = async function loadAlgoliaResults ({ version, language, query,
breadcrumbs: get(hit, '_highlightResult.breadcrumbs.value'),
heading: get(hit, '_highlightResult.heading.value'),
title: get(hit, '_highlightResult.title.value'),
content: get(hit, '_highlightResult.content.value')
content: get(hit, '_highlightResult.content.value'),
topics: hit.topics
}))
}
1 change: 1 addition & 0 deletions lib/search/lunr-search-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = class LunrIndex {
this.field('heading')
this.field('title')
this.field('content')
this.field('topics')
this.field('customRanking')

this.metadataWhitelist = ['position']
Expand Down
5 changes: 4 additions & 1 deletion lib/search/lunr-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ module.exports = async function loadLunrResults ({ version, language, query, lim
breadcrumbs: field(result, record, 'breadcrumbs'),
heading: field(result, record, 'heading'),
title: field(result, record, 'title'),
content: field(result, record, 'content')
content: field(result, record, 'content'),
// don't highlight the topics array
topics: record.topics
}
})
return results
Expand All @@ -48,6 +50,7 @@ async function loadLunrRecords (indexName) {
.then(JSON.parse)
}

// Highlight a match within an attribute field
function field (result, record, name) {
const text = record[name]
if (!text) return text
Expand Down
21 changes: 17 additions & 4 deletions lib/search/parse-page-sections-into-records.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const { maxContentLength } = require('./config')

module.exports = function parsePageSectionsIntoRecords (href, $) {
const title = $('h1').text().trim()
const breadcrumbs = $('nav.breadcrumbs a')
const breadcrumbsArray = $('nav.breadcrumbs a')
.map((i, el) => {
return $(el)
.text()
Expand All @@ -21,7 +21,18 @@ module.exports = function parsePageSectionsIntoRecords (href, $) {
.replace(/\s+/g, ' ')
})
.get()
.join(' / ')
.slice(0, -1)

const breadcrumbs = breadcrumbsArray.join(' / ') || ''
const metaKeywords = $('meta[name="keywords"]').attr('content')
const topics = metaKeywords ? metaKeywords.split(',') : []

const productName = breadcrumbsArray[0] || ''
topics.push(productName)
// Remove "github" to make filter queries shorter
if (productName.includes('GitHub ')) {
topics.push(productName.replace('GitHub ', ''))
}

let records

Expand Down Expand Up @@ -54,7 +65,8 @@ module.exports = function parsePageSectionsIntoRecords (href, $) {
breadcrumbs,
heading,
title,
content
content,
topics
}
})
.get()
Expand All @@ -74,7 +86,8 @@ module.exports = function parsePageSectionsIntoRecords (href, $) {
url,
breadcrumbs,
title,
content
content,
topics
}]
}

Expand Down
1 change: 1 addition & 0 deletions script/content-migrations/add-tags-to-articles.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ function updateFrontmatter (filePath, newTopics) {
} else if (Array.isArray(data.topics)) {
topics = topics.concat(data.topics)
}

newTopics.forEach(topic => {
topics.push(topic)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<head>
<meta name="keywords" content="topic1,topic2">
</head>
<div class="article-grid-body">
<nav class="breadcrumbs">
<a href="#">a</a>
<a href="#">b</a>
<a href="#">c</a>
<a href="#">GitHub Actions</a>
<a href="#">actions learning path</a>
<a href="#">I am the page title</a>
</nav>

<h1>I am the page title</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
<head>
<meta name="keywords" content="key1,key2,key3">
</head>
<p>I am outside the article and should not be included</p>

<div class="article-grid-body">
<nav class="breadcrumbs">
<a href="#">x</a>
<a href="#">y</a>
<a href="#">z</a>
<a href="#">Education</a>
<a href="#">map topic</a>
<a href="#">A page without sections</a>
</nav>

<h1>A page without sections</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,21 @@ describe('search parsePageSectionsIntoRecords module', () => {
objectID: '/example/href#first',
url: 'https://docs.github.com/example/href#first',
slug: 'first',
breadcrumbs: 'a / b / c',
breadcrumbs: 'GitHub Actions / actions learning path',
heading: 'First heading',
title: 'I am the page title',
content: "Here's a paragraph. And another."
content: "Here's a paragraph. And another.",
topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions']
},
{
objectID: '/example/href#second',
url: 'https://docs.github.com/example/href#second',
slug: 'second',
breadcrumbs: 'a / b / c',
breadcrumbs: 'GitHub Actions / actions learning path',
heading: 'Second heading',
title: 'I am the page title',
content: "Here's a paragraph in the second section. And another."
content: "Here's a paragraph in the second section. And another.",
topics: ['topic1', 'topic2', 'GitHub Actions', 'Actions']
}
]

Expand All @@ -50,9 +52,10 @@ describe('search parsePageSectionsIntoRecords module', () => {
{
objectID: '/example/href',
url: 'https://docs.github.com/example/href',
breadcrumbs: 'x / y / z',
breadcrumbs: 'Education / map topic',
title: 'A page without sections',
content: 'First paragraph. Second paragraph.'
content: 'First paragraph. Second paragraph.',
topics: ['key1', 'key2', 'key3', 'Education']
}
]
expect(records).toEqual(expected)
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions tests/unit/search/topics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const path = require('path')
const fs = require('fs')
const readFrontmatter = require('../../../lib/read-frontmatter')
const walk = require('walk-sync')
const { difference } = require('lodash')
const allowedTopics = require('../../../data/allowed-topics')

const contentDir = path.join(process.cwd(), 'content')
const topics = walk(contentDir, { includeBasePath: true })
.filter(filename => filename.endsWith('.md') && !filename.includes('README'))
.map(filename => {
const fileContent = fs.readFileSync(filename, 'utf8')
const { data } = readFrontmatter(fileContent)
return data.topics || []
})
.flat()

const allUsedTopics = [...new Set(topics)].sort()

describe('Check for allowed frontmatter topics', () => {
test('all used topics are allowed in /data/allowed-topics.js', () => {
expect(allUsedTopics.length).toBeGreaterThan(0)
const unusedTopics = difference(allUsedTopics, allowedTopics)
expect(unusedTopics).toEqual([])
})

test('all allowed topics are used by at least one content file', () => {
expect(allowedTopics.length).toBeGreaterThan(0)
const disallowedTopics = difference(allowedTopics, allUsedTopics)
expect(disallowedTopics).toEqual([])
})
})