mirror of
https://github.com/samber/awesome-prometheus-alerts.git
synced 2026-06-24 18:36:59 +08:00
fix: strip trailing slash from BASE_URL to prevent double slashes in URLs
Agent-Logs-Url: https://github.com/samber/awesome-prometheus-alerts/sessions/c85937ba-1855-4b8a-a72b-847eab1c8639 Co-authored-by: samber <2951285+samber@users.noreply.github.com>
This commit is contained in:
parent
79f4055dbb
commit
b1764267dc
9 changed files with 10 additions and 10 deletions
|
|
@ -5,7 +5,7 @@ interface Props {
|
||||||
class?: string;
|
class?: string;
|
||||||
}
|
}
|
||||||
const { class: extraClass = '' } = Astro.props;
|
const { class: extraClass = '' } = Astro.props;
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
---
|
---
|
||||||
|
|
||||||
<div id="search" class={extraClass}></div>
|
<div id="search" class={extraClass}></div>
|
||||||
|
|
@ -14,7 +14,7 @@ const base = import.meta.env.BASE_URL;
|
||||||
<script>
|
<script>
|
||||||
// Load Pagefind UI lazily (only when the search div is visible/focused)
|
// Load Pagefind UI lazily (only when the search div is visible/focused)
|
||||||
function initPagefind() {
|
function initPagefind() {
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import(`${base}/pagefind/pagefind-ui.js`).then((module) => {
|
import(`${base}/pagefind/pagefind-ui.js`).then((module) => {
|
||||||
const PagefindUI = module.PagefindUI;
|
const PagefindUI = module.PagefindUI;
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ const {
|
||||||
dateModified,
|
dateModified,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
|
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const canonical = canonicalUrl ?? `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
|
const canonical = canonicalUrl ?? `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { title, description, breadcrumbs = [], icon = 'book', badge = 'Guide', extraJsonLd, dateUpdated, keywords, readingTime } = Astro.props;
|
const { title, description, breadcrumbs = [], icon = 'book', badge = 'Guide', extraJsonLd, dateUpdated, keywords, readingTime } = Astro.props;
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const canonicalUrl = `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
|
const canonicalUrl = `${SITE_ORIGIN}${base}${Astro.url.pathname.replace(base, '')}`;
|
||||||
|
|
||||||
const dateModified = dateUpdated ?? new Date().toISOString().slice(0, 10);
|
const dateModified = dateUpdated ?? new Date().toISOString().slice(0, 10);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
import GuideLayout from '../layouts/GuideLayout.astro';
|
import GuideLayout from '../layouts/GuideLayout.astro';
|
||||||
|
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
|
|
||||||
const howToJsonLd = {
|
const howToJsonLd = {
|
||||||
'@context': 'https://schema.org',
|
'@context': 'https://schema.org',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
import GuideLayout from '../layouts/GuideLayout.astro';
|
import GuideLayout from '../layouts/GuideLayout.astro';
|
||||||
|
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
|
|
||||||
const howToJsonLd = {
|
const howToJsonLd = {
|
||||||
'@context': 'https://schema.org',
|
'@context': 'https://schema.org',
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import SearchWidget from '../components/SearchWidget.astro';
|
||||||
import { data, getGroupSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, getPopularServices } from '../data/rules';
|
import { data, getGroupSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, getPopularServices } from '../data/rules';
|
||||||
import { SITE_URL, GITHUB_URL, schemaAuthor, schemaPublisher, schemaWebSite, SITE_DATE_PUBLISHED, LICENSE_CC_BY_URL, LICENSE_MIT_URL } from '../data/site';
|
import { SITE_URL, GITHUB_URL, schemaAuthor, schemaPublisher, schemaWebSite, SITE_DATE_PUBLISHED, LICENSE_CC_BY_URL, LICENSE_MIT_URL } from '../data/site';
|
||||||
|
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const totalRules = getTotalRuleCount();
|
const totalRules = getTotalRuleCount();
|
||||||
const totalServices = getTotalServiceCount();
|
const totalServices = getTotalServiceCount();
|
||||||
const popularServices = getPopularServices();
|
const popularServices = getPopularServices();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ export function getStaticPaths() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { group, service } = Astro.props;
|
const { group, service } = Astro.props;
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const groupSlug = getGroupSlug(group);
|
const groupSlug = getGroupSlug(group);
|
||||||
const serviceSlug = getServiceSlug(service);
|
const serviceSlug = getServiceSlug(service);
|
||||||
const ruleCount = getRuleCount(service);
|
const ruleCount = getRuleCount(service);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ export function getStaticPaths() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { group } = Astro.props;
|
const { group } = Astro.props;
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const groupSlug = getGroupSlug(group);
|
const groupSlug = getGroupSlug(group);
|
||||||
const totalRules = group.services.reduce((sum, svc) => sum + getRuleCount(svc), 0);
|
const totalRules = group.services.reduce((sum, svc) => sum + getRuleCount(svc), 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import CautionBanner from '../../components/CautionBanner.astro';
|
||||||
import { data, getGroupSlug, getServiceSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, buildRedirectMap } from '../../data/rules';
|
import { data, getGroupSlug, getServiceSlug, getRuleCount, getTotalRuleCount, getTotalServiceCount, buildRedirectMap } from '../../data/rules';
|
||||||
import { SITE_URL, schemaWebSite } from '../../data/site';
|
import { SITE_URL, schemaWebSite } from '../../data/site';
|
||||||
|
|
||||||
const base = import.meta.env.BASE_URL;
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
||||||
const totalRules = getTotalRuleCount();
|
const totalRules = getTotalRuleCount();
|
||||||
const totalServices = getTotalServiceCount();
|
const totalServices = getTotalServiceCount();
|
||||||
const redirectMap = buildRedirectMap(base);
|
const redirectMap = buildRedirectMap(base);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue