-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: robots.txt - ui headers - typescript error (#1680)
* fix: remove duplicate headers (nginx) and log * fix: robots.txt & ts error
- Loading branch information
Showing
9 changed files
with
89 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { MetadataRoute } from "next" | ||
|
||
import { publicConfig } from "../config.public" | ||
|
||
const getRobotRules = () => { | ||
const { env } = publicConfig | ||
switch (env) { | ||
case "production": | ||
return { | ||
rules: { | ||
userAgent: "*", | ||
disallow: ["/test-widget", "/recherche-apprentissage", "/recherche-apprentissage-formation", "/recherche-emploi"], | ||
}, | ||
sitemap: "https://labonnealternance.apprentissage.beta.gouv.fr/sitemap.xml", | ||
} | ||
|
||
default: | ||
return { | ||
rules: { | ||
userAgent: "*", | ||
disallow: "/", | ||
}, | ||
sitemap: "", | ||
} | ||
} | ||
} | ||
|
||
export default function Robots(): MetadataRoute.Robots { | ||
return getRobotRules() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,40 @@ | ||
export const buildLinkForTownAndJob = (town, job) => { | ||
const result = `/recherche-apprentissage?&display=list&displayMap=false&job_name=${encodeURIComponent(job.name)}&romes=${job.romes.join(",")}${ | ||
town.name !== "France" ? `&radius=30&lat=${town.lat}&lon=${town.lon}&zipcode=${town.zip}&insee=${town.insee}&address=${encodeURIComponent(town.name)}` : "" | ||
}` | ||
return result | ||
import { UrlObject } from "url" | ||
|
||
interface Town { | ||
name: string | ||
lat?: number | ||
lon?: number | ||
zip?: string | ||
insee?: string | ||
} | ||
|
||
interface Job { | ||
name: string | ||
romes: string[] | ||
} | ||
|
||
export const buildLinkForTownAndJob = (town: Town, job: Job): UrlObject => { | ||
const pathname = "/recherche-apprentissage" | ||
const query: Record<string, string | boolean | string[]> = { | ||
display: "list", | ||
displayMap: false, | ||
job_name: encodeURIComponent(job.name), | ||
romes: job.romes.join(","), | ||
} | ||
|
||
if (town.name !== "France") { | ||
Object.assign(query, { | ||
radius: "30", | ||
lat: town.lat.toString(), | ||
lon: town.lon.toString(), | ||
zipcode: town.zip, | ||
insee: town.insee, | ||
address: encodeURIComponent(town.name), | ||
}) | ||
} | ||
|
||
return { | ||
pathname, | ||
query, | ||
} | ||
} |