Skip to content

repo sync #25198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 24, 2023
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
21 changes: 21 additions & 0 deletions src/pageinfo/tests/pageinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,25 @@ describe('pageinfo api', () => {
const { info } = JSON.parse(res.body)
expect(info.title).toBe('GitHub Fixture Documentation')
})

test('a page that uses non-trivial Liquid to render', async () => {
// This page uses `{% ifversion not fpt %}` in the intro.

// First on the fpt version
{
const res = await get('/api/pageinfo/v1?pathname=/en/get-started/liquid/ifversion')
expect(res.statusCode).toBe(200)
const { info } = JSON.parse(res.body)
expect(info.intro).toMatch(/\(on fpt\)/)
}
// Second on any other version
{
const res = await get(
`/api/pageinfo/v1?pathname=/en/enterprise-server@latest/get-started/liquid/ifversion`
)
expect(res.statusCode).toBe(200)
const { info } = JSON.parse(res.body)
expect(info.intro).toMatch(/\(not on fpt\)/)
}
})
})
10 changes: 0 additions & 10 deletions src/search/components/SearchResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import cx from 'classnames'

import type { SearchResultsT, SearchResultHitT } from './types'
import { useTranslation } from 'components/hooks/useTranslation'
import { useNumberFormatter } from 'components/hooks/useNumberFormatter'
import { Link } from 'components/Link'
import { useQuery } from 'components/hooks/useQuery'
import { sendEvent, EventType } from 'src/events/browser'
Expand All @@ -17,20 +16,11 @@ type Props = {
query: string
}
export function SearchResults({ results, query }: Props) {
const { t } = useTranslation('search')
const { formatInteger } = useNumberFormatter()

const pages = Math.ceil(results.meta.found.value / results.meta.size)
const { page } = results.meta

return (
<div>
<Text role={'status'}>
{results.meta.found.value === 1
? t('one_result')
: t('n_results').replace('{n}', formatInteger(results.meta.found.value))}
</Text>
<br />
<SearchResultHits hits={results.hits} query={query} />
{pages > 1 && <ResultsPagination page={page} totalPages={pages} />}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/search/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function Search() {
</Head>
{hasQuery && (
<Heading as="h1" className="mb-2">
{t('search_results_for')} "{query.trim()}"
{pageTitle}
</Heading>
)}

Expand Down
4 changes: 1 addition & 3 deletions tests/fixtures/content/get-started/liquid/ifversion.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Ifversion liquid tag
intro: Tests functionality of `ifversion` and its operators
intro: 'Tests functionality of `ifversion` and its operators {% ifversion not fpt %}(not on fpt){% else %}(on fpt){% endif %}'
versions:
fpt: '*'
ghes: '*'
Expand Down Expand Up @@ -29,7 +29,6 @@ condition-d
condition-e
{% endif %}


## ifversion with ranges

{% ifversion ghes > 3.4 %}
Expand Down Expand Up @@ -78,4 +77,3 @@ condition-m
{% ifversion not fpt and ghes > 3.4 %}
condition-o
{% endif %}