Skip to content

Commit 264c453

Browse files
committed
Fixes?
1 parent c13eeff commit 264c453

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

astro.config.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ export default defineConfig({
99
output: 'static',
1010
site: 'https://miroiu.github.io',
1111
base: '/nodify',
12-
// build: {
13-
// format: 'file',
14-
// },
15-
// trailingSlash: 'never',
12+
build: {
13+
format: 'file',
14+
},
15+
trailingSlash: 'never',
1616
integrations: [
1717
starlight({
1818
title: 'Nodify',
@@ -27,6 +27,7 @@ export default defineConfig({
2727
},
2828
components: {
2929
EditLink: './src/components/EditLink.astro',
30+
SiteTitle: './src/components/SiteTitle.astro',
3031
},
3132
social: [
3233
{
@@ -38,7 +39,6 @@ export default defineConfig({
3839
customCss: ['./src/styles/starlight.css'],
3940
}),
4041
],
41-
4242
vite: {
4343
plugins: [tailwindcss()],
4444
},

src/components/SiteTitle.astro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
const { siteTitle } = Astro.locals.starlightRoute;
3+
import Logo from '../assets/logo.svg';
4+
---
5+
6+
<a href="/nodify" class="site-title sl-flex">
7+
<Logo />
8+
<span translate="no">
9+
{siteTitle}
10+
</span>
11+
</a>
12+
13+
<style>
14+
@layer starlight.core {
15+
.site-title {
16+
align-items: center;
17+
gap: var(--sl-nav-gap);
18+
font-size: var(--sl-text-h4);
19+
font-weight: 600;
20+
color: var(--sl-color-text-accent);
21+
text-decoration: none;
22+
white-space: nowrap;
23+
min-width: 0;
24+
}
25+
span {
26+
overflow: hidden;
27+
}
28+
img {
29+
height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y));
30+
width: auto;
31+
max-width: 100%;
32+
object-fit: contain;
33+
object-position: 0 50%;
34+
}
35+
}
36+
</style>

src/middleware.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { MiddlewareHandler } from 'astro';
2+
3+
/**
4+
* This middleware converts the pathname to lowercase and adds .html to the final path for documentation pages and redirects the request to the URL with a 301 status code.
5+
*/
6+
export const onRequest: MiddlewareHandler = async ({ request }, next) => {
7+
const url = new URL(request.url);
8+
9+
if (url.pathname.includes('wiki/') && !url.pathname.includes('.html')) {
10+
const redirectUrl = `${url.pathname.toLocaleLowerCase()}.html`;
11+
return new Response(null, {
12+
status: 301,
13+
headers: {
14+
Location: redirectUrl,
15+
},
16+
});
17+
}
18+
19+
return next();
20+
};

0 commit comments

Comments
 (0)