Skip to content

Commit

Permalink
feat(pre-prod): add sitemap, move robots, other tidyup
Browse files Browse the repository at this point in the history
  • Loading branch information
charles4221 committed Feb 4, 2024
1 parent e7b0c7e commit 4a714d9
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 90 deletions.
2 changes: 0 additions & 2 deletions public/robots.txt

This file was deleted.

4 changes: 4 additions & 0 deletions src/app/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
User-agent: *
Allow: /

Sitemap: https://charlesharwood.dev/sitemap.xml
43 changes: 43 additions & 0 deletions src/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { MetadataRoute } from 'next';

import { createClient } from '@/prismic-config';
import { BASE_URL, PAGES_WITH_CUSTOM_ROUTE_HANDLERS } from '@/utils/constants';

export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const client = createClient();
const pages = await client.getAllByType('page');

const dynamicPagesMap = pages
.filter((page) => !PAGES_WITH_CUSTOM_ROUTE_HANDLERS.has(page.uid))
.map(
(page) =>
({
url: `${BASE_URL}/${page.uid}`,
lastModified: new Date(page.last_publication_date),
changeFrequency: 'monthly',
priority: 0.5,
}) as const,
);

return [
{
url: 'https://charlesharwood.dev',
lastModified: new Date(),
changeFrequency: 'yearly',
priority: 1,
},
{
url: 'https://charlesharwood.dev/about',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
{
url: 'https://charlesharwood.dev/contact',
lastModified: new Date(),
changeFrequency: 'monthly',
priority: 0.8,
},
...dynamicPagesMap,
];
}
9 changes: 5 additions & 4 deletions src/components/forms/InputWithLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { ComponentProps } from 'react';
import { Input } from './Input';
import { Label } from './Label';

export function InputWithLabel(
props: ComponentProps<typeof Input> & { label: string },
) {
export function InputWithLabel({
label,
...props
}: ComponentProps<typeof Input> & { label: string }) {
return (
<div>
<Label
htmlFor={props.id}
aria-required={props.required ? 'true' : 'false'}>
{props.label}
{label}
{props.required ? (
<span className="text-red-600 font-semibold"> *</span>
) : null}
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { createClient } from '@/prismic-config';
import { FONT_VT_323 } from '@/theme/fonts';

import { Container } from './Container';
import { NavLink } from './NavLink';
import type {
NavigationDocumentDataLinksItem,
Simplify,
} from '../../../prismicio-types';
import { NavLink } from '../links/NavLink';
import { SocialLinks } from '../links/SocialLinks';
import { DarkModeSetting } from '../settings/DarkModeSetting';
import { Heading } from '../typography/Heading';
Expand Down
File renamed without changes.
33 changes: 0 additions & 33 deletions src/components/project/Hero.tsx

This file was deleted.

39 changes: 0 additions & 39 deletions src/components/project/Testimonial.tsx

This file was deleted.

27 changes: 16 additions & 11 deletions src/store/bound.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';

import { IS_DEV } from '@/utils/constants';

import {
SettingsActions,
SettingsState,
Expand All @@ -20,19 +22,22 @@ export const useBoundStore = create<StoreState>()(
}),
{
name: 'persisted-store',
onRehydrateStorage: (state) => {
console.log({ stateBeforeHydrate: state });
onRehydrateStorage: IS_DEV
? (state) => {
console.log({ stateBeforeHydrate: state });

return (stateAfterHydrate, error) => {
if (error) {
console.error(error);
window.alert('Error: Failed to rehydrate store');
return;
}
return (stateAfterHydrate, error) => {
console.log({ stateAfterHydrate });

console.log({ stateAfterHydrate });
};
},
if (error) {
console.error(error);
window.alert(
'Error: Failed to rehydrate store. Check console for more info.',
);
}
};
}
: undefined,
partialize: (state) => ({
darkModeUserOverride: state.darkModeUserOverride,
}),
Expand Down
11 changes: 11 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import type { Metadata } from 'next';

export const IS_DEV = process.env.NODE_ENV !== 'production';

export const BASE_URL =
process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000';

export const METADATA_BASE: Metadata['metadataBase'] = new URL(
`http://localhost:${process.env.PORT || 3000}`,
);

export const PAGES_WITH_CUSTOM_ROUTE_HANDLERS = new Set([
'home',
'about',
'contact',
]);

0 comments on commit 4a714d9

Please sign in to comment.