!-- MANTAS PHOTOGRAPHY - HEADER SEO, SCHEMA, PERFORMANCE -->
window.location.hostname.indexOf("squarespace.com") > -1 ||
window.location.hostname.indexOf("sqsp") > -1 ||
window.location.pathname.indexOf("/config") > -1 ||
window.location.search.indexOf("editing=true") > -1 ||
window.location.search.indexOf("preview=true") > -1
);
} catch (e) {
return true;
}
}
function normalizePath(pathname) {
var path = pathname || "/";
path = path.replace(/\/{2,}/g, "/");
if (path !== "/") path = path.replace(/\/+$/, "");
return path;
}
function redirectAmpUrls() {
if (isSquarespaceEditor()) return;
if (!window.URLSearchParams) return;
var params = new URLSearchParams(window.location.search);
if (params.get("format") === "amp") {
params.delete("format");
var cleanSearch = params.toString();
var cleanUrl =
preferredOrigin +
normalizePath(window.location.pathname) +
(cleanSearch ? "?" + cleanSearch : "") +
window.location.hash;
window.location.replace(cleanUrl);
}
}
function redirectToPreferredHost() {
if (isSquarespaceEditor()) return;
if (window.location.protocol === "http:" || window.location.hostname !== preferredHost) {
window.location.replace(
preferredOrigin +
normalizePath(window.location.pathname) +
window.location.search +
window.location.hash
);
}
}
function isBrokenSchema(text) {
return text && (
text.indexOf("Potography") !== -1 ||
text.indexOf("Mantas Kubilinskas Potography") !== -1
);
}
function cleanBrokenSchema() {
document.querySelectorAll('script[type="application/ld+json"]').forEach(function (script) {
if (isBrokenSchema(script.textContent || "")) {
script.remove();
}
});
}
function removeDuplicateCanonical() {
var links = document.querySelectorAll('link[rel="canonical"]');
if (links.length <= 1) return;
for (var i = 1; i < links.length; i++) {
links[i].remove();
}
}
function addSearchNoindex() {
var isSearchPage =
window.location.pathname.indexOf("/search") === 0 ||
window.location.search.indexOf("q=") > -1;
if (!isSearchPage) return;
var existing = document.querySelector('meta[name="robots"]');
if (existing) {
existing.setAttribute("content", "noindex, nofollow");
return;
}
var meta = document.createElement("meta");
meta.name = "robots";
meta.content = "noindex, nofollow";
document.head.appendChild(meta);
}
function forceSecureMetaImages() {
document
.querySelectorAll('meta[property="og:image"], meta[property="og:image:secure_url"], meta[name="twitter:image"]')
.forEach(function (meta) {
var content = meta.getAttribute("content");
if (content && content.indexOf("http://") === 0) {
meta.setAttribute("content", content.replace(/^http:\/\//, "https://"));
}
});
var twitterCard = document.querySelector('meta[name="twitter:card"]');
if (!twitterCard) {
twitterCard = document.createElement("meta");
twitterCard.setAttribute("name", "twitter:card");
document.head.appendChild(twitterCard);
}
if (twitterCard.getAttribute("content") === "summary" || !twitterCard.getAttribute("content")) {
twitterCard.setAttribute("content", "summary_large_image");
}
}
function removeDuplicateMetaTags(selector) {
var tags = document.querySelectorAll(selector);
if (tags.length <= 1) return;
for (var i = 1; i < tags.length; i++) {
tags[i].remove();
}
}
function addSkipLink() {
if (document.querySelector(".mk-skip-link")) return;
var target =
document.querySelector("main") ||
document.querySelector("#siteWrapper") ||
document.querySelector(".site-wrapper");
if (!target) return;
if (!target.id) {
target.id = "mk-main-content";
}
var skipLink = document.createElement("a");
skipLink.href = "#" + target.id;
skipLink.className = "mk-skip-link";
skipLink.setAttribute("aria-label", "Skip to main content");
skipLink.textContent = "Skip to main content";
document.body.insertBefore(skipLink, document.body.firstChild);
}
function addBreadcrumbSchema() {
if (document.documentElement.hasAttribute("data-mk-breadcrumb-schema-loaded")) return;
var rawPath = window.location.pathname.replace(/^\/|\/$/g, "");
if (!rawPath) return;
document.documentElement.setAttribute("data-mk-breadcrumb-schema-loaded", "true");
var path = rawPath.split("/").filter(Boolean);
var items = [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://www.mantasphoto.com/"
}
];
var urlSoFar = "https://www.mantasphoto.com/";
var nameMap = {
"weddings": "Weddings",
"engagement": "Engagement",
"about-mantas-kubilinskas": "About",
"awards": "Awards",
"blog-articles": "Blog",
"blog": "Blog",
"contact-mantas-kubilinskas": "Contact",
"faq": "FAQ",
"faqs": "FAQ",
"investment": "Investment",
"portfolio": "Portfolio",
"testimonials": "Testimonials",
"home-gallery": "Gallery"
};
path.forEach(function (segment, index) {
urlSoFar += segment + "/";
var cleanSegment = decodeURIComponent(segment).toLowerCase();
var name =
nameMap[cleanSegment] ||
segment
.replace(/-/g, " ")
.replace(/\b\w/g, function (letter) {
return letter.toUpperCase();
})
.replace(/\bDc\b/g, "DC")
.replace(/\bMd\b/g, "MD")
.replace(/\bVa\b/g, "VA")
.replace(/\bNyc\b/g, "NYC");
items.push({
"@type": "ListItem",
"position": index + 2,
"name": name,
"item": urlSoFar
});
});
var script = document.createElement("script");
script.type = "application/ld+json";
script.text = JSON.stringify({
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": items
});
document.head.appendChild(script);
}
function runOptimizations() {
document.documentElement.setAttribute("lang", "en-US");
cleanBrokenSchema();
removeDuplicateCanonical();
addSearchNoindex();
addSkipLink();
forceSecureMetaImages();
removeDuplicateMetaTags('meta[name="twitter:image"]');
removeDuplicateMetaTags('meta[property="og:image"]');
removeDuplicateMetaTags('meta[property="og:image:secure_url"]');
addBreadcrumbSchema();
}
redirectAmpUrls();
redirectToPreferredHost();
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", runOptimizations);
} else {
runOptimizations();
}
window.addEventListener("load", runOptimizations);
})();