diff --git a/content/blog/2013/add-event.md b/content/blog/2013/add-event.md
index f9bdef7c..6fef4e54 100644
--- a/content/blog/2013/add-event.md
+++ b/content/blog/2013/add-event.md
@@ -9,7 +9,7 @@ categories:
tags: []
---
-
@@ -10,7 +12,7 @@ const { articleHtml } = Astro.props;
diff --git a/src/data/events.ts b/src/data/events.ts
index a3b0a451..9803d199 100644
--- a/src/data/events.ts
+++ b/src/data/events.ts
@@ -23,7 +23,7 @@ export const recurringCalendarEvents: RecurringCalendarEvent[] = [
endTime: "12:00",
location: "19 North Great Georges St., Dublin 1, Ireland",
details: "Weekly Sunday Service video upload and community worship.",
- url: "/services.html",
+ url: "/services",
weekday: 0,
},
];
diff --git a/src/lib/archive.ts b/src/lib/archive.ts
index d9bc6eaa..a1addeb6 100644
--- a/src/lib/archive.ts
+++ b/src/lib/archive.ts
@@ -122,13 +122,12 @@ export function speechCategorySlug(category: string): string {
export function categoryHref(entry: ArchiveEntry, category: string): string {
if (entry.data.type === "speech") {
- return `/speeches/categories/${speechCategorySlug(category)}.html`;
+ return `/speeches/categories/${speechCategorySlug(category)}`;
}
- return `/blog/categories/${blogCategorySlug(category)}.html`;
+ return `/blog/categories/${blogCategorySlug(category)}`;
}
export function tagHref(tag: string): string {
- return `/blog/tags/${blogTagSlug(tag)}.html`;
+ return `/blog/tags/${blogTagSlug(tag)}`;
}
-
diff --git a/src/lib/speeches.ts b/src/lib/speeches.ts
index ad552bb1..21e696c0 100644
--- a/src/lib/speeches.ts
+++ b/src/lib/speeches.ts
@@ -1,5 +1,6 @@
import fs from "node:fs";
import path from "node:path";
+import { stripHtmlExtensionFromInternalUrl } from "./urls";
const repoRoot = process.cwd();
const speechesRoot = path.join(repoRoot, "content", "speeches");
@@ -190,7 +191,7 @@ function itemFromFile(filePath: string): SpeechArchiveItem {
return {
id: relativePath.replace(/\.md$/, ""),
title,
- url: frontmatter.source ?? "#",
+ url: stripHtmlExtensionFromInternalUrl(frontmatter.source) ?? "#",
year,
speaker,
category,
diff --git a/src/lib/urls.ts b/src/lib/urls.ts
new file mode 100644
index 00000000..1dc3edf9
--- /dev/null
+++ b/src/lib/urls.ts
@@ -0,0 +1,39 @@
+const internalHosts = new Set(["familyfed.ie", "www.familyfed.ie", "familyfed.bcgen.ie"]);
+const ignoredProtocolPattern = /^(?:mailto|tel|javascript|data|blob):/i;
+
+function splitSuffix(value: string): { pathname: string; suffix: string } {
+ const match = value.match(/^([^?#]*)([?#].*)?$/);
+ return {
+ pathname: match?.[1] ?? value,
+ suffix: match?.[2] ?? "",
+ };
+}
+
+function stripHtmlPath(pathname: string): string {
+ return pathname.replace(/\.html$/i, "");
+}
+
+export function stripHtmlExtensionFromInternalUrl
(value: T): T {
+ if (!value || value.startsWith("#") || value.startsWith("?") || value.startsWith("//") || ignoredProtocolPattern.test(value)) {
+ return value;
+ }
+
+ const absoluteMatch = value.match(/^(https?:\/\/([^/?#]+))([^?#]*)([?#].*)?$/i);
+ if (absoluteMatch) {
+ const [, origin, host, pathname = "", suffix = ""] = absoluteMatch;
+ if (!internalHosts.has(host.toLowerCase())) {
+ return value;
+ }
+
+ return `${origin}${stripHtmlPath(pathname)}${suffix}` as T;
+ }
+
+ const { pathname, suffix } = splitSuffix(value);
+ return `${stripHtmlPath(pathname)}${suffix}` as T;
+}
+
+export function normalizeInternalHtmlLinks(html = ""): string {
+ return html.replace(/\b(href|action)=(["'])(.*?)\2/gis, (_match, attr, quote, value) => {
+ return `${attr}=${quote}${stripHtmlExtensionFromInternalUrl(value)}${quote}`;
+ });
+}
diff --git a/src/pages/2013-sunday-service-archive.astro b/src/pages/2013-sunday-service-archive.astro
index 91a1d7a6..58a0b937 100644
--- a/src/pages/2013-sunday-service-archive.astro
+++ b/src/pages/2013-sunday-service-archive.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/2014-sunday-services.astro b/src/pages/2014-sunday-services.astro
index a6c8898b..aebc3470 100644
--- a/src/pages/2014-sunday-services.astro
+++ b/src/pages/2014-sunday-services.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/2015-sunday-services-archive.astro b/src/pages/2015-sunday-services-archive.astro
index 295ff6cc..a9ec981e 100644
--- a/src/pages/2015-sunday-services-archive.astro
+++ b/src/pages/2015-sunday-services-archive.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/2016-sunday-service-archive.astro b/src/pages/2016-sunday-service-archive.astro
index 440d5c9f..a8497044 100644
--- a/src/pages/2016-sunday-service-archive.astro
+++ b/src/pages/2016-sunday-service-archive.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/2017-sunday-service-archive.astro b/src/pages/2017-sunday-service-archive.astro
index 9c53622d..b577f3b7 100644
--- a/src/pages/2017-sunday-service-archive.astro
+++ b/src/pages/2017-sunday-service-archive.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/2018-sunday-service-archive.astro b/src/pages/2018-sunday-service-archive.astro
index 9c2a387e..b2cb3a87 100644
--- a/src/pages/2018-sunday-service-archive.astro
+++ b/src/pages/2018-sunday-service-archive.astro
@@ -2,5 +2,4 @@
import LegacyRedirectPage from "../components/LegacyRedirectPage.astro";
---
-
-
+
diff --git a/src/pages/[...route].ts b/src/pages/[...route].ts
index ac4809db..73e573a3 100644
--- a/src/pages/[...route].ts
+++ b/src/pages/[...route].ts
@@ -1,6 +1,7 @@
import fs from "node:fs/promises";
import { contentSourceRoutes } from "../lib/content-routes";
import { isMigratedHtmlPage, relativeWebsitePath, routeFromRelativePath, sourcePathFromRoute, walkHtmlFiles } from "../lib/static-pages";
+import { normalizeInternalHtmlLinks } from "../lib/urls";
export async function getStaticPaths() {
const markdownRoutes = await contentSourceRoutes();
@@ -16,7 +17,7 @@ export async function getStaticPaths() {
}
export async function GET({ params }: { params: { route?: string } }) {
- const html = await fs.readFile(sourcePathFromRoute(params.route), "utf8");
+ const html = normalizeInternalHtmlLinks(await fs.readFile(sourcePathFromRoute(params.route), "utf8"));
return new Response(html, {
headers: {
diff --git a/src/pages/about-us-organizations.astro b/src/pages/about-us-organizations.astro
index 3106e711..864c53d8 100644
--- a/src/pages/about-us-organizations.astro
+++ b/src/pages/about-us-organizations.astro
@@ -10,9 +10,8 @@ const articleHtml = legacyPageArticle("about-us-organizations.html");
title="Organizations – FFWPU Ireland"
description="Explore organizations connected with Rev. Sun Myung Moon and Dr. Hak Ja Han Moon, including UPF, WFWP, IRFF, and the Unification Church."
bodyClass="page-template page-template-templates page-template-template-twocolumns-right page-template-templatestemplate-twocolumns-right-php page page-id-124 page-child parent-pageid-29 custom-background tribe-no-js metaslider-plugin parabola-image-three caption-light meta-light parabola_triagles parabola-menu-left"
- pathname="/about-us-organizations.html"
- canonical="/about-us-organizations.html"
+ pathname="/about-us-organizations"
+ canonical="/about-us-organizations"
>
-
diff --git a/src/pages/about.astro b/src/pages/about.astro
index 6dd89887..a1440398 100644
--- a/src/pages/about.astro
+++ b/src/pages/about.astro
@@ -8,8 +8,8 @@ import articleHtml from "../content/pages/about.html?raw";
title="About Us – FFWPU Ireland"
description="Learn about the Family Federation for World Peace and Unification in Ireland, its teachings, and its focus on God-centered families."
bodyClass="page-template page-template-templates page-template-template-twocolumns-right page-template-templatestemplate-twocolumns-right-php page page-id-29 page-parent custom-background tribe-no-js metaslider-plugin parabola-image-three caption-light meta-light parabola_triagles parabola-menu-left"
- pathname="/about.html"
- canonical="/about.html"
+ pathname="/about"
+ canonical="/about"
>
diff --git a/src/pages/admin/index.astro b/src/pages/admin/index.astro
index 5d0f2029..267e55c2 100644
--- a/src/pages/admin/index.astro
+++ b/src/pages/admin/index.astro
@@ -837,7 +837,7 @@ const adminConfig = {