Skip to content

Commit 2f863d1

Browse files
committed
UPDATE: more work on library to pattern change
1 parent b250913 commit 2f863d1

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

app/components/Patterns.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import * as yaml from "js-yaml";
44

55
const LIBRARY_DIR = path.join(process.cwd(), "library");
66

7-
export type LibraryEntry = {
7+
export type PatternEntry = {
88
title: string;
99
detail?: string; // markdown!
1010
handle: string;
1111
fullPath: string;
1212
tags?: string[];
13-
variations: LibraryEntryVariation[];
13+
variations: PatternEntryVariation[];
1414
};
1515

16-
export type LibraryEntryVariation = {
16+
export type PatternEntryVariation = {
1717
title: string;
1818
pattern: string;
1919
description?: string;
2020
};
2121

22-
const cache: Map<string, LibraryEntry> = new Map();
23-
const all: LibraryEntry[] = [];
22+
const cache: Map<string, PatternEntry> = new Map();
23+
const all: PatternEntry[] = [];
2424

2525
async function initialize() {
2626
if (all.length > 0) {
@@ -34,7 +34,7 @@ async function initialize() {
3434
const raw = await fsPromises.readFile(fullPath, "utf-8");
3535
const parsed = yaml.load(raw, {
3636
schema: yaml.JSON_SCHEMA,
37-
}) as LibraryEntry;
37+
}) as PatternEntry;
3838
parsed.fullPath = fullPath;
3939

4040
cache.set(parsed.handle, parsed);
@@ -53,7 +53,7 @@ function get(handle: string) {
5353
return entry;
5454
}
5555

56-
function getAll(): LibraryEntry[] {
56+
function getAll(): PatternEntry[] {
5757
return all;
5858
}
5959

app/routes/library.$entry._index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Markdown from 'react-markdown'
88
import { Footer } from "~/components/Footer";
99

1010
import { HeaderSearch } from "~/components/HeaderSearch/HeaderSearch";
11-
import { get, initialize, LibraryEntry, LibraryEntryVariation } from "~/components/Library";
11+
import { get, initialize, PatternEntry, PatternEntryVariation } from "~/components/Patterns";
1212
import { TagList } from "~/components/TagList";
1313

1414
export const loader = async ({
@@ -26,7 +26,7 @@ export const meta: MetaFunction = () => {
2626
];
2727
};
2828

29-
function LibraryEntryView(entry: LibraryEntry) {
29+
function PatternEntryView(entry: PatternEntry) {
3030
return (
3131
<Container>
3232

@@ -46,7 +46,7 @@ function LibraryEntryView(entry: LibraryEntry) {
4646
</tr>
4747
</thead>
4848
<tbody>
49-
{entry.variations.length > 0 ? (entry.variations.map((variation) => LibraryEntryVariationView(variation))) : <tr><td>(none)</td></tr>}
49+
{entry.variations.length > 0 ? (entry.variations.map((variation) => PatternEntryVariationView(variation))) : <tr><td>(none)</td></tr>}
5050
</tbody>
5151
</Table>
5252
<details><summary>Raw data</summary>
@@ -57,7 +57,7 @@ function LibraryEntryView(entry: LibraryEntry) {
5757
);
5858
}
5959

60-
function LibraryEntryVariationView(variation: LibraryEntryVariation) {
60+
function PatternEntryVariationView(variation: PatternEntryVariation) {
6161
return (
6262
<tr>
6363
<td>{variation.title}</td>
@@ -72,7 +72,7 @@ export default function Index() {
7272
return (
7373
<>
7474
<HeaderSearch />
75-
{entry ? LibraryEntryView(entry) : <h1>Not Found</h1>}
75+
{entry ? PatternEntryView(entry) : <h1>Not Found</h1>}
7676
</>
7777
);
7878
}

app/routes/library._index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Link as RemixLink, useLoaderData } from "@remix-run/react";
44
import { json } from "@remix-run/node";
55

66
import { HeaderSearch } from "~/components/HeaderSearch/HeaderSearch";
7-
import { getAll, initialize, LibraryEntry } from "~/components/Library";
7+
import { getAll, initialize, PatternEntry } from "~/components/Patterns";
88
import { TagList } from "~/components/TagList";
99
import { Footer } from "~/components/Footer";
1010

@@ -23,7 +23,7 @@ export const meta: MetaFunction = () => {
2323
};
2424

2525

26-
function LibraryEntryRow(entry: LibraryEntry) {
26+
function PatternEntryRow(entry: PatternEntry) {
2727
return (
2828
<tr key={entry.handle}>
2929
<td>
@@ -40,7 +40,7 @@ function LibraryEntryRow(entry: LibraryEntry) {
4040
export default function Index() {
4141
const entries = useLoaderData<typeof loader>();
4242

43-
const entryRows = entries.map((entry) => LibraryEntryRow(entry));
43+
const entryRows = entries.map((entry) => PatternEntryRow(entry));
4444

4545
return (
4646
<>

app/routes/library.tags[.]html.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Container } from "react-bootstrap";
44
import { Footer } from "~/components/Footer";
55

66
import { HeaderSearch } from "~/components/HeaderSearch/HeaderSearch";
7-
import { getAll, initialize } from "~/components/Library";
7+
import { getAll, initialize } from "~/components/Patterns";
88

99
type TagEntry = {
1010
title: string;

app/routes/sitemap[.]xml.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getAll, initialize } from "~/components/Library";
1+
import { getAll, initialize } from "~/components/Patterns";
22

33
function urlLine(url:string) {
44
return `\t<url><loc>https://www.regex.zone${url}</loc></url>`

0 commit comments

Comments
 (0)