From b131fceaeb0cd784cccfe719e68822d4adf3d97c Mon Sep 17 00:00:00 2001 From: Thomas Neil James Shadwell Date: Thu, 16 Nov 2023 16:32:02 -0800 Subject: [PATCH] Make it an error to use tags without an exemption and correct wayward tags. Fixes #3911 Fixes #3992 --- Global.d.ts | 13 +++++++++++++ project/zemn.me/next/components/Link/Link.tsx | 12 +++++++++++- project/zemn.me/next/pages/index.tsx | 16 ++++++++-------- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Global.d.ts b/Global.d.ts index ae6be5a998..63aaa55018 100644 --- a/Global.d.ts +++ b/Global.d.ts @@ -24,3 +24,16 @@ declare module '*.jpg' { export const blurWidth: number; export const blurHeight: number; } + +type LinkBrand = 'hey. please use project/zemn.me/next/components/Link instead'; + +declare module 'global' { + global { + namespace JSX { + interface IntrinsicElements { + // Override the `` element + a: { 'data-brand': LinkBrand }; + } + } + } +} diff --git a/project/zemn.me/next/components/Link/Link.tsx b/project/zemn.me/next/components/Link/Link.tsx index a3879d7380..0495e06a60 100644 --- a/project/zemn.me/next/components/Link/Link.tsx +++ b/project/zemn.me/next/components/Link/Link.tsx @@ -54,6 +54,8 @@ function isFirstPartyURL(u: string | UrlObject | URL): boolean { ); } +type Exempt = T & { 'data-brand': LinkBrand }; + export function Link({ href, rel, target, ...props }: LinkProps) { if (href !== undefined && !isFirstPartyURL(href)) { rel = `${rel ?? ''} external`.trim(); @@ -62,7 +64,15 @@ export function Link({ href, rel, target, ...props }: LinkProps) { // next Link has a strangely strident stance on providing the href parameter // which we do not. if there is no href we just fall back to using an tag. // https://github.com/i18next/next-i18next/issues/599 - if (href === undefined) return ; + if (href === undefined) { + const p = { + href, + rel, + target, + ...props, + }; + return )} />; + } return ; } diff --git a/project/zemn.me/next/pages/index.tsx b/project/zemn.me/next/pages/index.tsx index db6dd3a128..6b57ec3ed1 100644 --- a/project/zemn.me/next/pages/index.tsx +++ b/project/zemn.me/next/pages/index.tsx @@ -145,19 +145,19 @@ export default function Main() {

The background video (“hero video”) is of a hidden area in the gardens of{' '} - + Kenwood House - + , a beautiful stately home sandwiched between Highgate and Hampstead in London where I grew up. It's located at about{' '} - 51.57139601074658°N, -0.16924392259112794°E - + .

@@ -171,9 +171,9 @@ export default function Main() {

The type and style itself was inspired by older, pre-computer era typsetting such as the{' '} - + Lloyd's Act 1871 - + . Particular effort was put into trying to have content fill horizontal space automatically, as seen in older documents that try to make the most of the @@ -211,9 +211,9 @@ export default function Main() {

The eye logo is a reference to the well-known{' '} - + ‘eye of providence’ - + , a symbol that represents human achievement as being incomplete without God. I wanted it to reflect the idea that, in a universe that might not have a