Skip to content
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

feat: update title of question page #3443

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions packages/cypress/src/integration/questions/read.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('[Questions]', () => {

cy.step('Can visit question')
cy.visit(`/questions/${question.slug}`)
cy.title().should('eq', question.title)

cy.step('All metadata visible')
cy.contains(`${question.subscribers.length} following`)
Expand Down
1 change: 1 addition & 0 deletions src/pages/Question/QuestionListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const QuestionListing = () => {
const sort = searchParams.get('sort') as QuestionSortOption

useEffect(() => {
document.title = 'Questions'
if (!sort) {
// ensure sort is set
const params = new URLSearchParams(searchParams.toString())
Expand Down
10 changes: 3 additions & 7 deletions src/pages/Question/QuestionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { Breadcrumbs } from 'src/pages/common/Breadcrumbs/Breadcrumbs'
import { useQuestionStore } from 'src/stores/Question/question.store'
import { formatImagesForGallery } from 'src/utils/formatImageListForGallery'
import { buildStatisticsLabel } from 'src/utils/helpers'
import { incrementViewCount } from 'src/utils/incrementViewCount'
import { Box, Button, Card, Divider, Flex, Heading, Text } from 'theme-ui'

import { ContentAuthorTimestamp } from '../common/ContentAuthorTimestamp/ContentAuthorTimestamp'
Expand Down Expand Up @@ -50,13 +49,10 @@ export const QuestionPage = () => {
}

store.activeQuestionItem = foundQuestion
incrementViewCount({
document: foundQuestion,
documentType: 'question',
store,
})
store.incrementViewCount(foundQuestion._id)

setQuestion(foundQuestion)
document.title = foundQuestion.title
setIsLoading(false)
}

Expand Down Expand Up @@ -164,7 +160,7 @@ export const QuestionPage = () => {
{
icon: 'view',
label: buildStatisticsLabel({
stat: question.total_views,
stat: question.total_views || 0,
statUnit: 'view',
usePlural: true,
}),
Expand Down
Loading