parent
c95f8544e8
commit
e1fea28e08
|
|
@ -927,7 +927,14 @@ key: 产品密钥
|
|||
| -------- | -------- | ---------- | ---------- |
|
||||
| topic | news | technews | blockchain |
|
||||
|
||||
## Konachan.com Anime Wallpapers
|
||||
## Konachan Anime Wallpapers
|
||||
|
||||
::: tip 提示
|
||||
|
||||
* tags 可以在 [konachan](https://konachan.com/post) 选好后, 复制其 URL 中 tags= 后的参数
|
||||
* 路由可选 `/konachan` 或 `/konachan.com` 或 `/konachan.net`, 其中前两者相同, `.net` 是全年龄健康的壁纸 ♡
|
||||
|
||||
:::
|
||||
|
||||
### Posts
|
||||
|
||||
|
|
|
|||
|
|
@ -245,9 +245,17 @@ if (config.github && config.github.access_token) {
|
|||
|
||||
// konachan
|
||||
router.get('/konachan/post', require('./routes/konachan/post'));
|
||||
router.get('/konachan.com/post', require('./routes/konachan/post'));
|
||||
router.get('/konachan.net/post', require('./routes/konachan/post'));
|
||||
router.get('/konachan/post/popular_recent', require('./routes/konachan/post_popular_recent'));
|
||||
router.get('/konachan.com/post/popular_recent', require('./routes/konachan/post_popular_recent'));
|
||||
router.get('/konachan.net/post/popular_recent', require('./routes/konachan/post_popular_recent'));
|
||||
router.get('/konachan/post/:tags', require('./routes/konachan/post'));
|
||||
router.get('/konachan.com/post/:tags', require('./routes/konachan/post'));
|
||||
router.get('/konachan.net/post/:tags', require('./routes/konachan/post'));
|
||||
router.get('/konachan/post/popular_recent/:period', require('./routes/konachan/post_popular_recent'));
|
||||
router.get('/konachan.com/post/popular_recent/:period', require('./routes/konachan/post_popular_recent'));
|
||||
router.get('/konachan.net/post/popular_recent/:period', require('./routes/konachan/post_popular_recent'));
|
||||
|
||||
// yande.re
|
||||
router.get('/yande.re/post', require('./routes/yande.re/post'));
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ const config = require('../../config');
|
|||
module.exports = async (ctx) => {
|
||||
const { tags = '' } = ctx.params;
|
||||
|
||||
const baseURL = ctx.path.startsWith('/konachan.net') ? 'https://konachan.net' : 'https://konachan.com';
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://konachan.com/post.json?tags=${tags}`,
|
||||
baseURL,
|
||||
url: `/post.json?tags=${tags}`,
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
|
|
@ -14,22 +17,25 @@ module.exports = async (ctx) => {
|
|||
|
||||
const posts = response.data;
|
||||
|
||||
let title = 'Konachan.com Anime Wallpapers';
|
||||
let title = 'Konachan Anime Wallpapers';
|
||||
if (tags) {
|
||||
title = decodeURIComponent(tags) + ' - ' + title;
|
||||
}
|
||||
|
||||
ctx.state.data = {
|
||||
title,
|
||||
link: 'https://konachan.com/post',
|
||||
link: `${baseURL}/post`,
|
||||
item: posts.map((post) => {
|
||||
const content = (url) => {
|
||||
let result = `<img src="${url}" />`;
|
||||
if (url.startsWith('//')) {
|
||||
url = 'https:' + url;
|
||||
}
|
||||
let result = `<img referrerpolicy="no-referrer" src="${url}" />`;
|
||||
if (post.source) {
|
||||
result += `<a href="${post.source}">source</a>`;
|
||||
}
|
||||
if (post.parent_id) {
|
||||
result += `<a href="https://konachan.com/post/show/${post.parent_id}">parent</a>`;
|
||||
result += `<a href="${baseURL}/post/show/${post.parent_id}">parent</a>`;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
@ -40,7 +46,7 @@ module.exports = async (ctx) => {
|
|||
title: post.tags,
|
||||
id: `${ctx.path}#${post.id}`,
|
||||
guid: `${ctx.path}#${post.id}`,
|
||||
link: `https://konachan.com/post/show/${post.id}`,
|
||||
link: `${baseURL}/post/show/${post.id}`,
|
||||
author: post.author,
|
||||
published: new Date(created_at).toISOString(),
|
||||
pubDate: new Date(created_at).toUTCString(),
|
||||
|
|
|
|||
|
|
@ -4,9 +4,12 @@ const config = require('../../config');
|
|||
module.exports = async (ctx) => {
|
||||
const { period = '1d' } = ctx.params;
|
||||
|
||||
const baseURL = ctx.path.startsWith('/konachan.net') ? 'https://konachan.net' : 'https://konachan.com';
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: 'https://konachan.com/post/popular_recent.json',
|
||||
baseURL,
|
||||
url: '/post/popular_recent.json',
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
},
|
||||
|
|
@ -27,16 +30,19 @@ module.exports = async (ctx) => {
|
|||
const title = titles[period] || titles['1d'];
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title} - Konachan.com Anime Wallpapers`,
|
||||
link: 'https://konachan.com/post/popular_recent',
|
||||
title: `${title} - Konachan Anime Wallpapers`,
|
||||
link: `${baseURL}/post/popular_recent`,
|
||||
item: posts.map((post) => {
|
||||
const content = (url) => {
|
||||
let result = `<img src="${url}" />`;
|
||||
if (url.startsWith('//')) {
|
||||
url = 'https:' + url;
|
||||
}
|
||||
let result = `<img referrerpolicy="no-referrer" src="${url}" />`;
|
||||
if (post.source) {
|
||||
result += `<a href="${post.source}">source</a>`;
|
||||
}
|
||||
if (post.parent_id) {
|
||||
result += `<a href="https://konachan.com/post/show/${post.parent_id}">parent</a>`;
|
||||
result += `<a href="${baseURL}/post/show/${post.parent_id}">parent</a>`;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
|
@ -47,7 +53,7 @@ module.exports = async (ctx) => {
|
|||
title: post.tags,
|
||||
id: `${ctx.path}#${post.id}`,
|
||||
guid: `${ctx.path}#${post.id}`,
|
||||
link: `https://konachan.com/post/show/${post.id}`,
|
||||
link: `${baseURL}/post/show/${post.id}`,
|
||||
author: post.author,
|
||||
published: new Date(created_at).toISOString(),
|
||||
pubDate: new Date(created_at).toUTCString(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue