Skip to content
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

feat: add FreeBSD and NetBSD platforms #19

Merged
merged 2 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/misc/BrowsePlatforms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import PlatformIcon from "./PlatformIcon.vue";
import { useRouter } from "vue-router";

const router = useRouter();
const platforms = ["common", "linux", "openbsd", "osx", "windows", "android", "sunos"];
const platforms = ["android", "common", "freebsd", "linux", "netbsd", "openbsd", "osx", "sunos", "windows"];

const options = platforms.map((platform) => ({
label: getPlatformDisplay(platform),
Expand Down
76 changes: 46 additions & 30 deletions src/components/search/composables/getDefaultPlatforms.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
type Platform = "common" | "openbsd" | "osx" | "linux" | "windows" | "android" | "sunos";
type Platform = "android" | "common" | "freebsd" | "linux" | "netbsd" | "openbsd" | "osx" | "windows" | "sunos";

export function getDefaultPlatforms(): Platform[] {
const platforms: Platform[] = ["common"];
const navigatorPlatform = navigator?.platform?.toLowerCase();

if (navigatorPlatform) {
if (navigatorPlatform.includes("win")) {
platforms.push("windows");
return platforms;
}
if (navigatorPlatform.includes("android")) {
platforms.push("android");
}

if (navigatorPlatform.includes("openbsd")){
platforms.push("openbsd");
return platforms;
}
if (navigatorPlatform.includes("freebsd")){
platforms.push("freebsd");
}

if (navigatorPlatform.includes("mac")) {
platforms.push("osx");
return platforms;
}
if (navigatorPlatform.includes("linux")) {
platforms.push("linux");
}

if (navigatorPlatform.includes("linux")) {
platforms.push("linux");
}
if (navigatorPlatform.includes("mac")) {
platforms.push("osx");
return platforms;
}

if (navigatorPlatform.includes("android")) {
platforms.push("android");
}
if (navigatorPlatform.includes("netbsd")){
platforms.push("netbsd");
}

if (navigatorPlatform.includes("sunos")) {
platforms.push("sunos");
if (navigatorPlatform.includes("openbsd")){
platforms.push("openbsd");
return platforms;
}

if (navigatorPlatform.includes("sunos")) {
platforms.push("sunos");
}

if (navigatorPlatform) {
if (navigatorPlatform.includes("win")) {
platforms.push("windows");
return platforms;
}
}

Expand All @@ -38,29 +46,37 @@ export function getDefaultPlatforms(): Platform[] {
)?.userAgentData?.platform?.toLowerCase();

if (uaPlatform) {
if (uaPlatform.includes("win")) {
platforms.push("windows");
if (uaPlatform.includes("android")) {
platforms.push("android");
}

if (uaPlatform.includes("openbsd")){
platforms.push("openbsd");
if (uaPlatform.includes("freebsd")) {
platforms.push("freebsd");
}

if (uaPlatform.includes("linux")) {
platforms.push("linux");
}

if (uaPlatform.includes("mac")) {
platforms.push("osx");
}

if (uaPlatform.includes("linux")) {
platforms.push("linux");
if (uaPlatform.includes("netbsd")){
platforms.push("netbsd");
}

if (uaPlatform.includes("android")) {
platforms.push("android");
if (uaPlatform.includes("openbsd")){
platforms.push("openbsd");
}

if (uaPlatform.includes("sunos")) {
platforms.push("sunos");
}

if (uaPlatform.includes("win")) {
platforms.push("windows");
}
}

return [...new Set(platforms)];
Expand Down
6 changes: 4 additions & 2 deletions src/data/tldr-pages/display/platform.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const displayMap = {
android: "Android",
common: "Common",
freebsd: "FreeBSD",
linux: "Linux",
netbsd: "NetBSD",
openbsd: "OpenBSD",
osx: "macOS",
windows: "Windows",
android: "Android",
sunos: "SunOS",
windows: "Windows",
} as Record<string, string>;

export function getPlatformDisplay(platform: string) {
Expand Down