Skip to content

Commit

Permalink
Migrate rest of project to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
Jbithell committed Jun 8, 2024
1 parent 4a32995 commit 71cca57
Show file tree
Hide file tree
Showing 40 changed files with 658 additions and 284 deletions.
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"cSpell.words": [
"htmlfilename",
"luxon",
"mantine",
"pdfs",
"porthmadog",
"ukho"
]
}
3 changes: 1 addition & 2 deletions data/php/dataParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
$pdfs = [];
foreach ($tidesMonths as $month=>$data) {
//Generate a PDF
$pdf = ["name" => date("F Y",strtotime($month)), "date" => date("Y-m-d", strtotime($month)), "filename" => strtolower(date("Y/m",strtotime($month))) . '.pdf', "htmlfilename" => strtolower(date("Y/m",strtotime($month))) . '.html'];
$pdf['url'] = $pdf['filename'];
$pdf = ["name" => date("F Y", strtotime($month)), "date" => date("Y-m-d", strtotime($month)), "filename" => strtolower(date("Y/m", strtotime($month))) . '.pdf', "htmlfilename" => strtolower(date("Y/m", strtotime($month))) . '.html', "url" => strtolower(date("Y/m", strtotime($month)))];

$output = '<center><div style="margin-top: 8px; margin-bottom: 2px; margin-left: 5px; margin-right: 5px;">
<style>
Expand Down
2 changes: 1 addition & 1 deletion data/tides.json

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import TidalData from "./data/tides.json";
import path from "path";
import { TidesJson_PDFObject } from "./src/types";
import { CreatePagesArgs } from "gatsby";

export const createPages = async function ({
actions,
graphql,
}: CreatePagesArgs) {
TidalData.pdfs.forEach((pdf: TidesJson_PDFObject) => {
actions.createPage({
path: "tide-tables/" + pdf.url,
component: path.resolve(`./src/components/templates/TideTablePage.tsx`),
context: { pdf },
defer: false,
});
});
};
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@
"gatsby-source-filesystem": "^5.13.1",
"gatsby-transformer-remark": "^6.13.1",
"gatsby-transformer-sharp": "^5.13.1",
"luxon": "^3.4.4",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"recharts": "^2.12.7"
},
"devDependencies": {
"@types/luxon": "^3.4.2",
"@types/node": "^20.12.12",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
Expand Down
24 changes: 0 additions & 24 deletions src/components/Copyright.js

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/Header.js

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/HtmlHead.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/components/Layout.js

This file was deleted.

47 changes: 0 additions & 47 deletions src/components/PDFs.js

This file was deleted.

26 changes: 26 additions & 0 deletions src/components/SEO.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react"
import { useSiteMetadata } from "../hooks/use-site-metadata"

export const SEO = ({ title, description, pathname, children }: { title?: string, description?: string, pathname?: string, children?: React.ReactNode }) => {
const { title: defaultTitle, description: defaultDescription, siteUrl } = useSiteMetadata()

const seo = {
title: (title ? title + " | " : "") + defaultTitle,
description: description || defaultDescription,
url: `${siteUrl}${pathname || ``}`,
}

return (
<>
<title>{seo.title}</title>
<meta charSet="utf-8" />
<meta name="description" content={seo.description} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={seo.title} />
<meta name="twitter:url" content={seo.url} />
<meta name="twitter:description" content={seo.description} />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
{children}
</>
)
}
44 changes: 0 additions & 44 deletions src/components/Tides.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/navigation/Footer.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.inner {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: var(--mantine-spacing-xl);
padding-bottom: var(--mantine-spacing-xl);

@media (max-width: $mantine-breakpoint-xs) {
flex-direction: column;
}
}

.links {
@media (max-width: $mantine-breakpoint-xs) {
margin-top: var(--mantine-spacing-md);
}
}

.link {
text-decoration: none;
color: light-dark(var(--mantine-color-gray-7), var(--mantine-color-dark-0));
}
16 changes: 16 additions & 0 deletions src/components/navigation/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Container, Group, Text } from '@mantine/core';
import * as classes from './Footer.module.css';
import React from 'react';
import { Link } from 'gatsby';
import { useBuildDate } from '../../hooks/use-build-date';

export function Footer() {
const buildYear = useBuildDate()

return (
<Container size="xl" className={classes.inner}>
<Text>Times are GMT/BST. No warranty is provided for the accuracy of data displayed. Tidal Data is &copy;Crown Copyright. Reproduced by permission of the Controller of Her Majesty's Stationery Office and the UK Hydrographic Office (www.ukho.gov.uk). No tidal data may be reproduced without the expressed permission of the UKHO licensing department.</Text>
<Text>&copy;2014-{buildYear} James Bithell</Text>
</Container>
);
}
Loading

0 comments on commit 71cca57

Please sign in to comment.