diff options
author | Russell Dickenson <rdickenson@gitlab.com> | 2023-09-04 07:19:45 +0300 |
---|---|---|
committer | Russell Dickenson <rdickenson@gitlab.com> | 2023-09-04 07:19:45 +0300 |
commit | c297e4a0f60fb1fbc354e1e20c6fdf62231c72d8 (patch) | |
tree | dca871d4898914d1c06c9f29c315ee9d0e2fca04 | |
parent | e358375c9252d34b010ef9d76eb3d92bd9e88396 (diff) | |
parent | 9edfc2cc7245ac6c847a4c30e480429820a3033d (diff) |
Merge branch 'revert-5427da6b' into 'main'fneill-nav-update-runner-api-tutorial
Revert "Merge branch '1705-googlebot-badge-block' into 'main'"
See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/4220
Merged-by: Russell Dickenson <rdickenson@gitlab.com>
Co-authored-by: Evan Read <eread@gitlab.com>
-rw-r--r-- | content/frontend/default/badges.js | 50 | ||||
-rw-r--r-- | content/frontend/default/default.js | 49 | ||||
-rw-r--r-- | content/robots.txt.erb | 1 | ||||
-rw-r--r-- | layouts/default.html | 1 |
4 files changed, 48 insertions, 53 deletions
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', - ' <span data-component="docs-badges" data-nosnippet><span data-type="content" data-value="contribute"></span></span>', - ); -} -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,16 +1,63 @@ /* 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', + ' <span data-component="docs-badges"><span data-type="content" data-value="contribute"></span></span>', + ); + } + 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 */ const versionBanner = document.querySelector('#js-version-banner'); 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 %> <script src="<%= @items['/frontend/header/index.*'].path %>"></script> <script src="<%= @items['/assets/javascripts/tables.*'].path %>"></script> - <script src="<%= @items['/frontend/default/badges.*'].path %>"></script> <%# Add analytics only in production %> <%= render '/analytics.*' %> |