feat(route): add Android SDK Platform Tools release notes (#10264)

* feat(route): add Android SDK Platform Tools release notes

* fix typo

* fix links
This commit is contained in:
Ethan Shen
2022-07-21 18:01:51 +08:00
committed by GitHub
parent 9703916bce
commit cb11a6c8a7
6 changed files with 78 additions and 0 deletions

View File

@@ -4,6 +4,12 @@ pageClass: routes
# Application Updates
## Android
### SDK Platform Tools release notes
<RouteEn author="nczitzk" example="/android/platform-tools-releases" path="/android/platform-tools-releases"/>
## Anki
### Changes

View File

@@ -14,6 +14,12 @@ pageClass: routes
</Route>
## Android
### SDK Platform Tools release notes
<Route author="nczitzk" example="/android/platform-tools-releases" path="/android/platform-tools-releases"/>
## Anki
### Changes

View File

@@ -0,0 +1,3 @@
module.exports = {
'/platform-tools-releases': ['nczitzk'],
};

View File

@@ -0,0 +1,47 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const rootUrl = 'https://developer.android.com';
const currentUrl = `${rootUrl}/studio/releases/platform-tools`;
const response = await got({
method: 'get',
url: currentUrl,
headers: {
cookie: 'signin=autosignin',
},
});
const $ = cheerio.load(response.data);
$('.hide-from-toc').remove();
$('.devsite-dialog, .devsite-badge-awarder, .devsite-hats-survey').remove();
const items = $('h4')
.toArray()
.map((item) => {
item = $(item);
const title = item.attr('data-text');
let description = '';
item.nextUntil('h4').each(function () {
description += $(this).html();
});
return {
title,
description,
link: `${currentUrl}#${item.attr('id')}`,
pubDate: parseDate(title.match(/\((.*)\)/)[1], 'MMMM YYYY'),
};
});
ctx.state.data = {
title: $('title').text(),
link: currentUrl,
item: items,
};
};

13
lib/v2/android/radar.js Normal file
View File

@@ -0,0 +1,13 @@
module.exports = {
'android.com': {
_name: 'Android Developers',
developer: [
{
title: 'SDK Platform Tools release notes',
docs: 'https://docs.rsshub.app/program-update.html#android-sdk-platform-tools-release-notes',
source: ['/studio/releases/platform-tools', '/'],
target: '/android/platform-tools-releases',
},
],
},
};

3
lib/v2/android/router.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/platform-tools-releases', require('./platform-tools-releases'));
};