From 9edfc2cc7245ac6c847a4c30e480429820a3033d Mon Sep 17 00:00:00 2001 From: Evan Read Date: Mon, 4 Sep 2023 04:19:45 +0000 Subject: Revert "Merge branch '1705-googlebot-badge-block' into 'main'" --- content/frontend/default/badges.js | 50 ------------------------------------- content/frontend/default/default.js | 49 +++++++++++++++++++++++++++++++++++- content/robots.txt.erb | 1 - layouts/default.html | 1 - 4 files changed, 48 insertions(+), 53 deletions(-) delete mode 100644 content/frontend/default/badges.js diff --git a/content/frontend/default/badges.js b/content/frontend/default/badges.js deleted file mode 100644 index eabe9a3d..00000000 --- a/content/frontend/default/badges.js +++ /dev/null @@ -1,50 +0,0 @@ -/* global Vue */ -import { isContainedInHeading } from '../shared/dom'; -import DocsBadges from './components/docs_badges.vue'; - -/** - * Badge components - * - * Badges are typically added in markdown and rendered by Nanoc as spans. - * Contributor docs have a section-wide badge added here. - */ -const isContributorDocs = () => { - const paths = [ - '/ee/development/', - '/omnibus/development/', - '/runner/development/', - '/charts/development/', - ]; - return paths.some((substr) => window.location.pathname.startsWith(substr)); -}; -// Inject markup for our Contributor docs badge. -if (isContributorDocs()) { - document - .querySelector('h1 a') - .insertAdjacentHTML( - 'beforebegin', - ' ', - ); -} -document.querySelectorAll('[data-component="docs-badges"]').forEach((badgeSet) => { - const badges = badgeSet.querySelectorAll('span'); - - // Get badges that were added to the heading - const badgesData = Array.from(badges).map((badge) => ({ - type: badge.getAttribute('data-type'), - text: badge.getAttribute('data-value'), - })); - - (() => - new Vue({ - el: badgeSet, - components: { - DocsBadges, - }, - render(createElement) { - return createElement(DocsBadges, { - props: { badgesData, isHeading: isContainedInHeading(badgeSet) }, - }); - }, - }))(); -}); diff --git a/content/frontend/default/default.js b/content/frontend/default/default.js index 9b4b6053..f4c92c54 100644 --- a/content/frontend/default/default.js +++ b/content/frontend/default/default.js @@ -1,15 +1,62 @@ /* global Vue */ -import { getNextUntil } from '../shared/dom'; +import { getNextUntil, isContainedInHeading } from '../shared/dom'; import NavigationToggle from './components/navigation_toggle.vue'; import VersionBanner from './components/version_banner.vue'; import { setupTableOfContents } from './setup_table_of_contents'; import VersionsMenu from './components/versions_menu.vue'; import TabsSection from './components/tabs_section.vue'; +import DocsBadges from './components/docs_badges.vue'; /* eslint-disable no-new */ document.addEventListener('DOMContentLoaded', () => { setupTableOfContents(); + /** + * Badge components + * + * Badges are typically added in markdown and rendered by Nanoc as spans. + * Contributor docs have a section-wide badge added here. + */ + const isContributorDocs = () => { + const paths = [ + '/ee/development/', + '/omnibus/development/', + '/runner/development/', + '/charts/development/', + ]; + return paths.some((substr) => window.location.pathname.startsWith(substr)); + }; + // Inject markup for our Contributor docs badge. + if (isContributorDocs()) { + document + .querySelector('h1 a') + .insertAdjacentHTML( + 'beforebegin', + ' ', + ); + } + document.querySelectorAll('[data-component="docs-badges"]').forEach((badgeSet) => { + const badges = badgeSet.querySelectorAll('span'); + + // Get badges that were added to the heading + const badgesData = Array.from(badges).map((badge) => ({ + type: badge.getAttribute('data-type'), + text: badge.getAttribute('data-value'), + })); + + new Vue({ + el: badgeSet, + components: { + DocsBadges, + }, + render(createElement) { + return createElement(DocsBadges, { + props: { badgesData, isHeading: isContainedInHeading(badgeSet) }, + }); + }, + }); + }); + /** * Banner components */ diff --git a/content/robots.txt.erb b/content/robots.txt.erb index 6be46cef..f7bfd466 100644 --- a/content/robots.txt.erb +++ b/content/robots.txt.erb @@ -8,7 +8,6 @@ sitemap: https://docs.gitlab.com/sitemap.xml user-agent: * disallow: /ce/ disallow: /debug/ -disallow: /frontend/default/badges.js <% elsif stable_version?(current_branch) %> # If on stables branches sitemap: https://docs.gitlab.com/<%= current_branch %>/sitemap.xml diff --git a/layouts/default.html b/layouts/default.html index 09d5df66..ccc36f4b 100644 --- a/layouts/default.html +++ b/layouts/default.html @@ -95,7 +95,6 @@ <% end %> - <%# Add analytics only in production %> <%= render '/analytics.*' %> -- cgit v1.2.3