Skip to content

Commit

Permalink
fixing localeSelector by including page slug into graphql localeData …
Browse files Browse the repository at this point in the history
…fetch
  • Loading branch information
sergey-orangit committed Jan 20, 2025
1 parent 9d67dd0 commit 03caab8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
4 changes: 4 additions & 0 deletions configs/createPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ async function handleActivity(
locale: activity.locale,
id: activity.id,
strapi_id: activity.strapi_id,
slug: activityPath,
},
};

Expand Down Expand Up @@ -150,6 +151,7 @@ async function handleActivityGroup(
id: activityGroup?.id,
strapi_id: activityGroup?.strapi_id,
ageGroupId: activityGroupData?.age_group.strapi_id,
slug: activityGroupPath,
},
};

Expand Down Expand Up @@ -190,6 +192,7 @@ async function handleAgeGroup(
locale: ageGroup?.locale,
id: ageGroup.id,
strapi_id: ageGroup.strapi_id,
slug: ageGroupPath,
},
};

Expand Down Expand Up @@ -360,6 +363,7 @@ async function createContentPage(
locale: pageDataResponse.data?.strapiContentPage.locale,
id: pageDataResponse?.data?.strapiContentPage.id,
strapi_id: pageDataResponse?.data?.strapiContentPage.strapi_id,
slug: pagePath,
},
};

Expand Down
1 change: 1 addition & 0 deletions configs/typeDefs.gql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type SitePageContext @dontInfer {
id: Int!
strapi_id: Int
ageGroupId: Int
slug: String
}

type ActivityLogo implements Node @dontInfer {
Expand Down
3 changes: 2 additions & 1 deletion src/templates/activityGroupTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ query Query(
$strapi_id: Int,
$locale: String,
$ageGroupId: Int,
$slug: String,
) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale } } }) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale }, slug: { eq: $slug } } }) {
nodes {
...SitePageLocaleFragment
}
Expand Down
9 changes: 7 additions & 2 deletions src/templates/activityTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ const ActivityPageTemplate = ({ path, data }: PageProps<ActivityQueryType, Activ
export default ActivityPageTemplate;

export const query = graphql`
query getActivity($strapi_id: Int, $locale: String, $type: String) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale }, type: { eq: $type } } }) {
query getActivity(
$strapi_id: Int,
$locale: String,
$type: String,
$slug: String,
) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale }, type: { eq: $type }, slug: { eq: $slug } } }) {
nodes {
...SitePageLocaleFragment
}
Expand Down
9 changes: 7 additions & 2 deletions src/templates/ageGroupTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ const AgeGroupTemplate = ({ path, data }: PageProps<QueryType, AgeGroupPageTempl
export default AgeGroupTemplate;

export const query = graphql`
query AgeGroupQuery($locale: String, $strapi_id: Int, $id: String) {
query AgeGroupQuery(
$locale: String,
$strapi_id: Int,
$id: String,
$slug: String,
) {
localeData: allSitePage(
filter: {context: {locale: {eq: $locale}, type: {eq: "ActivityGroup"}}}
filter: {context: {locale: {eq: $locale}, type: {eq: "ActivityGroup"}, slug: { eq: $slug }}}
) {
nodes {
...SitePageLocaleFragment
Expand Down
9 changes: 7 additions & 2 deletions src/templates/contentPageTemplate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,13 @@ const ContentPageTemplate = ({ path, data }: PageProps<ContentPageQueryType, Con
export default ContentPageTemplate;

export const query = graphql`
query getContentPage($locale: String, $type: String, $id: String) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale }, type: { eq: $type } } }) {
query getContentPage(
$locale: String,
$type: String,
$id: String,
$slug: String,
) {
localeData: allSitePage(filter: { context: { locale: { eq: $locale }, type: { eq: $type }, slug: { eq: $slug } } }) {
nodes {
...SitePageLocaleFragment
}
Expand Down

0 comments on commit 03caab8

Please sign in to comment.