Skip to content

Commit

Permalink
chore: clean up baseUrl (#30)
Browse files Browse the repository at this point in the history
* chore: clean up baseUrl
* fix: add vercel url fallback | mkn, poe
* fix: revert port change; move package to devDependencies | mkn
  • Loading branch information
MarcelKnobelsdorf authored Nov 13, 2023
1 parent 007aede commit 6171183
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Build with Next.js
run: yarn build
env:
BASE_URL: "opensource.porsche.com"
BASE_URL: "https://opensource.porsche.com"
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@types/node": "20.5.7",
"@types/react": "18.2.21",
"@types/react-dom": "18.2.7",
"dotenv": "16.3.1",
"eslint": "8.48.0",
"http-server": "14.1.1",
"js-yaml-loader": "1.2.2",
Expand Down
6 changes: 3 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import path from "path";
import dotenv from "dotenv";
// eslint-disable-next-line import/no-extraneous-dependencies
import { defineConfig, devices } from "@playwright/test";

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

dotenv.config({ path: path.resolve(__dirname, ".env.local") });
/**
* See https://playwright.dev/docs/test-configuration.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const siteConfig = {
};

export const metadata: Metadata = {
metadataBase: new URL(`https://${BASE_URL}`),
metadataBase: new URL(`${BASE_URL}`),
title: siteConfig.title,
description: siteConfig.description,
alternates: {
Expand Down
10 changes: 5 additions & 5 deletions src/app/sitemap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ import { BASE_URL } from "../config";

const Sitemap = (): MetadataRoute.Sitemap => {
const blogs = allBlogs.map((doc) => ({
url: `https://${BASE_URL}${doc.slug}`,
url: `${BASE_URL}${doc.slug}`,
lastModified: format(parseISO(doc.date), "yyyy-MM-dd"),
}));
const docs = allDocs.map((doc) => ({
url: `https://${BASE_URL}${doc.slug}`,
url: `${BASE_URL}${doc.slug}`,
lastModified: format(parseISO(doc.date), "yyyy-MM-dd"),
}));

const staticPaths = [
{
url: `https://${BASE_URL}`,
url: `${BASE_URL}`,
lastModified: "2023-08-25",
},
{
url: `https://${BASE_URL}/legal-notice`,
url: `${BASE_URL}/legal-notice`,
lastModified: "2023-08-25",
},
{
url: `https://${BASE_URL}/privacy`,
url: `${BASE_URL}/privacy`,
lastModified: "2023-08-25",
},
];
Expand Down
5 changes: 4 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
const VERCEL_URL = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: null;
export const BASE_URL =
process.env.BASE_URL ?? process.env.VERCEL_URL ?? "opensource.porsche.com";
process.env.BASE_URL ?? VERCEL_URL ?? "https://opensource.porsche.com";
8 changes: 3 additions & 5 deletions tests/a11y.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { test, expect, Page } from "@playwright/test";
import AxeBuilder from "@axe-core/playwright";
import { BASE_URL as BASE_URL_CONFIG } from "../src/config";

const BASE_URL = `https://${BASE_URL_CONFIG}`;
import { BASE_URL } from "../src/config";

const runA11yScan = async (page: Page, path: string): Promise<void> => {
await page.goto(path);
Expand All @@ -14,13 +12,13 @@ const runA11yScan = async (page: Page, path: string): Promise<void> => {
const accessibilityScanResults = await new AxeBuilder({ page })
.withTags(["wcag2a", "wcag21a", "best-practice", "wcag2aa", "wcag21aa"])
.exclude("p-carousel")
.exclude("svg")
.exclude("#sharpBlur")
.analyze();

expect(accessibilityScanResults.violations).toEqual([]);
};

test.describe("Should not find any automatically detectable accessiblity issues", () => {
test.describe("Should not find any automatically detectable accessibility issues", () => {
test(`all pages`, async ({ page }) => {
const request = page.waitForEvent("response");
await page.goto(`${BASE_URL ?? ""}/sitemap.xml`);
Expand Down
3 changes: 2 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2401,7 +2401,7 @@ __metadata:
languageName: node
linkType: hard

"dotenv@npm:^16.0.3":
"dotenv@npm:16.3.1, dotenv@npm:^16.0.3":
version: 16.3.1
resolution: "dotenv@npm:16.3.1"
checksum: 15d75e7279018f4bafd0ee9706593dd14455ddb71b3bcba9c52574460b7ccaf67d5cf8b2c08a5af1a9da6db36c956a04a1192b101ee102a3e0cf8817bbcf3dfd
Expand Down Expand Up @@ -5825,6 +5825,7 @@ __metadata:
"@types/react-dom": 18.2.7
contentlayer: 0.3.4
date-fns: 2.30.0
dotenv: 16.3.1
eslint: 8.48.0
http-server: 14.1.1
js-yaml-loader: 1.2.2
Expand Down

0 comments on commit 6171183

Please sign in to comment.