-
Notifications
You must be signed in to change notification settings - Fork 9.6k
feat(route): Add Archdaily Search Support #21511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FridayAnubis
wants to merge
9
commits into
DIYgod:master
Choose a base branch
from
FridayAnubis:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a686fc5
feat: add ArchDaily route
FridayAnubis dbce373
Merge branch 'master' of https://github.com/FridayAnubis/RSSHub
FridayAnubis 976c6c8
Merge branch 'master' into master
TonyRL 63bfdf6
fixed: all category redirected to "all"
FridayAnubis 41656ee
Merge branch 'master' of https://github.com/FridayAnubis/RSSHub
FridayAnubis dbd5515
remove deprecated category interface
FridayAnubis 8ba793a
fix: radar source
FridayAnubis 31231d0
fix(route): update outdated API entry(image) and fix empty-content pa…
FridayAnubis 02f633a
fix: improve safety
FridayAnubis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import type { Namespace } from '@/types'; | ||
|
|
||
| export const namespace: Namespace = { | ||
| name: 'ArchDaily', | ||
| url: 'archdaily.com', | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import type { Route } from '@/types'; | ||
| import ofetch from '@/utils/ofetch'; | ||
| import { parseDate } from '@/utils/parse-date'; | ||
|
|
||
| export const route: Route = { | ||
| path: '/search/:category?/:search', | ||
| categories: ['journal'], | ||
| example: '/archdaily/search/projects/Urban Design', | ||
| parameters: { category: 'The category to search in, including "all", "projects", "products", "images", "professionals", "article-archive", "folders", "articles"', search: 'The search query' }, | ||
| features: { | ||
| requireConfig: false, | ||
| }, | ||
| radar: [ | ||
| { | ||
| source: ['www.archdaily.com/search/:category?q=:search'], | ||
| target: '/search/:category/:search', | ||
| }, | ||
| ], | ||
| name: 'Search', | ||
| maintainers: ['Friday_Anubis'], | ||
| handler, | ||
| }; | ||
|
|
||
| async function handler(ctx) { | ||
| const { category = 'all', search } = ctx.req.param(); | ||
|
|
||
| const baseUrl = 'https://www.archdaily.com'; | ||
| const allowedCategories = new Set(['all', 'projects', 'products', 'images', 'professionals', 'article-archive', 'folders', 'articles']); | ||
| const finalCategory = allowedCategories.has(category) ? category : 'all'; | ||
|
|
||
| const response = await ofetch<{ results?: any[] }>(`${baseUrl}/search/api/v1/us/${finalCategory}?q=${encodeURIComponent(search)}`); | ||
|
|
||
| const items = (response?.results ?? []).map((item) => { | ||
| const title = item?.title || item?.name; | ||
| const link = item?.url; | ||
| const image = item?.featured_images?.url_large || item?.featured_images?.url_medium || item?.featured_images?.url_small; | ||
| const category = (item?.tags ?? []).map((tag) => tag?.name).filter(Boolean); | ||
|
|
||
| return { | ||
| title, | ||
| link, | ||
| description: `${image ? `<img src="${image}"><br>` : ''}${item?.meta_description ?? ''}`, | ||
| pubDate: item?.publication_date ? parseDate(item.publication_date) : undefined, | ||
| author: item?.author?.name, | ||
| category, | ||
| }; | ||
| }); | ||
|
|
||
| return { | ||
| title: `ArchDaily - ${search}${finalCategory === 'all' ? '' : ` in ${finalCategory}`}`, | ||
| link: `${baseUrl}/search/${finalCategory}?q=${encodeURIComponent(search)}`, | ||
| description: `Search results for "${search}" on ArchDaily`, | ||
| item: items, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the examples tested have
allasfinalCategoryhttps://github.com/DIYgod/RSSHub/actions/runs/23597214345/job/68717079718#step:14:20