Skip to content

Commit

Permalink
Merge pull request #41 from inclusion-numerique/dev
Browse files Browse the repository at this point in the history
Add sitemap, update dependencies, fix CircleCI config
  • Loading branch information
aurelientanguy committed Nov 2, 2023
2 parents c3c3019 + 23d239b commit 094d828
Show file tree
Hide file tree
Showing 18 changed files with 5,854 additions and 3,217 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ commands:
command: |
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install terraform
sudo apt update && sudo apt install terraform=1.5.7-*
install_dependencies:
steps:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ storybook-static

# Temporary only
/mssweb
/apps/cms

apps/web/public/images/grist-attachments/
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
6 changes: 3 additions & 3 deletions apps/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"axios-retry": "^3.4.0",
"commander": "^10.0.0",
"csv-parse": "^5.3.6",
"csv-stringify": "^6.3.0",
"csv-stringify": "^6.4.4",
"dotenv": "^16.0.3",
"form-data": "^4.0.0",
"lodash": "^4.17.21",
Expand All @@ -30,8 +30,8 @@
"slug": "^8.2.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"undici": "^5.21.0",
"zod": "^3.21.4"
"undici": "^5.27.0",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/lodash": "^4.14.192",
Expand Down
9 changes: 9 additions & 0 deletions apps/web/next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @type {import('next-sitemap').IConfig} */

import { getServerUrl } from '@sde/web/utils/baseUrl';

module.exports = {
// siteUrl: 'https://solutionsdelus.gouv.fr',
siteUrl: getServerUrl(),
generateRobotsTxt: true,
};
1 change: 0 additions & 1 deletion apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ const nextConfig = {
reactStrictMode: true,
transpilePackages: ['@sde/emails'],
experimental: {
appDir: true,
// See https://beta.nextjs.org/docs/api-reference/next.config.js#servercomponentsexternalpackages
serverComponentsExternalPackages: [
'nanoid',
Expand Down
108 changes: 55 additions & 53 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"dev": "pnpm --silent with-env next dev",
"build": "pnpm --silent with-env next build",
"postbuild": "next-sitemap",
"modclean": "modclean -Pr",
"modclean:root": "modclean -Pr -p ./../..",
"start": "next start",
Expand All @@ -30,92 +31,93 @@
"node": "^18.16"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.304.0",
"@aws-sdk/s3-request-presigner": "^3.304.0",
"@gouvfr/dsfr": "^1.9.0",
"@hookform/resolvers": "^3.0.0",
"@next-auth/prisma-adapter": "^1.0.5",
"@prisma/client": "^4.12.0",
"@react-spring/web": "^9.7.1",
"@aws-sdk/client-s3": "^3.438.0",
"@aws-sdk/s3-request-presigner": "^3.438.0",
"@gouvfr/dsfr": "^1.10.2",
"@hookform/resolvers": "^3.3.2",
"@next-auth/prisma-adapter": "^1.0.7",
"@prisma/client": "^5.5.2",
"@react-spring/web": "^9.7.3",
"@sde/emails": "*",
"@sde/storybook": "*",
"@sentry/browser": "^7.46.0",
"@sentry/nextjs": "^7.46.0",
"@tanstack/react-query": "^4.28.0",
"@trpc/client": "^10.18.0",
"@trpc/react-query": "^10.18.0",
"@trpc/server": "^10.18.0",
"@sentry/browser": "^7.77.0",
"@sentry/nextjs": "^7.77.0",
"@tanstack/react-query": "^4.36.1",
"@trpc/client": "^10.43.0",
"@trpc/react-query": "^10.43.0",
"@trpc/server": "^10.43.0",
"axios": "^1.3.4",
"chart.js": "^4.2.1",
"chart.js": "^4.4.0",
"client-only": "^0.0.1",
"copy": "^0.3.2",
"csv-stringify": "^6.3.0",
"date-fns": "^2.29.3",
"csv-stringify": "^6.4.4",
"date-fns": "^2.30.0",
"decimal.js": "^10.4.3",
"deep-object-diff": "^1.1.9",
"dotenv": "^16.0.3",
"dotenv-cli": "^7.1.0",
"encoding": "^0.1.13",
"env-var": "^7.3.0",
"env-var": "^7.4.1",
"file-saver": "^2.0.5",
"form-data": "^4.0.0",
"fuse.js": "^6.6.2",
"js-cookie": "^3.0.1",
"js-file-downloader": "^1.1.24",
"maplibre-gl": "^2.4.0",
"fuse.js": "^7.0.0",
"js-cookie": "^3.0.5",
"js-file-downloader": "^1.1.25",
"maplibre-gl": "^3.5.2",
"nanoid": "^3.3.6",
"next": "^13.2.4",
"next-auth": "^4.21.1",
"node-html-parser": "^6.1.5",
"nodemailer": "^6.9.1",
"prisma": "^4.12.0",
"next": "^14.0.1",
"next-auth": "^4.24.4",
"next-sitemap": "^4.2.3",
"node-html-parser": "^6.1.11",
"nodemailer": "^6.9.7",
"prisma": "^5.5.2",
"react": "^18.2.0",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.2.0",
"react-dropzone": "^14.2.3",
"react-hook-form": "^7.43.9",
"react-intersection-observer": "^9.4.3",
"react-loader-spinner": "^5.3.4",
"react-swipeable": "^7.0.0",
"react-textarea-autosize": "^8.4.1",
"react-hook-form": "^7.47.0",
"react-intersection-observer": "^9.5.2",
"react-loader-spinner": "^5.4.5",
"react-swipeable": "^7.0.1",
"react-textarea-autosize": "^8.5.3",
"react-use-css-custom-property": "^0.1.1",
"scroll-into-view-if-needed": "^3.0.6",
"scroll-into-view-if-needed": "^3.1.0",
"server-only": "^0.0.1",
"sharp": "^0.32.0",
"smooth-scroll-into-view-if-needed": "^2.0.0",
"superjson": "^1.12.2",
"sharp": "^0.32.6",
"smooth-scroll-into-view-if-needed": "^2.0.2",
"superjson": "^2.2.0",
"uglify-js": "^3.17.4",
"undici": "^5.21.0",
"uuid": "^9.0.0",
"zod": "^3.21.4",
"zustand": "^4.3.7"
"undici": "^5.27.0",
"uuid": "^9.0.1",
"zod": "^3.22.4",
"zustand": "^4.4.5"
},
"devDependencies": {
"@next/bundle-analyzer": "^13.2.4",
"@next/bundle-analyzer": "^14.0.1",
"@sde/test": "*",
"@types/file-saver": "^2.0.5",
"@types/js-cookie": "^3.0.3",
"@types/mime-types": "^2.1.1",
"@types/file-saver": "^2.0.6",
"@types/js-cookie": "^3.0.5",
"@types/mime-types": "^2.1.3",
"@types/node": "^18.16.13",
"@types/nodemailer": "^6.4.7",
"@types/nprogress": "^0.2.0",
"@types/react": "^18.0.32",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1",
"css-loader": "^6.7.3",
"@types/nodemailer": "^6.4.13",
"@types/nprogress": "^0.2.2",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@types/uuid": "^9.0.6",
"css-loader": "^6.8.1",
"eslint": "^8.37.0",
"jest": "^29.5.0",
"joi": "^17.9.1",
"modclean": "^3.0.0-beta.1",
"postcss": "^8.4.21",
"postcss": "^8.4.31",
"postcss-flexbugs-fixes": "^5.0.2",
"postcss-import": "^15.1.0",
"postcss-loader": "^7.1.0",
"postcss-loader": "^7.3.3",
"postcss-nested": "^6.0.1",
"postcss-preset-env": "^8.3.0",
"postcss-preset-env": "^9.2.0",
"react-is": "^18.2.0",
"require-from-string": "^2.0.2",
"style-loader": "^3.3.2",
"style-loader": "^3.3.3",
"typescript": "^5.0.3"
}
}
4 changes: 2 additions & 2 deletions apps/web/src/app/(public)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ export default async function HomePage() {
</div>
{categories.map((category) => (
<div key={category} className="fr-col-12 fr-col-md-6 fr-col-lg-4">
<div className="fr-tile fr-tile--horizontal fr-enlarge-link">
<div className="fr-tile__body fr-m-4v">
<div className="fr-tile fr-tile--horizontal fr-tile--sm fr-enlarge-link">
<div className="fr-tile__body">
<h4 className="fr-tile__title fr-mb-0">
<Link href={categoryProjectsLink(category)}>
{category}
Expand Down
18 changes: 15 additions & 3 deletions apps/web/src/app/(public)/projets/[slug]/Localization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import styles from './Localization.module.css'

const Localization = ({
project,
collectiviteUrl,
className,
}: {
project: ProjectItem
collectiviteUrl?: string;
className?: string
}) => (
<div className={className ?? ''}>
Expand All @@ -19,9 +21,19 @@ const Localization = ({
) : null}
<div className={`fr-p-6v ${styles.bloc}`}>
<h2 className="fr-mb-0 fr-text-title--blue-france">Le territoire</h2>
<p className="fr-mt-6v fr-mb-0 fr-text--bold">
{project.localization.label}
</p>
{project.localization.echelon === 'commune' ?
(
<p className="fr-mt-6v fr-mb-0 fr-text--bold">
<a href={collectiviteUrl} target="_blank">
{project.localization.label}
</a>
</p>
) : (
<p className="fr-mt-6v fr-mb-0 fr-text--bold">
{project.localization.label}
</p>
)
}
{/* No need to display departments for projects with region echelon */}
{project.localization.echelon !== 'region' &&
project.localization.departmentName ? (
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/app/(public)/projets/[slug]/Project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Quotes from './Quotes'
import styles from './Project.module.css'
import SocialNetworks from './SocialNetworks'

const Project = ({ project }: { project: ProjectItem }) => {
const Project = ({ project, collectiviteUrl }: { project: ProjectItem, collectiviteUrl?: string }) => {
const coverPicture = (
<picture>
<img
Expand Down Expand Up @@ -66,7 +66,7 @@ const Project = ({ project }: { project: ProjectItem }) => {
className="fr-hidden-lg fr-mt-12v"
url={getServerUrl(getProjectPath(project))}
/>
<Localization project={project} className="fr-hidden-lg fr-mt-12v" />
<Localization project={project} collectiviteUrl={collectiviteUrl} className="fr-hidden-lg fr-mt-12v" />
<Blocs className="fr-mt-6v" project={project} />
{project.funding ? (
<>
Expand Down Expand Up @@ -146,7 +146,7 @@ const Project = ({ project }: { project: ProjectItem }) => {
className="fr-mt-8v"
url={getServerUrl(getProjectPath(project))}
/>
<Localization className="fr-mt-8v" project={project} />
<Localization className="fr-mt-8v" project={project} collectiviteUrl={collectiviteUrl} />
</div>
</div>
</>
Expand Down
36 changes: 34 additions & 2 deletions apps/web/src/app/(public)/projets/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,44 @@ export async function generateMetadata({
}
}

type Collectivite = {
city: string;
zip_code: string;
slug: string;
slug_alias: string;
region: string;
}

type Localization = {
label: string;
department: string | null;
departmentName: string | null;
regionName: string | null;
population: number | null;
echelon: string;
}

const getCollectiviteUrl = async (localization: Localization) => {
const res = await fetch(`https://api.collectivite.fr/api/commune/search/${encodeURIComponent(localization.label)}`)
const data = await res.json()

const sameName = data.filter((item: Collectivite) => item.city.toLowerCase() === localization.label.toLowerCase())
const target = sameName.find((item: Collectivite) =>
item.zip_code ? item.zip_code.startsWith(localization.department || '') : true
)
const slug = target.slug_alias || target.slug || ""

return `https://collectivite.fr/${slug}`;
};

const ProjectPage = async ({ params }: { params: { slug: string } }) => {
const project = await getProject(params.slug)
if (!project) {
notFound()
return {}
}
const collectiviteUrl = project.localization.echelon === 'commune' ?
await getCollectiviteUrl(project.localization) : ""

return (
<div className="fr-container">
Expand All @@ -67,7 +99,7 @@ const ProjectPage = async ({ params }: { params: { slug: string } }) => {
<ol className="fr-breadcrumb__list">
<li>
<Link className="fr-breadcrumb__link" href="/">
Accueil
Solutions d&apos;élus
</Link>
</li>
<li>
Expand All @@ -89,7 +121,7 @@ const ProjectPage = async ({ params }: { params: { slug: string } }) => {
>
Retour à la liste des projets
</Link>
<Project project={project} />
<Project project={project} collectiviteUrl={collectiviteUrl} />
</div>
)
}
Expand Down
Loading

0 comments on commit 094d828

Please sign in to comment.