From f7227ed850f9aa5eae474765fd237213d1ffafb8 Mon Sep 17 00:00:00 2001 From: Matt Cowley Date: Thu, 26 May 2022 01:49:55 +0100 Subject: [PATCH] Remove tutorials from website (#112) * Remove library tutorials from website * Add deprecation notice to tutorial API endpoints * Add deprecation notice for tutorials property of library endpoint * Remove all documentation for deprecated endpoints --- .../components/tutorial/_tutorial_author.scss | 47 ----- .../components/tutorial/_tutorial_hero.scss | 44 ----- .../components/tutorial/_tutorial_list.scss | 46 ----- assets/scss/style.scss | 5 - assets/scss/views/_api.scss | 34 ++++ ..._libraries-library-tutorials-tutorial.scss | 61 ------ .../views/_libraries-library-tutorials.scss | 17 -- components/api/library.vue | 67 +++---- components/api/tutorial.vue | 178 ++---------------- components/api/tutorials.vue | 175 ++--------------- components/json-ld/tutorial.vue | 35 ---- components/json-ld/tutorials.vue | 38 ---- components/tutorial/tutorial_author.vue | 59 ------ components/tutorial/tutorial_hero.vue | 66 ------- components/tutorial/tutorial_list.vue | 75 -------- data/json-ld/library.js | 4 - data/json-ld/tutorial.js | 38 ---- data/json-ld/tutorials.js | 27 --- pages/libraries/_library/index.vue | 4 - .../_library/tutorials/_tutorial.vue | 150 --------------- pages/libraries/_library/tutorials/index.vue | 77 -------- util/build/routes.js | 18 +- util/build/sitemap.js | 2 +- util/get_library.js | 2 +- util/get_tutorial.js | 25 --- 25 files changed, 94 insertions(+), 1200 deletions(-) delete mode 100644 assets/scss/components/tutorial/_tutorial_author.scss delete mode 100644 assets/scss/components/tutorial/_tutorial_hero.scss delete mode 100644 assets/scss/components/tutorial/_tutorial_list.scss delete mode 100644 assets/scss/views/_libraries-library-tutorials-tutorial.scss delete mode 100644 assets/scss/views/_libraries-library-tutorials.scss delete mode 100644 components/json-ld/tutorial.vue delete mode 100644 components/json-ld/tutorials.vue delete mode 100644 components/tutorial/tutorial_author.vue delete mode 100644 components/tutorial/tutorial_hero.vue delete mode 100644 components/tutorial/tutorial_list.vue delete mode 100644 data/json-ld/tutorial.js delete mode 100644 data/json-ld/tutorials.js delete mode 100644 pages/libraries/_library/tutorials/_tutorial.vue delete mode 100644 pages/libraries/_library/tutorials/index.vue delete mode 100644 util/get_tutorial.js diff --git a/assets/scss/components/tutorial/_tutorial_author.scss b/assets/scss/components/tutorial/_tutorial_author.scss deleted file mode 100644 index c207a3c46f..0000000000 --- a/assets/scss/components/tutorial/_tutorial_author.scss +++ /dev/null @@ -1,47 +0,0 @@ -.tutorial-author { - background: $primary; - width: 100%; - - img { - border-radius: $radius; - margin: 0 $whitespace 0 0; - } - - .details { - p { - @include font-light; - - color: $banner; - font-size: 16px; - margin: 0 0 $whitespace; - - a { - color: darken($banner, 7%); - text-decoration: underline; - transition: color $transition-duration $transition-timing-function; - - &:hover, - &:focus { - color: $darker; - } - } - - &.name { - @include font-medium; - - font-size: 22px; - margin: ($whitespace * .25) 0 $whitespace; - } - - &.social { - font-size: 20px; - - a { - display: inline-block; - margin: 0 ($whitespace * .5) 0 0; - text-decoration: none; - } - } - } - } -} diff --git a/assets/scss/components/tutorial/_tutorial_hero.scss b/assets/scss/components/tutorial/_tutorial_hero.scss deleted file mode 100644 index bbdc9b48ec..0000000000 --- a/assets/scss/components/tutorial/_tutorial_hero.scss +++ /dev/null @@ -1,44 +0,0 @@ -.tutorial-hero { - h1 { - @include font-medium; - - color: $light; - font-size: 45px; - margin: ($whitespace * .5) 0 0; - } - - h2 { - @include font-medium; - - color: $light; - font-size: 25px; - margin: ($whitespace * .125) 0 ($whitespace * 1.5); - - a { - @include primary-link; - } - } - - p { - @include font-regular; - - color: $light; - font-size: 18px; - } - - .description { - margin: ($whitespace * 1) 0 ($whitespace * .5); - } - - .author { - margin: 0; - - p { - margin: ($whitespace * .25) $whitespace ($whitespace * .5) 0; - - a { - @include primary-link; - } - } - } -} diff --git a/assets/scss/components/tutorial/_tutorial_list.scss b/assets/scss/components/tutorial/_tutorial_list.scss deleted file mode 100644 index b3fd8cbe7b..0000000000 --- a/assets/scss/components/tutorial/_tutorial_list.scss +++ /dev/null @@ -1,46 +0,0 @@ -.tutorial-list { - h3 { - @include font-medium; - - color: $light; - font-size: 30px; - margin: ($whitespace * 2) 0 ($whitespace); - } - - p { - @include font-regular; - - color: $light; - font-size: 20px; - margin: ($whitespace * .5) 0 ($whitespace); - - a { - @include primary-link; - } - } - - ul { - border-top: 3px solid $white; - list-style: none; - margin: ($whitespace * 2) 0 0; - padding: ($whitespace * 2) 0; - - li { - margin: 0 0 ($whitespace); - - p { - font-size: 20px; - margin: 0; - - &:not(:first-child) { - font-size: 16px; - } - - a { - display: inline-block; - line-height: 1.5; - } - } - } - } -} diff --git a/assets/scss/style.scss b/assets/scss/style.scss index 1137f16106..6ae8f51f9a 100644 --- a/assets/scss/style.scss +++ b/assets/scss/style.scss @@ -18,9 +18,6 @@ @import "components/library/library_card"; @import "components/library/library_hero"; @import "components/library/library_asset_buttons"; -@import "components/tutorial/tutorial_hero"; -@import "components/tutorial/tutorial_author"; -@import "components/tutorial/tutorial_list"; @import "components/search/search"; @import "components/banner"; @import "components/footer"; @@ -32,7 +29,5 @@ @import "views/libraries"; @import "views/libraries-library"; @import "views/libraries-library-version"; -@import "views/libraries-library-tutorials"; -@import "views/libraries-library-tutorials-tutorial"; @import "views/about"; @import "views/api"; diff --git a/assets/scss/views/_api.scss b/assets/scss/views/_api.scss index 6837e50602..4bc4145ed9 100644 --- a/assets/scss/views/_api.scss +++ b/assets/scss/views/_api.scss @@ -122,6 +122,40 @@ main { } } } + + .callout { + align-items: center; + background: rgba($primary, .9); + border-radius: .5em; + display: flex; + flex-flow: row nowrap; + margin: 2em 0; + padding: 1em; + + > * { + margin: 0 .5em; + } + + .icon { + color: $white; + font-size: 2.25em; + } + + p { + @include font-medium; + + color: $banner; + + a { + color: $white; + + &:hover, + &:focus { + color: $banner; + } + } + } + } } } } diff --git a/assets/scss/views/_libraries-library-tutorials-tutorial.scss b/assets/scss/views/_libraries-library-tutorials-tutorial.scss deleted file mode 100644 index 676bbfb987..0000000000 --- a/assets/scss/views/_libraries-library-tutorials-tutorial.scss +++ /dev/null @@ -1,61 +0,0 @@ -main { - &.libraries-library-tutorials-tutorial { - .tutorial { - max-width: 100%; - - h1, - h2 { - @include font-bold; - } - - h3, - h4, - h5 { - @include font-medium; - } - - h1 { - font-size: 2.4rem; - } - - h2 { - font-size: 2rem; - } - - h3 { - font-size: 1.6rem; - } - - h4 { - font-size: 1.2rem; - } - - h5 { - font-size: .8rem; - } - - p { - line-height: 1.5; - margin: 0 0 ($whitespace * .5); - } - - a { - @include primary-link; - - text-decoration: underline; - } - } - - .callout { - align-items: center; - - h4 { - margin: $whitespace 0; - } - - .button { - margin: $whitespace; - } - } - } -} diff --git a/assets/scss/views/_libraries-library-tutorials.scss b/assets/scss/views/_libraries-library-tutorials.scss deleted file mode 100644 index 565117a9be..0000000000 --- a/assets/scss/views/_libraries-library-tutorials.scss +++ /dev/null @@ -1,17 +0,0 @@ -main { - &.libraries-library-tutorials { - .tutorials-hero { - h1 { - @include font-medium; - - color: $light; - font-size: 45px; - margin: ($whitespace * .5) 0 0; - - a { - @include primary-link; - } - } - } - } -} diff --git a/components/api/library.vue b/components/api/library.vue index 2428f02724..3c69f7b5b1 100644 --- a/components/api/library.vue +++ b/components/api/library.vue @@ -4,6 +4,22 @@ Getting a specific library on cdnjs
+
+ +
+

+ The tutorials property of libraries is deprecated. + It will always be an empty array, and will be removed in the future. +

+

+ See + + cdnjs/cdnjs issue #14130 + for more information. +

+
+
+

The /libraries/:library endpoint allows for data on a specific library to be requested and will return a JSON object with all library data properties by default. @@ -68,11 +84,11 @@ {"name":"vue","author":"Evan You <yyx990803@gmail.com>","description":"Simple, Fast & Composable MVVM for building interactive interfaces","filename":"vue.min.js","sri":"sha256-ngFW3UnAN0Tnm76mDuu7uUtYEcG3G5H1+zioJw3t+68=","version":"2.6.11","repository":{"type":"git","url":"https://github.com/vuejs/vue.git"},"autoupdate":{"source":"npm","target":"vue"}}

- - https://api.cdnjs.com/libraries/react?fields=name,description,tutorials + + https://api.cdnjs.com/libraries/react?fields=name,description

- {"name":"react","description":"React is a JavaScript library for building user interfaces.","tutorials":[{"id":"universal-react-apps","modified":"2017-09-05T17:31:26.000Z","author":{"name":"Ahmed Bouchefra","email":"techiediaries9@gmail.com","description":"Web developer, technical writer and entrepreneur","homepage":"https://www.techiediaries.com","twitter":"techiediaries"},"description":"This tutorial will cover how to use React and Next.js to build a simple universal web app.","homepage":"https://www.techiediaries.com","keywords":["react","nextjs","universal"],"library-tags":["react","nextjs"],"name":"Building Universal Server Rendered Apps with React and Next.js 3.0","repository":"https://github.com/techiediaries","content":"\n## Introduction\n\nNext.js is a framework for quickly building universal (also called Isomorphic) server-rendered web apps with\nReact. In this tutorial you will learn essential concepts of server-rendered React apps by creating a demo app with Next.js.\n\nBuilding apps with Next.js is simple. You just create a <em>pages</em> directory and place React components in it.\nNext.js will take care of everything else.\n\nThis tutorial was originally published in [techiediaries](https://www.techiediaries.com/universal-react-apps-nextjs/)\n\nNow let's get started\n\nFirst we need to install the required tools:\n\n## Installing Next.js 2.0\n\nYou can install Next.js 2.0 via npm with:\n\n npm install --save next react react-dom\n\n## Installing Next.js 3.0\n\nNext.js 3.0 is still in beta, you can also install it via npm with:\n\n npm install next@beta react react-dom --save\n\n## Adding NPM Scripts to package.json\n\nBuilding apps with Next.js is a matter of using three commands:\n\n next\n next build\n next start\n\nSo lets add NPM scripts to trigger these commands:\n\n \"scripts\": {\n \"dev\": \"next\",\n \"build\": \"next build\",\n \"start\": \"next start\"\n },\n\n## Adding Pages\n\nTo create pages you first need to create a pages directory:\n\n mkdir pages\n\n### Adding the Home Page\n\nCreate an index.js file inside pages folder and put this content in it:\n\n import Link from 'next/link'\n export default () => (\n <div>\n <Link href='/'><a>Home</a></Link> -\n <Link href='/about'><a>About Me</a></Link> -\n <Link href='/contact'><a>Contact</a></Link>\n <br></br>\n <p>This is the home page</p>\n\n </div>\n )\n\n### Adding the About Page\n\nNext create an about.js file inside pages folder then put the following content:\n\n import Link from 'next/link'\n export default () => (\n <div>\n <Link href='/'><a>Home</a></Link> -\n <Link href='/about'><a>About Me</a></Link> -\n <Link href='/contact'><a>Contact</a></Link>\n <br></br>\n <p>This is about page</p>\n </div>\n )\n\n### Adding the Contact Page\n\nAdd contact.js file inside pages folder then put the following:\n\n import Link from 'next/link'\n export default () => (\n <div>\n <Link href='/'><a>Home</a></Link> -\n <Link href='/about'><a>About Me</a></Link> -\n <Link href='/contact'><a>Contact</a></Link>\n <br></br>\n <p>This is the contact page</p>\n\n </div>\n )\n\nNow you can launch next with:\n\n npm run dev\n\nYour app will be available from [http://localhost:3000](http://localhost:3000).\n\nAs you can see the names of files inside pages directory become the routes except for / which points to index.js\n\n## Conclusion\n\nUniversal apps become very popular in these days and thanks to React and Next.js you can build them in a matter\nof a few commands.\n\nThanks for reading!\n"}]} + {"name":"react","description":"React is a JavaScript library for building user interfaces."}

@@ -90,11 +106,13 @@ diff --git a/components/api/tutorials.vue b/components/api/tutorials.vue index aa4019d5c4..14cf6b41b5 100644 --- a/components/api/tutorials.vue +++ b/components/api/tutorials.vue @@ -4,173 +4,32 @@ Listing all tutorials for a library on cdnjs

-

- The /libraries/:library/tutorials endpoint returns a JSON array containing all the - user-submitted tutorials relating to this library on cdnjs. This is a mirror of the - tutorials property returned from the main library endpoint. -

-

- The cache lifetime on this endpoint is 24 hours. -

-

- - - Alongside the properties listed here, there may be other optional properties available based on - the metadata available in each source tutorial file. - - -

- -

Query Parameters

- - - - - - - - - - - - - - - - - -
ParameterTypeRequiredDescription
{{ field.param }}{{ field.type }}{{ field.req ? 'required' : 'optional' }} -

-
- -

JSON Response

- - - - - - - - - - - - - - - -
PropertyTypeDescription
{{ field.prop }} - - -

-
- -

Example Requests

- -

- - https://api.cdnjs.com/libraries/vue/tutorials - -

- [{"id":"wtf-is-vuex","modified":"2017-05-29T04:18:13.000Z","author":{"name":"Anthony","email":"anthony@vuejsdevelopers.com","description":"Web developer, author and online course instructor with Vue.js Developers","homepage":"http://vuejsdevelopers.com","twitter":"https://twitter.com/vuejsdevelopers"},"description":"Vuex is one of the most useful tools in the Vue.js ecosystem, but it can be very confusing at first. I've written this primer on Vuex to give you the background that I wish I'd had.","homepage":"http://vuejsdevelopers.com","keywords":["vue.js","vuex"],"library-tags":["vue.js","vuex"],"name":"WTF is Vuex? A Beginner's Guide To Vue's Application Data Store","repository":"https://github.com/vuejsdevelopers","content":"Vuex. Is it pronounced “vewks”, or “veweks”? Or maybe it’s meant to be “vew”, pronounced with a French-style silent “x”?\n\nMy trouble with understanding Vuex only began with the name.\n\nBeing an eager Vue developer I’d heard enough about Vuex to suspect that it must be an important part of the Vue ecosystem, even if I didn’t know what it actually was.\n\nI eventually had enough of wondering, so I went to the documentation with plans of a brief skim through; just enough to get the idea.\n\nTo my chagrin I was greeted with unfamiliar terms like “state management pattern”, “global singleton” and “source of truth”. These terms may make sense to anyone already familiar with the concept, but for me they didn’t gel at all.\n\nThe one thing I did get, though, was that Vuex had something to do with Flux and Redux. I didn’t know what those were either, but I figured it may help if I investigated them first.\n\nAfter a bit of research and persistence the concepts behind the jargon finally started to materialise in my mind. I was getting it. I went back to the Vuex documentation and it finally hit me…Vuex is freaking awesome!\n\nI’m still not quite sure how to pronounce it, but Vuex has become an essential piece in my Vue.js toolbelt. I think it’s totally worth your time to check it out too, so I’ve written this primer on Vuex to give you the background that I wish I’d had.\n\nNote: This article was originally posted [here on the Vue.js Developers blog](http://vuejsdevelopers.com/2017/05/15/vue-js-what-is-vuex/?jsdojo_id=cjs_wfv) on 2017/05/15 ..."}] -

- - Example response has been trimmed to remove text from tutorial content. - -

- -

- - https://api.cdnjs.com/libraries/backbone.js/tutorials?fields=name,modified - -

- [{"id":"cross-domain-sessions","name":"Cross-domain Backbone.js with sessions using CORS","modified":"2017-09-05T17:41:17.000Z"},{"id":"infinite-scrolling","name":"Lightweight Infinite Scrolling using Twitter API","modified":"2017-09-05T17:41:17.000Z"},{"id":"nodejs-restify-mongodb-mongoose","name":"Simple example - Node.js, Restify, MongoDb and Mongoose ","modified":"2017-09-05T17:41:17.000Z"},{"id":"organizing-backbone-using-modules","name":"Organizing your application using Modules (require.js)","modified":"2017-09-05T17:41:17.000Z"},{"id":"real-time-backbone-with-pubnub","name":"Real-Time Backbone With PubNub","modified":"2018-07-28T08:54:41.000Z"},{"id":"seo-for-single-page-apps","name":"SEO for single page apps","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-collection","name":"What is a collection?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-model","name":"What is a model?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-router","name":"What is a router?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-view","name":"What is a view?","modified":"2017-09-05T17:41:17.000Z"},{"id":"why-would-you-use-backbone","name":"Why do you need Backbone.js?","modified":"2017-09-05T17:41:17.000Z"}] +
+ +
+

+ The /libraries/:library/tutorials endpoint is deprecated. + All requests to this endpoint will return an empty array, and will return a 404 in the future. +

+

+ See + + cdnjs/cdnjs issue #14130 + for more information. +

+
+
diff --git a/components/json-ld/tutorial.vue b/components/json-ld/tutorial.vue deleted file mode 100644 index 97cf22df0b..0000000000 --- a/components/json-ld/tutorial.vue +++ /dev/null @@ -1,35 +0,0 @@ - diff --git a/components/json-ld/tutorials.vue b/components/json-ld/tutorials.vue deleted file mode 100644 index ae48d7c930..0000000000 --- a/components/json-ld/tutorials.vue +++ /dev/null @@ -1,38 +0,0 @@ - diff --git a/components/tutorial/tutorial_author.vue b/components/tutorial/tutorial_author.vue deleted file mode 100644 index 3c66d82389..0000000000 --- a/components/tutorial/tutorial_author.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - diff --git a/components/tutorial/tutorial_hero.vue b/components/tutorial/tutorial_hero.vue deleted file mode 100644 index 35898e0efc..0000000000 --- a/components/tutorial/tutorial_hero.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - diff --git a/components/tutorial/tutorial_list.vue b/components/tutorial/tutorial_list.vue deleted file mode 100644 index 78b479a660..0000000000 --- a/components/tutorial/tutorial_list.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - diff --git a/data/json-ld/library.js b/data/json-ld/library.js index 91c94fe7f6..519fe11fb0 100644 --- a/data/json-ld/library.js +++ b/data/json-ld/library.js @@ -27,9 +27,5 @@ export default (base, library, libraryName) => { softwareVersion: library.version, applicationCategory: 'library', operatingSystem: 'any', - hasPart: { - '@type': 'CreativeWorkSeries', - url: `${base}libraries/${libraryName}/tutorials`, - }, }; }; diff --git a/data/json-ld/tutorial.js b/data/json-ld/tutorial.js deleted file mode 100644 index e034d085e2..0000000000 --- a/data/json-ld/tutorial.js +++ /dev/null @@ -1,38 +0,0 @@ -export default (base, tutorial, tutorialName, library) => ({ - '@context': 'http://schema.org', - '@type': 'TechArticle', - name: tutorial.name, - headline: tutorial.name, - description: tutorial.description, - keywords: tutorial.keywords && tutorial.keywords.join(','), - url: `${base}libraries/${library}/tutorials/${tutorialName}`, - inLanguage: 'en', - accessMode: 'textual', - accessModeSufficient: 'textual', - isAccessibleForFree: true, - image: `${base}banner.png`, - isPartOf: { - '@type': 'CreativeWorkSeries', - url: `${base}libraries/${library}/tutorials`, - }, - author: { - '@type': 'Person', - name: tutorial.author.name, - }, - publisher: { - '@type': 'Organization', - name: 'cdnjs', - url: base, - logo: { - type: 'ImageObject', - url: `${base}favicon.png`, - }, - }, - sourceOrganization: { - '@type': 'Organization', - name: 'cdnjs', - url: base, - }, - dateModified: tutorial.modified, - datePublished: tutorial.created, -}); diff --git a/data/json-ld/tutorials.js b/data/json-ld/tutorials.js deleted file mode 100644 index 7050f45b2b..0000000000 --- a/data/json-ld/tutorials.js +++ /dev/null @@ -1,27 +0,0 @@ -import Tutorial from './tutorial'; - -export default (base, library, tutorials, keywords) => ({ - '@context': 'http://schema.org', - '@type': 'CreativeWorkSeries', - name: `${library} Tutorials`, - headline: `${library} Tutorials`, - description: `Tutorials for ${library} on cdnjs`, - keywords, - url: `${base}libraries/${library}/tutorials`, - inLanguage: 'en', - accessMode: 'textual', - accessModeSufficient: 'textual', - isAccessibleForFree: true, - isPartOf: `${base}libraries/${library}`, - hasPart: tutorials.map(d => Tutorial(base, d, d.id, library)), - publisher: { - '@type': 'Organization', - name: 'cdnjs', - url: base, - }, - sourceOrganization: { - '@type': 'Organization', - name: 'cdnjs', - url: base, - }, -}); diff --git a/pages/libraries/_library/index.vue b/pages/libraries/_library/index.vue index 38c9fc3a8b..c8f6d652d3 100644 --- a/pages/libraries/_library/index.vue +++ b/pages/libraries/_library/index.vue @@ -54,8 +54,6 @@ - - @@ -76,7 +74,6 @@ import Breadcrumbs from '../../../components/breadcrumbs'; import LibraryHero from '../../../components/library/library_hero'; import LibraryAssetButtons from '../../../components/library/library_asset_buttons'; - import TutorialList from '../../../components/tutorial/tutorial_list'; import JSONLDLibrary from '../../../components/json-ld/library'; const meta = { @@ -128,7 +125,6 @@ Breadcrumbs, LibraryHero, LibraryAssetButtons, - TutorialList, JSONLDLibrary, VueSelect, }, diff --git a/pages/libraries/_library/tutorials/_tutorial.vue b/pages/libraries/_library/tutorials/_tutorial.vue deleted file mode 100644 index c7de743747..0000000000 --- a/pages/libraries/_library/tutorials/_tutorial.vue +++ /dev/null @@ -1,150 +0,0 @@ - - - diff --git a/pages/libraries/_library/tutorials/index.vue b/pages/libraries/_library/tutorials/index.vue deleted file mode 100644 index e4086bba19..0000000000 --- a/pages/libraries/_library/tutorials/index.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - diff --git a/util/build/routes.js b/util/build/routes.js index fe63e98ad2..88fbb14fdc 100644 --- a/util/build/routes.js +++ b/util/build/routes.js @@ -8,20 +8,9 @@ export default async () => { const libsJson = await libsRaw.json(); const libsAsync = libsJson.results.map((lib) => { return [lib.name, async () => { - const libRaw = await fetch(`${baseApi}/libraries/${encodeURIComponent(lib.name)}?fields=tutorials,versions`); + const libRaw = await fetch(`${baseApi}/libraries/${encodeURIComponent(lib.name)}?fields=versions`); const libJson = await libRaw.json(); - if (!libJson.tutorials) { - console.warn(`No tutorials array for ${lib.name}`, libJson); - } - - const tutorials = (libJson.tutorials || []).map((tut) => { - return { - url: `/libraries/${encodeURIComponent(lib.name)}/tutorials/${encodeURIComponent(tut.id)}`, - priority: 0.5, - }; - }); - if (!libJson.versions) { console.warn(`No versions array for ${lib.name}`, libJson); } @@ -38,12 +27,7 @@ export default async () => { url: `/libraries/${encodeURIComponent(lib.name)}`, priority: 0.6, }, - ...tutorials, ...versions, - { - url: `/libraries/${encodeURIComponent(lib.name)}/tutorials`, - priority: 0.4, - }, ]; }]; }); diff --git a/util/build/sitemap.js b/util/build/sitemap.js index 0a2813e977..81bfd6c7a2 100644 --- a/util/build/sitemap.js +++ b/util/build/sitemap.js @@ -24,7 +24,7 @@ const getUrls = async () => { }, ]; - // Add in all the libraries, their versions & tutorials + // Add in all the libraries and their versions return urls.concat(await routes()); }; diff --git a/util/get_library.js b/util/get_library.js index 39fd9806f8..feef22fabe 100644 --- a/util/get_library.js +++ b/util/get_library.js @@ -7,7 +7,7 @@ const spdxLicenseIds = require('spdx-license-ids/index.json'); const index = searchClient.initIndex('libraries'); const apiFields = () => new Set([ - 'name', 'autoupdate', 'licenses', 'license', 'homepage', 'description', 'keywords', 'version', 'filename', 'versions', 'tutorials', + 'name', 'autoupdate', 'licenses', 'license', 'homepage', 'description', 'keywords', 'version', 'filename', 'versions', ]); const apiFieldsQuery = fields => `?fields=${Array.from(fields).map(f => encodeURIComponent(f)).join(',')}`; diff --git a/util/get_tutorial.js b/util/get_tutorial.js deleted file mode 100644 index 99c19a3c60..0000000000 --- a/util/get_tutorial.js +++ /dev/null @@ -1,25 +0,0 @@ -import fetch from 'node-fetch'; -import { baseApi } from '../data/config'; - -export const getTutorials = async (lib) => { - // Get data from cdnjs API - const res = await fetch(`${baseApi}/libraries/${encodeURIComponent(lib)}/tutorials`); - const apiData = await res.json(); - - // Done - return apiData; -}; - -export const getTutorial = async (lib, tut) => { - // Get data from cdnjs API - const res = await fetch(`${baseApi}/libraries/${encodeURIComponent(lib)}/tutorials/${encodeURIComponent(tut)}`); - const apiData = await res.json(); - - // Not found - if (Object.entries(apiData).length === 0 && apiData.constructor.name === Object.name) { - throw new Error('Tutorial not found'); - } - - // Done - return apiData; -};