Skip to content

Commit a7a57b2

Browse files
authored
Rename 'map topics' to 'subcategories' (#56202)
1 parent 4a7cf8e commit a7a57b2

32 files changed

+73
-71
lines changed

src/content-linter/lib/helpers/schema-utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function formatAjvErrors(errors = []) {
3333
// The two most common errors are required and additionalProperties.
3434
// This catches any other with a generic detail that uses the AJV wording.
3535
error.detail = `Frontmatter ${errorObj.message}.`
36-
error.context = Object.values(errorObj.params.join(''))
36+
error.context = Object.values(errorObj.params).join('')
3737
error.errorProperty = error.context
3838
error.searchProperty = error.errorProperty
3939
return error

src/content-linter/lib/linting-rules/early-access-references.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ export const frontmatterEarlyAccessReferences = {
6262

6363
// The landing page must link to early-access content so the
6464
// children property doesn't need to be checked in that case.
65-
if (filepath === 'content/index.md') delete fm.children
65+
// Also exclude fixture index files.
66+
if (filepath === 'content/index.md' || filepath.includes('fixtures/content/index.md'))
67+
delete fm.children
6668

6769
// Convert updated frontmatter back to a string
6870
// to search for 'early-access'.'

src/content-linter/tests/category-pages.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ describe.skip('category pages', () => {
139139
const articleContents = await fs.promises.readFile(articlePath, 'utf8')
140140
const data = getFrontmatterData(articleContents)
141141

142-
// Do not include map topics in list of published articles
143-
if (data.mapTopic || data.hidden) return null
142+
// Do not include subcategories in list of published articles
143+
if (data.subcategory || data.hidden) return null
144144

145145
// ".../content/github/{category}/{article}.md" => "/{article}"
146146
return `/${path.relative(categoryDir, articlePath).replace(/\.md$/, '')}`
@@ -161,8 +161,8 @@ describe.skip('category pages', () => {
161161
const articleContents = await fs.promises.readFile(articlePath, 'utf8')
162162
const data = getFrontmatterData(articleContents)
163163

164-
// Do not include map topics nor hidden pages in list of available articles
165-
if (data.mapTopic || data.hidden) return null
164+
// Do not include subcategories nor hidden pages in list of available articles
165+
if (data.subcategory || data.hidden) return null
166166

167167
// ".../content/github/{category}/{article}.md" => "/{article}"
168168
return `/${path.relative(categoryDir, articlePath).replace(/\.md$/, '')}`
@@ -195,7 +195,7 @@ describe.skip('category pages', () => {
195195
expect(unexpectedArticles.length, errorMessage).toBe(0)
196196
})
197197

198-
test('contains only articles and map topics with versions that are also available in the parent category', () => {
198+
test('contains only articles and subcategories with versions that are also available in the parent category', () => {
199199
Object.entries(articleVersions).forEach(([articleName, articleVersions]) => {
200200
const unexpectedVersions = difference(articleVersions, categoryVersions)
201201
const errorMessage = `${articleName} has versions that are not available in parent category`

src/content-render/scripts/reconcile-category-dirs-with-ids.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ const slugger = new GithubSlugger()
2323

2424
const contentDir = path.join(ROOT, 'content')
2525

26-
const INCLUDE_MAP_TOPICS = Boolean(JSON.parse(process.env.INCLUDE_MAP_TOPICS || 'false'))
26+
const INCLUDE_SUBCATEGORIES = Boolean(JSON.parse(process.env.INCLUDE_SUBCATEGORIES || 'false'))
2727

2828
main()
2929

3030
async function main() {
3131
const englishCategoryIndices = getEnglishCategoryIndices().filter((name) => {
32-
return INCLUDE_MAP_TOPICS || name.split(path.sep).length < 5
32+
return INCLUDE_SUBCATEGORIES || name.split(path.sep).length < 5
3333
})
3434

3535
const shouldRename = []

src/content-render/tests/render-changed-and-deleted-files.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('deleted-content', () => {
127127
? `The deleted file ${file} did not set up a redirect when deleted.`
128128
: ''
129129
// Certain articles that are deleted and moved under a directory with the same article name
130-
// should just route to the map topic page instead of redirecting (docs content team confirmed).
130+
// should just route to the subcategory page instead of redirecting (docs content team confirmed).
131131
// So, in this scenario, we'd get a 200 status code.
132132
expect(res.statusCode === 301 || res.statusCode === 200, error).toBe(true)
133133
})

src/dev-toc/layout.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ <h2 class="mt-3 mb-3"><abbr>TOC</abbr> for {{ allVersions[currentVersion].versio
3939
<li style="margin: 3px 0 0 30px;">
4040
<a title="{{ categoryPage.page.documentType }}" href="{{ docsRoot }}{{ categoryPage.href }}">{{ categoryPage.renderedFullTitle }}</a>
4141
<ul>
42-
{% for maptopicPage in categoryPage.childPages %}
42+
{% for subcategoryPage in categoryPage.childPages %}
4343
<li style="margin: 3px 0 0 30px;">
44-
<a title="{{ maptopicPage.page.documentType }}" href="{{ docsRoot }}{{ maptopicPage.href }}">{{ maptopicPage.renderedFullTitle }}</a>
44+
<a title="{{ subcategoryPage.page.documentType }}" href="{{ docsRoot }}{{ subcategoryPage.href }}">{{ subcategoryPage.renderedFullTitle }}</a>
4545
<ul>
46-
{% for articlePage in maptopicPage.childPages %}
46+
{% for articlePage in subcategoryPage.childPages %}
4747
<li style="margin: 3px 0 0 30px;">
4848
<a title="{{ articlePage.page.documentType }}" href="{{ docsRoot }}{{ articlePage.href }}">{{ articlePage.renderedFullTitle }}</a>
4949
</li>

src/events/lib/get-document-type.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Document types used by the system
33
*/
4-
type DocumentType = 'homepage' | 'product' | 'category' | 'mapTopic' | 'article' | 'early-access'
4+
type DocumentType = 'homepage' | 'product' | 'category' | 'subcategory' | 'article' | 'early-access'
55

66
/**
77
* This function derives the document type from the *relative path* segment length,
@@ -20,17 +20,17 @@ export default function getDocumentType(relativePath: string): DocumentType {
2020
// Early Access has an extra tree segment, so it has a different number of segments.
2121
const isEarlyAccess = relativePath.startsWith('early-access')
2222

23-
const publicDocs: DocumentType[] = ['homepage', 'product', 'category', 'mapTopic']
23+
const publicDocs: DocumentType[] = ['homepage', 'product', 'category', 'subcategory']
2424

2525
const earlyAccessDocs: DocumentType[] = [
2626
'homepage',
2727
'early-access',
2828
'product',
2929
'category',
30-
'mapTopic',
30+
'subcategory',
3131
]
3232

33-
// Anything beyond the largest depth is assumed to be a mapTopic
33+
// Anything beyond the largest depth is assumed to be a subcategory
3434
return isEarlyAccess
3535
? earlyAccessDocs[Math.min(segmentLength, earlyAccessDocs.length) - 1]
3636
: publicDocs[Math.min(segmentLength, publicDocs.length) - 1]

src/events/lib/schema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const context = {
8989
page_document_type: {
9090
type: 'string',
9191
description: 'The generic page document type based on URL path.',
92-
enum: ['homepage', 'early-access', 'product', 'category', 'mapTopic', 'article'], // get-document-type.js
92+
enum: ['homepage', 'early-access', 'product', 'category', 'subcategory', 'article'], // get-document-type.js
9393
},
9494
page_type: {
9595
type: 'string',

src/fixtures/fixtures/article-with-mislocalized-frontmatter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: GitHub 上でプロジェクトを探索する
33
intro: ''
4-
mapTopic: verdadero
4+
subcategory: true
55
versions:
66
free-pro-team: '*'
77
enterprise-server: '*'

src/fixtures/fixtures/content/actions/category/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ versions:
88
ghes: '*'
99
ghec: '*'
1010
children:
11-
- /map-topic
11+
- /subcategory
1212
---

0 commit comments

Comments
 (0)