Skip to content

Commit

Permalink
fix(frontend): backlink (#1339)
Browse files Browse the repository at this point in the history
* fix(frontend): backlink

* refactor(frontend): remove useless param

* fix(frontend): apply feedbacks

* fix(frontend): header link
  • Loading branch information
UnbearableBear authored Sep 27, 2019
1 parent 9588ae0 commit 830187a
Show file tree
Hide file tree
Showing 24 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ exports[`<About /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ exports[`<Annuaire /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ exports[`<CodeDuTravail /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ exports[`<DroitDuTravail /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ exports[`<FicheMT /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ exports[`<FicheSP /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ exports[`<Term /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ exports[`<Glossaire /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ exports[`<Home /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ exports[`<MentionLegales /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ exports[`<ModelesDeCourriers /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ exports[`<Outils /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ exports[`<Question /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ exports[`<Recherche /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ exports[`<Theme /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
11 changes: 5 additions & 6 deletions packages/code-du-travail-frontend/pages/themes/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const {

// Theme page
class Theme extends React.Component {
static async getInitialProps({ query: { slug: query } }) {
static async getInitialProps({ query: { slug } }) {
const searchThemeResponse = await fetch(
`${API_URL}/themes${query ? `/${query}` : ""}`
`${API_URL}/themes${slug ? `/${slug}` : ""}`
);

if (!searchThemeResponse.ok) {
Expand All @@ -31,13 +31,12 @@ class Theme extends React.Component {
const theme = await searchThemeResponse.json();

return {
theme,
query
theme
};
}

render() {
const { theme = { children: [] }, query, pageUrl, ogImage } = this.props;
const { theme = { children: [] }, pageUrl, ogImage } = this.props;

const isRootTheme = theme && !theme.slug;

Expand Down Expand Up @@ -66,7 +65,7 @@ class Theme extends React.Component {
)}
{!isRootTheme && theme.refs.length > 0 && (
<Section>
<SearchResults query={query} items={theme.refs} />
<SearchResults items={theme.refs} />
</Section>
)}
</PageLayout>
Expand Down
2 changes: 1 addition & 1 deletion packages/code-du-travail-frontend/src/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Header = () => (
<StyledHeader>
<Container>
<Wrapper>
<Link href="/?q=" passHref>
<Link href="/" passHref>
<LogoWrapper title="Code du travail numérique - retour à l'accueil">
<Logo
src={"/static/assets/img/marianne.svg"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ exports[`<Header /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ exports[`<HomeLayout /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ exports[`<PageLayout /> should render 1`] = `
>
<a
class="c3"
href="/?q="
href="/"
title="Code du travail numérique - retour à l'accueil"
>
<img
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ export const Law = ({ items, query }) => (
<Link
href={{
pathname: `/${getRouteBySource(item.source)}/[slug]`,
query: { q: query, slug: item.slug }
query: {
...(query && { q: query }),
slug: item.slug
}
}}
as={`/${getRouteBySource(item.source)}/${item.slug}?q=${query}`}
as={`/${getRouteBySource(item.source)}/${item.slug}${
query ? `?q=${query}` : ""
}`}
passHref
>
<LargeLink icon={getSourceIcon(item.source)}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ const ListLink = ({
<Link
href={{
pathname: `/${getRouteBySource(source)}/[slug]`,
query: { q: query, slug: slug }
query: { ...(query && { q: query }), slug: slug }
}}
as={`/${getRouteBySource(source)}/${slug}?q=${query}`}
as={`/${getRouteBySource(source)}/${slug}${query ? `?q=${query}` : ""}`}
passHref
>
<LargeLink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,14 @@ export const Themes = ({ items, query }) => (
<Link
href={{
pathname: `/${getRouteBySource(item.source)}/[slug]`,
query: { q: query, slug: item.slug }
query: {
...(query && { q: query }),
slug: item.slug
}
}}
as={`/${getRouteBySource(item.source)}/${item.slug}?q=${query}`}
as={`/${getRouteBySource(item.source)}/${item.slug}${
query ? `?q=${query}` : ""
}`}
passHref
>
<LargeLink icon={getSourceIcon(item.source)}>
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"@babel/helper-remap-async-to-generator" "^7.1.0"
"@babel/plugin-syntax-async-generators" "^7.2.0"

"@babel/[email protected]", "@babel/[email protected]", "@babel/plugin-proposal-class-properties@7.6.2", "@babel/plugin-proposal-class-properties@^7.5.5":
"@babel/[email protected]", "@babel/[email protected]", "@babel/plugin-proposal-class-properties@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.5.5.tgz#a974cfae1e37c3110e71f3c6a2e48b8e71958cd4"
integrity sha512-AF79FsnWFxjlaosgdi421vmYG6/jg79bVD0dpD44QdgobzHKuLZ6S3vl8la9qIeSwGi8i1fS0O1mfuDAAdo1/A==
Expand Down

0 comments on commit 830187a

Please sign in to comment.