Skip to content

Commit

Permalink
Merge pull request #331 from visualize-admin/feat/page-titles
Browse files Browse the repository at this point in the history
Page titles
  • Loading branch information
ptbrowne authored Feb 7, 2022
2 parents 49fbe37 + 700f952 commit c6fec51
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
9 changes: 9 additions & 0 deletions app/components/chart-preview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Trans } from "@lingui/macro";
import Head from "next/head";
import * as React from "react";
import { Box, Flex, Text } from "theme-ui";
import { ChartDataFilters } from "../charts/shared/chart-data-filters";
Expand Down Expand Up @@ -65,6 +66,14 @@ export const ChartPreview = ({ dataSetIri }: { dataSetIri: string }) => {
state.meta.title[locale]
)}
</Text>
<Head>
<title key="title">
{state.meta.title[locale] === ""
? metaData?.dataCubeByIri?.title
: state.meta.title[locale]}{" "}
- visualize.admin.ch
</title>
</Head>
<Text
variant="paragraph1"
sx={{
Expand Down
6 changes: 6 additions & 0 deletions app/configurator/components/dataset-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useLocale } from "../../locales/use-locale";
import { DataCubePublicationStatus } from "../../graphql/resolver-types";
import DebugPanel from "../../components/debug-panel";
import LinkButton from "./link-button";
import Head from "next/head";

export interface Preview {
iri: string;
Expand Down Expand Up @@ -44,6 +45,11 @@ export const DataSetPreview = ({ dataSetIri }: { dataSetIri: string }) => {
<Flex
sx={{ alignItems: "center", justifyContent: "space-between", mb: 6 }}
>
<Head>
<title key="title">
{dataCubeByIri.title} - visualize.admin.ch
</title>
</Head>
<Text as="div" variant="heading1">
{dataCubeByIri.title}
</Text>
Expand Down
20 changes: 19 additions & 1 deletion app/configurator/components/select-dataset-step.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Trans } from "@lingui/macro";
import { t, Trans } from "@lingui/macro";
import Head from "next/head";
import NextLink from "next/link";
import { Router, useRouter } from "next/router";
import React, { useMemo } from "react";
Expand Down Expand Up @@ -171,9 +172,26 @@ export const SelectDatasetStepContent = () => {
);
};

const PageTitle = () => {
const { search, filters } = useBrowseContext();
return (
<Head>
<title key="title">
{search
? `"${search}"`
: filters?.length > 0 && filters[0].__typename !== "DataCubeAbout"
? filters[0].label
: t({ id: "browse.datasets.all-datasets" })}{" "}
- visualize.admin.ch
</title>
</Head>
);
};

export const SelectDatasetStep = () => {
return (
<BrowseStateProvider>
<PageTitle />
<SelectDatasetStepContent />
</BrowseStateProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion app/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ msgstr "Create visualization"

#: app/configurator/components/select-dataset-step.tsx:133
msgid "browse.datasets.all-datasets"
msgstr "All Datasets"
msgstr "All datasets"

#: app/configurator/components/select-dataset-step.tsx:145
msgid "browse.datasets.description"
Expand Down
2 changes: 1 addition & 1 deletion app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default function App({ Component, pageProps }: AppProps) {
return (
<>
<Head>
<title>visualize.admin.ch</title>
<title key="title">visualize.admin.ch</title>
<meta property="og:type" content="website" />
<meta property="og:title" content={"visualize.admin.ch"} />
<meta property="og:url" content={`${PUBLIC_URL}${asPath}`} />
Expand Down

0 comments on commit c6fec51

Please sign in to comment.