Skip to content

Commit

Permalink
Merge pull request #19 from kbdharun/main
Browse files Browse the repository at this point in the history
feat: add FreeBSD and NetBSD platforms
  • Loading branch information
rwv authored Oct 29, 2023
2 parents 221f192 + 4851543 commit 11ff0e6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 33 deletions.
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

0 comments on commit 11ff0e6

Please sign in to comment.