|
| 1 | +/* Force default dark mode if no user preference is stored. */ |
| 2 | +window.addEventListener('DOMContentLoaded', function () { |
| 3 | + if (localStorage.getItem('theme') === null) { |
| 4 | + document.documentElement.setAttribute('data-bs-theme', 'dark'); |
| 5 | + var darkButton = document.querySelector('[data-bs-theme-value="dark"]'); |
| 6 | + if (darkButton) { |
| 7 | + // Simulate click to update button state and lightswitch.js internal state |
| 8 | + darkButton.click(); |
| 9 | + // Remove it from localStorage so it doesn't force this preference later |
| 10 | + localStorage.removeItem('theme'); |
| 11 | + } |
| 12 | + } |
| 13 | + |
| 14 | + /* ── SEO: canonical link ─────────────────────────────────────────── */ |
| 15 | + if (!document.querySelector('link[rel="canonical"]')) { |
| 16 | + var canonical = document.createElement('link'); |
| 17 | + canonical.rel = 'canonical'; |
| 18 | + canonical.href = window.location.href.split('?')[0].split('#')[0]; |
| 19 | + document.head.appendChild(canonical); |
| 20 | + } |
| 21 | + |
| 22 | + /* ── SEO: meta keywords ──────────────────────────────────────────── */ |
| 23 | + if (!document.querySelector('meta[name="keywords"]')) { |
| 24 | + var kw = document.createElement('meta'); |
| 25 | + kw.name = 'keywords'; |
| 26 | + kw.content = [ |
| 27 | + 'selection index', 'plant breeding', 'quantitative genetics', |
| 28 | + 'R package', 'CRAN', 'genomic selection', 'marker-assisted selection', |
| 29 | + 'genetic advance', 'phenotypic selection', 'LPSI', 'LGSI', 'LMSI', |
| 30 | + 'eigen selection index', 'multistage selection', 'stochastic simulation', |
| 31 | + 'heritability', 'variance-covariance matrix', 'economic weights', |
| 32 | + 'breeding pipeline', 'selection.index' |
| 33 | + ].join(', '); |
| 34 | + document.head.appendChild(kw); |
| 35 | + } |
| 36 | + |
| 37 | + /* ── SEO: Open Graph type (pkgdown sets title/desc, we fix type) ─── */ |
| 38 | + var ogType = document.querySelector('meta[property="og:type"]'); |
| 39 | + if (!ogType) { |
| 40 | + var meta = document.createElement('meta'); |
| 41 | + meta.setAttribute('property', 'og:type'); |
| 42 | + meta.content = 'website'; |
| 43 | + document.head.appendChild(meta); |
| 44 | + } |
| 45 | + |
| 46 | + /* ── SEO: Twitter Card tags ──────────────────────────────────────── */ |
| 47 | + var twitterCard = document.querySelector('meta[name="twitter:card"]'); |
| 48 | + if (!twitterCard) { |
| 49 | + [ |
| 50 | + { name: 'twitter:card', content: 'summary' }, |
| 51 | + { name: 'twitter:title', content: document.title }, |
| 52 | + { name: 'twitter:description', content: (document.querySelector('meta[name="description"]') || {}).content || '' }, |
| 53 | + { name: 'twitter:site', content: '@zankrut20' } |
| 54 | + ].forEach(function (attrs) { |
| 55 | + var m = document.createElement('meta'); |
| 56 | + m.name = attrs.name; |
| 57 | + m.content = attrs.content; |
| 58 | + document.head.appendChild(m); |
| 59 | + }); |
| 60 | + } |
| 61 | + |
| 62 | + /* ── SEO: JSON-LD SoftwareApplication structured data ────────────── */ |
| 63 | + if (!document.querySelector('script[type="application/ld+json"]')) { |
| 64 | + var schema = { |
| 65 | + '@context': 'https://schema.org', |
| 66 | + '@type': 'SoftwareApplication', |
| 67 | + 'name': 'selection.index', |
| 68 | + 'alternateName': 'selection.index R Package', |
| 69 | + 'description': 'A production-ready R package for plant breeders and quantitative geneticists to compute classical phenotypic, genomic, marker-assisted, restricted, constrained, and eigen selection indices. Maximizes genetic advance with multi-trait LPSI, LGSI, LMSI, and stochastic simulation tools.', |
| 70 | + 'applicationCategory': 'ScientificApplication', |
| 71 | + 'applicationSubCategory': 'Plant Breeding & Quantitative Genetics', |
| 72 | + 'operatingSystem': 'Windows, macOS, Linux', |
| 73 | + 'programmingLanguage': 'R', |
| 74 | + 'softwareVersion': '2.0.1', |
| 75 | + 'dateModified': '2026-03-06', |
| 76 | + 'license': 'https://www.gnu.org/licenses/gpl-3.0', |
| 77 | + 'url': 'https://zankrut20.github.io/selection.index/', |
| 78 | + 'downloadUrl': 'https://cran.r-project.org/package=selection.index', |
| 79 | + 'installUrl': 'https://cran.r-project.org/package=selection.index', |
| 80 | + 'author': { |
| 81 | + '@type': 'Person', |
| 82 | + 'name': 'Zankrut Goyani', |
| 83 | + 'email': 'zankrut20@gmail.com', |
| 84 | + 'url': 'https://github.com/zankrut20' |
| 85 | + }, |
| 86 | + 'maintainer': { |
| 87 | + '@type': 'Person', |
| 88 | + 'name': 'Zankrut Goyani', |
| 89 | + 'email': 'zankrut20@gmail.com' |
| 90 | + }, |
| 91 | + 'publisher': { |
| 92 | + '@type': 'Person', |
| 93 | + 'name': 'Zankrut Goyani' |
| 94 | + }, |
| 95 | + 'sameAs': [ |
| 96 | + 'https://github.com/zankrut20/selection.index', |
| 97 | + 'https://cran.r-project.org/package=selection.index', |
| 98 | + 'https://cloud.r-project.org/package=selection.index' |
| 99 | + ], |
| 100 | + 'offers': { |
| 101 | + '@type': 'Offer', |
| 102 | + 'price': '0', |
| 103 | + 'priceCurrency': 'USD' |
| 104 | + }, |
| 105 | + 'keywords': [ |
| 106 | + 'selection index', 'plant breeding', 'quantitative genetics', |
| 107 | + 'genomic selection', 'marker-assisted selection', 'LPSI', 'LGSI', |
| 108 | + 'eigen selection index', 'multistage selection', 'stochastic simulation', |
| 109 | + 'genetic advance', 'heritability', 'R package' |
| 110 | + ] |
| 111 | + }; |
| 112 | + var ld = document.createElement('script'); |
| 113 | + ld.type = 'application/ld+json'; |
| 114 | + ld.textContent = JSON.stringify(schema, null, 2); |
| 115 | + document.head.appendChild(ld); |
| 116 | + } |
| 117 | +}); |
| 118 | + |
0 commit comments