Skip to content

Commit bca2d96

Browse files
authored
Merge pull request #36169 from github/repo-sync
Repo sync
2 parents 588231b + 8c23bcc commit bca2d96

File tree

13 files changed

+52
-14
lines changed

13 files changed

+52
-14
lines changed

config/kubernetes/production/deployments/webapp.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ spec:
2323
image: docs-internal
2424
resources:
2525
requests:
26-
cpu: 8000m
27-
memory: 10Gi
26+
cpu: 4000m
27+
memory: 8Gi
2828
limits:
29-
cpu: 16000m
30-
memory: 14Gi
29+
cpu: 8000m
30+
memory: 16Gi
3131
ports:
3232
- name: http
3333
containerPort: 4000

content/billing/using-the-new-billing-platform/charging-business-units.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ To ensure your cost centers reflect spending as intended, it's important to unde
103103

104104
### Cost center allocation for {% data variables.product.prodname_GH_advanced_security %}
105105

106-
* If a user belongs to a cost center, all charges associated with the user is billed to the cost center.
106+
* If a user belongs to a cost center, all charges associated with the user are billed to the cost center.
107107
* If a user does not belong to any cost center, usage is charged to the enterprise's default payment method and grouped under "Enterprise Only" spending on the usage page.
108108

109109
### Cost center allocation for {% data variables.product.prodname_enterprise %}

package-lock.json

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@
313313
"remark-parse": "^11.0.0",
314314
"remark-rehype": "^11.1.0",
315315
"remark-remove-comments": "^1.0.1",
316+
"remark-stringify": "^11.0.0",
316317
"rss-parser": "^3.13.0",
317318
"scroll-anchoring": "^0.1.0",
318319
"semver": "^7.6.2",

src/content-render/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { renderLiquid } from './liquid/index.js'
2-
import { renderUnified } from './unified/index.js'
2+
import { renderMarkdown, renderUnified } from './unified/index.js'
33
import { engine } from './liquid/engine.js'
44

55
const globalCache = new Map()
@@ -26,6 +26,12 @@ export async function renderContent(template = '', context = {}, options = {}) {
2626
}
2727
try {
2828
template = await renderLiquid(template, context)
29+
if (context.markdownRequested) {
30+
const md = await renderMarkdown(template, context, options)
31+
32+
return md
33+
}
34+
2935
const html = await renderUnified(template, context, options)
3036
if (cacheKey) {
3137
globalCache.set(cacheKey, html)

src/content-render/unified/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { fastTextOnly } from './text-only.js'
2-
import { createProcessor } from './processor.js'
2+
import { createProcessor, createMarkdownOnlyProcessor } from './processor.js'
33

44
export async function renderUnified(template, context, options) {
55
const processor = createProcessor(context)
@@ -12,3 +12,11 @@ export async function renderUnified(template, context, options) {
1212

1313
return html.trim()
1414
}
15+
16+
export async function renderMarkdown(template, context, options) {
17+
const processor = createMarkdownOnlyProcessor(context)
18+
const vFile = await processor.process(template)
19+
let markdown = vFile.toString()
20+
21+
return markdown.trim()
22+
}

src/content-render/unified/processor.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import annotate from './annotate.js'
2929
import alerts from './alerts.js'
3030
import replaceDomain from './replace-domain.js'
3131
import removeHtmlComments from 'remark-remove-comments'
32+
import remarkStringify from 'remark-stringify'
3233

3334
export function createProcessor(context) {
3435
return (
@@ -79,6 +80,10 @@ export function createProcessor(context) {
7980
)
8081
}
8182

83+
export function createMarkdownOnlyProcessor(context) {
84+
return unified().use(remarkParse).use(gfm).use(remarkStringify)
85+
}
86+
8287
export function createMinimalProcessor(context) {
8388
return unified()
8489
.use(remarkParse)

src/fixtures/tests/permissions-callout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('permission statements', () => {
3636
})
3737

3838
test('page with permission frontmatter and product statement', async () => {
39-
const $ = await getDOM('/get-started/foo/page-with-permissions-and-product-callout.md')
39+
const $ = await getDOM('/get-started/foo/page-with-permissions-and-product-callout')
4040
const html = $('[data-testid=permissions-callout] div').html()
4141
// part of the UI
4242
expect(html).toMatch('Who can use this feature')

src/frame/middleware/context/context.ts

+8
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ export default async function contextualize(
3838

3939
req.context.process = { env: {} }
4040

41+
if (req.pagePath && req.pagePath.endsWith('.md')) {
42+
req.context.markdownRequested = true
43+
44+
// req.pagePath is used later in the rendering pipeline to
45+
// locate the file in the tree so it cannot have .md
46+
req.pagePath = req.pagePath.replace(/\/index\.md$/, '').replace(/\.md$/, '')
47+
}
48+
4149
// define each context property explicitly for code-search friendliness
4250
// e.g. searches for "req.context.page" will include results from this file
4351
req.context.currentLanguage = req.language

src/frame/middleware/render-page.ts

+9
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ export default async function renderPage(req: ExtendedRequest, res: Response) {
190190
}
191191
}
192192

193+
if (context.markdownRequested) {
194+
if (!page.autogenerated && page.documentType === 'article') {
195+
return res.type('text/markdown').send(req.context.renderedPage)
196+
} else {
197+
const newUrl = req.originalUrl.replace(req.path, req.path.replace(/\.md$/, ''))
198+
return res.redirect(newUrl)
199+
}
200+
}
201+
193202
defaultCacheControl(res)
194203

195204
return nextHandleRequest(req, res)

src/shielding/middleware/handle-invalid-paths.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,11 @@ export default function handleInvalidPaths(
8383
return res.status(404).send('Not found')
8484
}
8585

86-
if (req.path.endsWith('/index.md') || req.path.endsWith('.md')) {
86+
if (req.path.endsWith('/index.md')) {
8787
defaultCacheControl(res)
8888
// The originalUrl is the full URL including query string.
8989
// E.g. `/en/foo.md?bar=baz`
90-
const newUrl = req.originalUrl.replace(
91-
req.path,
92-
req.path.replace(/\/index\.md$/, '').replace(/\.md$/, ''),
93-
)
90+
const newUrl = req.originalUrl.replace(req.path, req.path.replace(/\/index\.md$/, ''))
9491
return res.redirect(newUrl)
9592
}
9693

src/shielding/tests/shielding.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ describe('index.md and .md suffixes', () => {
7171
}
7272
})
7373

74-
test('any URL that ends with /.md redirects', async () => {
74+
// TODO-ARTICLEAPI: unskip tests or replace when ready to ship article API
75+
test.skip('any URL that ends with /.md redirects', async () => {
7576
// With language prefix
7677
{
7778
const res = await get('/en/get-started/hello.md')

src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ export type Context = {
165165
currentLearningTrack?: LearningTrack | null
166166
renderedPage?: string
167167
miniTocItems?: string | undefined
168+
markdownRequested?: boolean
168169
}
169170
export type LearningTracks = {
170171
[group: string]: {

0 commit comments

Comments
 (0)