From 4871047dbd0c5ef5e4089425a85ac85dcd9cf263 Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Wed, 15 Jun 2022 10:54:35 -0700 Subject: [PATCH] docs: Update analytics, canonical URL, ads (#15996) * docs: Update analytics, canonical URL, ads * Update docs/src/_includes/layouts/base.html Co-authored-by: Milos Djermanovic * Update docs/src/_data/links.json Co-authored-by: Milos Djermanovic * Update docs/src/_includes/partials/docs-footer.html Co-authored-by: Milos Djermanovic Co-authored-by: Milos Djermanovic --- docs/.eleventy.js | 10 ++ docs/package.json | 1 + docs/src/_data/links.json | 20 +++- docs/src/_data/site.js | 26 +++++ docs/src/_data/sites/en.yml | 109 ++++++++++++++++++ .../components/language-switcher.html | 24 ++-- docs/src/_includes/components/navigation.html | 8 +- .../_includes/components/social-icons.html | 36 ++++-- .../_includes/components/theme-switcher.html | 25 +++- .../_includes/layouts/{base.njk => base.html} | 37 ++++-- docs/src/_includes/layouts/components.html | 2 +- docs/src/_includes/layouts/doc.html | 2 +- docs/src/_includes/layouts/main.html | 2 +- docs/src/_includes/partials/analytics.html | 24 ++++ docs/src/_includes/partials/carbon-ad.html | 6 +- docs/src/_includes/partials/docs-footer.html | 2 +- docs/src/pages/404.html | 16 +-- 17 files changed, 291 insertions(+), 59 deletions(-) create mode 100644 docs/src/_data/site.js create mode 100644 docs/src/_data/sites/en.yml rename docs/src/_includes/layouts/{base.njk => base.html} (77%) create mode 100644 docs/src/_includes/partials/analytics.html diff --git a/docs/.eleventy.js b/docs/.eleventy.js index 87416ff3cc5..49b6bbf0d5a 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -9,6 +9,7 @@ const markdownItAnchor = require("markdown-it-anchor"); const markdownItContainer = require("markdown-it-container"); const Image = require("@11ty/eleventy-img"); const path = require("path"); +const yaml = require("js-yaml"); const { DateTime @@ -39,7 +40,16 @@ module.exports = function(eleventyConfig) { pathPrefix = "/docs/latest/"; } + //------------------------------------------------------------------------------ + // Data + //------------------------------------------------------------------------------ + + // Load site-specific data + const siteName = process.env.ESLINT_SITE_NAME || "en"; + + eleventyConfig.addGlobalData("site_name", siteName); eleventyConfig.addGlobalData("GIT_BRANCH", process.env.BRANCH); + eleventyConfig.addDataExtension("yml", contents => yaml.load(contents)); //------------------------------------------------------------------------------ // Filters diff --git a/docs/package.json b/docs/package.json index 85ce93cb40e..62b97a3da3a 100644 --- a/docs/package.json +++ b/docs/package.json @@ -30,6 +30,7 @@ "eleventy-plugin-reading-time": "^0.0.1", "imagemin": "^8.0.1", "imagemin-cli": "^7.0.0", + "js-yaml": "^3.14.1", "luxon": "^2.4.0", "markdown-it": "^12.2.0", "markdown-it-anchor": "^8.1.2", diff --git a/docs/src/_data/links.json b/docs/src/_data/links.json index 2c4e4941242..d9b29733216 100644 --- a/docs/src/_data/links.json +++ b/docs/src/_data/links.json @@ -2,5 +2,21 @@ "github": "https://github.com/eslint/eslint", "twitter": "https://twitter.com/geteslint", "chat": "https://eslint.org/chat", - "group": "https://groups.google.com/group/eslint" -} \ No newline at end of file + "group": "https://groups.google.com/group/eslint", + + "blog": "/blog", + "docs": "/docs/latest/", + "playground": "/play", + "getStarted": "/docs/latest/user-guide/getting-started", + "sponsors": "/sponsors", + "branding": "/branding", + "store": "https://eslint.threadless.com", + "team": "/team", + + "configuring": "https://eslint.org/docs/user-guide/configuring/", + "fixProblems": "https://eslint.org/docs/user-guide/command-line-interface#fixing-problems", + + "donate": "/donate", + "openCollective": "https://opencollective.com/eslint", + "githubSponsors": "https://github.com/sponsors/eslint" +} diff --git a/docs/src/_data/site.js b/docs/src/_data/site.js new file mode 100644 index 00000000000..d0792694f48 --- /dev/null +++ b/docs/src/_data/site.js @@ -0,0 +1,26 @@ +/** + * @fileoverview Convenience helper for site data. + * @author Nicholas C. Zakas + */ + +//----------------------------------------------------------------------------- +// Requirements +//----------------------------------------------------------------------------- + +const path = require("path"); +const fs = require("fs"); +const yaml = require("js-yaml"); + +//----------------------------------------------------------------------------- +// Exports +//----------------------------------------------------------------------------- + +module.exports = function(eleventy) { + + const siteName = eleventy.site_name; + const siteDataFile = path.resolve(__dirname, `sites/${siteName}.yml`); + + fs.statSync(siteDataFile); + + return yaml.load(fs.readFileSync(siteDataFile)); +} diff --git a/docs/src/_data/sites/en.yml b/docs/src/_data/sites/en.yml new file mode 100644 index 00000000000..c929da0c3c1 --- /dev/null +++ b/docs/src/_data/sites/en.yml @@ -0,0 +1,109 @@ +#------------------------------------------------------------------------------ +# English Site Details +# The documentation site that is hosted at eslint.org/docs +# Author: Nicholas C. Zakas +#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# Global Settings +#------------------------------------------------------------------------------ + +language: + code: en + flag: πŸ‡ΊπŸ‡Έ + name: English (US) +locale: en-US +hostname: eslint.org + +#------------------------------------------------------------------------------ +# Analytics +#------------------------------------------------------------------------------ + +google_analytics: + code: "G-7DGPHY308T" + +#------------------------------------------------------------------------------ +# Ads +#------------------------------------------------------------------------------ + +carbon_ads: + serve: CESDV2QM + placement: eslintorg + +#------------------------------------------------------------------------------ +# Shared +#------------------------------------------------------------------------------ + +shared: + get_started: Get Started + become_a_sponsor: Become a Sponsor + eslint_logo_alt: ESLint logo + description: > + A pluggable and configurable linter tool for identifying and reporting on + patterns in JavaScript. Maintain your code quality with ease. + title_format: PAGE_TITLE - ESLint - Pluggable JavaScript Linter + skip_to_content: Skip to main content + donate: Donate + +#------------------------------------------------------------------------------ +# Navigation +#------------------------------------------------------------------------------ + +navigation: +- text: Team + link: team +- text: Blog + link: blog +- text: Docs + link: docs +- text: Store + link: store + target: _blank +- text: Playground + link: playground + +#------------------------------------------------------------------------------ +# Footer +#------------------------------------------------------------------------------ + +footer: + title: Ready to fix your JavaScript code? + description: Install from npm or start donating today. + secondary: Secondary + social_icons: + title: Social Media + twitter: Twitter + chat: Discord + mailing_list: Google Group + github: GitHub + theme_switcher: + title: Theme Switcher + light: Light + dark: Dark + language_switcher: + title: Language Switcher + description: Selecting a language will take you to the ESLint website in that language. + change_language: Change Language + language: Language + copyright: > + © OpenJS Foundation and ESLint contributors, www.openjsf.org + links: + open_jsf: The OpenJS Foundation + terms: Terms of Use + privacy: Privacy Policy + bylaws: OpenJS Foundation Bylaws + trademark: Trademark Policy + trademark_list: Trademark List + cookies: Cookie Policy + +#------------------------------------------------------------------------------ +# 404 Page +#------------------------------------------------------------------------------ + +404_page: + title: 404 error + subtitle: Page not found + description: Sorry, the page you are looking for doesn't exist or has been moved. + actions: + back_to_home: Back to homepage + browse_docs: Browse the docs diff --git a/docs/src/_includes/components/language-switcher.html b/docs/src/_includes/components/language-switcher.html index 0c945201d41..aef1c2aa956 100644 --- a/docs/src/_includes/components/language-switcher.html +++ b/docs/src/_includes/components/language-switcher.html @@ -1,22 +1,22 @@
- Change language -