forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add topics attribute to search (github#18212)
- Loading branch information
Showing
15 changed files
with
174 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
.../algolia/fixtures/page-with-sections.html → ...t/search/fixtures/page-with-sections.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletions
9
...golia/fixtures/page-without-sections.html → ...earch/fixtures/page-without-sections.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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([]) | ||
}) | ||
}) |