Skip to content

Commit

Permalink
Merge branch 'admin-server-relative-paths' into docker
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarnutsch committed Dec 4, 2024
2 parents fc73ace + b025273 commit 56634ea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
6 changes: 3 additions & 3 deletions admin/server/server.js → admin/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ const express = require("express");
const compression = require("compression");
const helmet = require("helmet");
const fs = require("fs");
const path = require("path");

const app = express();
const port = process.env.APP_PORT ?? 3000;

// Read index.html file
let indexFile = fs.readFileSync("../build/index.html", "utf8");
let indexFile = fs.readFileSync(path.join(__dirname, "../build/index.html"), "utf8");

// Replace environment variables
indexFile = indexFile.replace(/\$([A-Z_]+)/g, (match, p1) => {
Expand Down Expand Up @@ -42,7 +42,7 @@ app.get("/status/health", (req, res) => {
});

app.use(
express.static("../build", {
express.static(path.join(__dirname, "../build"), {
index: false, // Don't send index.html for requests to "/" as it will be handled by the fallback route (with replaced environment variables)
setHeaders: (res, path, stat) => {
if (path.endsWith(".js")) {
Expand Down
2 changes: 1 addition & 1 deletion admin/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "server",
"private": true,
"scripts": {
"serve": "node server.js"
"serve": "node index.js"
},
"dependencies": {
"compression": "^1.7.5",
Expand Down
12 changes: 12 additions & 0 deletions site/src/app/[domain]/[language]/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Link from "next/link";

export default async function NotFound404() {
return (
<html>
<body>
<p>Page not found.</p>
<Link href="/">Return Home</Link>
</body>
</html>
);
}
15 changes: 9 additions & 6 deletions site/src/layout/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SvgUse } from "@src/common/helpers/SvgUse";
import { MobileMenu } from "@src/layout/header/MobileMenu";
import { PageLink } from "@src/layout/header/PageLink";
import { PageLayout } from "@src/layout/PageLayout";
import Link from "next/link";
import { useEffect, useState } from "react";
import { useIntl } from "react-intl";
import styled from "styled-components";
Expand Down Expand Up @@ -43,7 +44,9 @@ export const Header = ({ header }: Props) => {
<PageLayout grid>
<PageLayoutContent>
<Root>
<SvgUse href="/assets/comet-logo.svg#logo" />
<Link href="/">
<SvgUse href="/assets/comet-logo.svg#logo" />
</Link>

<DesktopHeaderFullHeightNav>
<TopLevelNavigation>
Expand All @@ -56,9 +59,9 @@ export const Header = ({ header }: Props) => {
onMouseLeave={() => setExpandedSubLevelNavigation(null)}
>
<LinkContainer>
<Link page={node} activeClassName="active" aria-label={node.name}>
<MenuPageLink page={node} activeClassName="active" aria-label={node.name}>
{node.name}
</Link>
</MenuPageLink>
{visibleChildNodes.length > 0 && (
<ToggleSubLevelNavigationButton
aria-label={intl.formatMessage(
Expand All @@ -82,9 +85,9 @@ export const Header = ({ header }: Props) => {
<SubLevelNavigation $isExpanded={expandedSubLevelNavigation === node.id}>
{visibleChildNodes.map((node) => (
<li key={node.id}>
<Link page={node} activeClassName="active" aria-label={node.name}>
<MenuPageLink page={node} activeClassName="active" aria-label={node.name}>
{node.name}
</Link>
</MenuPageLink>
</li>
))}
</SubLevelNavigation>
Expand Down Expand Up @@ -185,7 +188,7 @@ const AnimatedChevron = styled(SvgUse)<{ $isExpanded: boolean }>`
transition: transform 0.4s ease;
`;

const Link = styled(PageLink)`
const MenuPageLink = styled(PageLink)`
text-decoration: none;
display: inline-block;
padding: ${({ theme }) => theme.spacing.S100} 0;
Expand Down

0 comments on commit 56634ea

Please sign in to comment.