mirror of
https://github.com/uetchy/namae.git
synced 2025-03-17 12:30:32 +09:00
feat: add archlinux
This commit is contained in:
parent
dc62baf8be
commit
63bd18b38d
28
api/services/archlinux/[query].ts
Normal file
28
api/services/archlinux/[query].ts
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { send, sendError, fetch } from '../../../util/http';
|
||||||
|
import { NowRequest, NowResponse } from '@vercel/node';
|
||||||
|
|
||||||
|
export default async function handler(
|
||||||
|
req: NowRequest,
|
||||||
|
res: NowResponse
|
||||||
|
): Promise<void> {
|
||||||
|
const { query } = req.query;
|
||||||
|
|
||||||
|
if (!query || typeof query !== 'string') {
|
||||||
|
return sendError(res, new Error('No query given'));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/[^a-zA-Z0-9_-]/.test(query)) {
|
||||||
|
return sendError(res, new Error('Invalid characters'));
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(
|
||||||
|
`https://archlinux.org/packages/?sort=&q=${encodeURIComponent(query)}`,
|
||||||
|
'GET'
|
||||||
|
).then((res) => res.text());
|
||||||
|
const availability = !/<div id="exact-matches"/.test(response);
|
||||||
|
send(res, { availability });
|
||||||
|
} catch (err) {
|
||||||
|
sendError(res, err);
|
||||||
|
}
|
||||||
|
}
|
@ -15,6 +15,9 @@
|
|||||||
"pressEnterToSearch": "Press Enter to search",
|
"pressEnterToSearch": "Press Enter to search",
|
||||||
"providers": {
|
"providers": {
|
||||||
"appStore": "App Store",
|
"appStore": "App Store",
|
||||||
|
"archlinux": "Arch Linux",
|
||||||
|
"ubuntu": "Ubuntu",
|
||||||
|
"debian": "Debian",
|
||||||
"domains": "Domains",
|
"domains": "Domains",
|
||||||
"firebase": "Firebase",
|
"firebase": "Firebase",
|
||||||
"github": "GitHub Organization",
|
"github": "GitHub Organization",
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
FaGitlab,
|
FaGitlab,
|
||||||
// FaInstagram,
|
// FaInstagram,
|
||||||
FaJsSquare,
|
FaJsSquare,
|
||||||
FaLinux,
|
|
||||||
FaPython,
|
FaPython,
|
||||||
FaSlack,
|
FaSlack,
|
||||||
FaTwitter,
|
FaTwitter,
|
||||||
@ -16,7 +15,15 @@ import {
|
|||||||
import { IoIosBeer, IoMdAppstore } from 'react-icons/io';
|
import { IoIosBeer, IoMdAppstore } from 'react-icons/io';
|
||||||
import { MdDomain } from 'react-icons/md';
|
import { MdDomain } from 'react-icons/md';
|
||||||
import { RiBuilding2Fill, RiNpmjsFill } from 'react-icons/ri';
|
import { RiBuilding2Fill, RiNpmjsFill } from 'react-icons/ri';
|
||||||
import { SiAppstore, SiFirebase, SiRubygems, SiRust } from 'react-icons/si';
|
import {
|
||||||
|
SiAppstore,
|
||||||
|
SiArchlinux,
|
||||||
|
SiDebian,
|
||||||
|
SiFirebase,
|
||||||
|
SiRubygems,
|
||||||
|
SiRust,
|
||||||
|
SiUbuntu,
|
||||||
|
} from 'react-icons/si';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { sendGettingStartedEvent } from '../util/analytics';
|
import { sendGettingStartedEvent } from '../util/analytics';
|
||||||
@ -27,17 +34,19 @@ const supportedProviders: Record<string, React.ReactNode> = {
|
|||||||
domains: <MdDomain />,
|
domains: <MdDomain />,
|
||||||
github: <FaGithub />,
|
github: <FaGithub />,
|
||||||
gitlab: <FaGitlab />,
|
gitlab: <FaGitlab />,
|
||||||
|
twitter: <FaTwitter />,
|
||||||
|
homebrew: <IoIosBeer />,
|
||||||
npm: <RiNpmjsFill />,
|
npm: <RiNpmjsFill />,
|
||||||
rust: <SiRust />,
|
rust: <SiRust />,
|
||||||
pypi: <FaPython />,
|
pypi: <FaPython />,
|
||||||
rubygems: <SiRubygems />,
|
rubygems: <SiRubygems />,
|
||||||
ocaml: <OcamlIcon />,
|
ocaml: <OcamlIcon />,
|
||||||
homebrew: <IoIosBeer />,
|
archlinux: <SiArchlinux />,
|
||||||
linux: <FaLinux />,
|
ubuntu: <SiUbuntu />,
|
||||||
twitter: <FaTwitter />,
|
debian: <SiDebian />,
|
||||||
// instagram: <FaInstagram />,
|
// instagram: <FaInstagram />,
|
||||||
spectrum: <SpectrumIcon />,
|
|
||||||
slack: <FaSlack />,
|
slack: <FaSlack />,
|
||||||
|
spectrum: <SpectrumIcon />,
|
||||||
heroku: <DiHeroku />,
|
heroku: <DiHeroku />,
|
||||||
now: <NowIcon />,
|
now: <NowIcon />,
|
||||||
netlify: <NetlifyIcon />,
|
netlify: <NetlifyIcon />,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { SiDebian, SiUbuntu } from 'react-icons/si';
|
import { SiDebian, SiUbuntu, SiArchlinux } from 'react-icons/si';
|
||||||
import { normalize } from '../../../util/text';
|
import { normalize } from '../../../util/text';
|
||||||
import { Card, DedicatedAvailability, Repeater } from '../core';
|
import { Card, DedicatedAvailability, Repeater } from '../core';
|
||||||
|
|
||||||
@ -16,6 +16,13 @@ const LinuxCard: React.FC<{ query: string }> = ({ query }) => {
|
|||||||
<Repeater items={names}>
|
<Repeater items={names}>
|
||||||
{(name) => (
|
{(name) => (
|
||||||
<>
|
<>
|
||||||
|
<DedicatedAvailability
|
||||||
|
name={name}
|
||||||
|
service="archlinux"
|
||||||
|
message="Go to ArchLinux.org"
|
||||||
|
link={`https://archlinux.org/packages/?sort=&q=${name}`}
|
||||||
|
icon={<SiArchlinux />}
|
||||||
|
/>
|
||||||
<DedicatedAvailability
|
<DedicatedAvailability
|
||||||
name={name}
|
name={name}
|
||||||
service="launchpad"
|
service="launchpad"
|
||||||
|
@ -15,11 +15,11 @@ const TwitterCard: React.FC<{ query: string }> = ({ query }) => {
|
|||||||
const names = [
|
const names = [
|
||||||
normalizedQuery,
|
normalizedQuery,
|
||||||
`${capitalCase}App`,
|
`${capitalCase}App`,
|
||||||
`${capitalCase}Team`,
|
`${lowerCase}_team`,
|
||||||
`${lowerCase}hq`,
|
`${capitalCase}HQ`,
|
||||||
|
`hey${lowerCase}`,
|
||||||
];
|
];
|
||||||
const moreNames = [
|
const moreNames = [
|
||||||
`hey${lowerCase}`,
|
|
||||||
`${lowerCase}_support`,
|
`${lowerCase}_support`,
|
||||||
`${lowerCase}_org`,
|
`${lowerCase}_org`,
|
||||||
`${lowerCase}_app`,
|
`${lowerCase}_app`,
|
||||||
|
@ -5,7 +5,7 @@ import XHR from 'i18next-xhr-backend';
|
|||||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||||
import { initReactI18next } from 'react-i18next';
|
import { initReactI18next } from 'react-i18next';
|
||||||
|
|
||||||
const TRANSLATION_VERSION = '4';
|
const TRANSLATION_VERSION = '5';
|
||||||
|
|
||||||
i18n
|
i18n
|
||||||
.use(Backend)
|
.use(Backend)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user