mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-05 20:02:47 +01:00
Merge branch 'main' into add-farsi-translation
This commit is contained in:
@@ -98,6 +98,12 @@ function injectOrganizationLd(document) {
|
||||
}
|
||||
|
||||
const BREADCRUMB_MARKER = 'data-bentopdf-breadcrumb';
|
||||
const BRAND_NAME = process.env.VITE_BRAND_NAME || 'BentoPDF';
|
||||
|
||||
function buildLocalHomeHref(lang) {
|
||||
const langSegment = lang === 'en' ? '/' : `/${lang}/`;
|
||||
return `${BASE_PATH}${langSegment}`.replace(/\/+/g, '/');
|
||||
}
|
||||
|
||||
function injectToolBreadcrumb(document, lang, toolName, toolUrl) {
|
||||
const h1 = document.querySelector('h1[data-i18n^="tools:"]');
|
||||
@@ -112,9 +118,9 @@ function injectToolBreadcrumb(document, lang, toolName, toolUrl) {
|
||||
nav.className = 'text-sm text-gray-400 mb-4';
|
||||
|
||||
const homeLink = document.createElement('a');
|
||||
homeLink.href = homeUrl;
|
||||
homeLink.href = buildLocalHomeHref(lang);
|
||||
homeLink.className = 'hover:text-indigo-300';
|
||||
homeLink.textContent = 'BentoPDF';
|
||||
homeLink.textContent = BRAND_NAME;
|
||||
|
||||
const sep = document.createElement('span');
|
||||
sep.setAttribute('aria-hidden', 'true');
|
||||
@@ -139,7 +145,7 @@ function injectToolBreadcrumb(document, lang, toolName, toolUrl) {
|
||||
{
|
||||
'@type': 'ListItem',
|
||||
position: 1,
|
||||
name: 'BentoPDF',
|
||||
name: BRAND_NAME,
|
||||
item: homeUrl,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -56,6 +56,11 @@ const connectOrigins = uniq([
|
||||
]);
|
||||
const fontOrigins = uniq([ocrFontOrigin].filter(Boolean));
|
||||
|
||||
const githubStarsDisabled =
|
||||
process.env.DISABLE_GITHUB_STARS === 'true' ||
|
||||
process.env.SIMPLE_MODE === 'true';
|
||||
const githubApiSource = githubStarsDisabled ? '' : ' https://api.github.com';
|
||||
|
||||
const directives = [
|
||||
`default-src 'self'`,
|
||||
`script-src 'self' 'wasm-unsafe-eval' 'unsafe-eval' blob: ${scriptOrigins.join(' ')}`.trim(),
|
||||
@@ -63,7 +68,7 @@ const directives = [
|
||||
`style-src 'self' 'unsafe-inline' https://fonts.googleapis.com`,
|
||||
`img-src 'self' data: blob: https:`,
|
||||
`font-src 'self' data: https://fonts.gstatic.com ${fontOrigins.join(' ')}`.trim(),
|
||||
`connect-src 'self' blob: https://api.github.com https://fonts.gstatic.com ${connectOrigins.join(' ')}`.trim(),
|
||||
`connect-src 'self' blob:${githubApiSource} https://fonts.gstatic.com ${connectOrigins.join(' ')}`.trim(),
|
||||
`object-src 'none'`,
|
||||
`base-uri 'self'`,
|
||||
`frame-src 'self' blob:`,
|
||||
@@ -77,7 +82,7 @@ const docsDirectives = [
|
||||
`style-src 'self' 'unsafe-inline' https://fonts.googleapis.com`,
|
||||
`img-src 'self' data: blob: https:`,
|
||||
`font-src 'self' data: https://fonts.gstatic.com ${fontOrigins.join(' ')}`.trim(),
|
||||
`connect-src 'self' https://api.github.com https://fonts.gstatic.com ${connectOrigins.join(' ')}`.trim(),
|
||||
`connect-src 'self'${githubApiSource} https://fonts.gstatic.com ${connectOrigins.join(' ')}`.trim(),
|
||||
`object-src 'none'`,
|
||||
`base-uri 'self'`,
|
||||
`frame-ancestors 'self'`,
|
||||
|
||||
@@ -11,6 +11,7 @@ const SITE_URL = (process.env.SITE_URL || 'https://www.bentopdf.com').replace(
|
||||
/\/+$/,
|
||||
''
|
||||
);
|
||||
const BASE_PATH = (process.env.BASE_URL || '/').replace(/\/$/, '');
|
||||
const HOST = new URL(SITE_URL).hostname;
|
||||
|
||||
const NOINDEX_ALLOWLIST = new Set(['404.html', 'wasm-settings.html']);
|
||||
@@ -72,6 +73,7 @@ function expectedCanonicalForFile(rel) {
|
||||
const baseName = fileName.replace(/\.html$/, '');
|
||||
const slug = baseName === 'index' ? '' : baseName;
|
||||
const segments = [SITE_URL];
|
||||
if (BASE_PATH) segments.push(BASE_PATH.replace(/^\//, ''));
|
||||
if (slug) segments.push(slug);
|
||||
return segments.join('/').replace(/\/+$/, '') || SITE_URL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user