You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have an mdx page that is trying to render differing content based on whether the user is running Windows or Mac. However,determining platform via navigator seems to always return null, and thus present the I'm not sure what platform you're running text when viewing the html. Sample code below:
What version of
astro
are you using?2.9.4
Are you using an SSR adapter? If so, which one?
N/A
What package manager are you using?
NPM
What operating system are you using?
Windows 11
What browser are you using?
Firefox
Describe the Bug
I have an mdx page that is trying to render differing content based on whether the user is running Windows or Mac. However,determining platform via navigator seems to always return null, and thus present the I'm not sure what platform you're running text when viewing the html. Sample code below:
layout: ../../layouts/toc.astro
title: "document title"
author: "Insert author here"
date: "13 Jul 2023"
{() => {
const getOperatingSystem = (() => {
if (typeof window === "undefined") {
//If the code is not running in the browser (e.g., server-side), return null - we don't want errors
return null;
}
if (window.navigator.platform.indexOf("Win") != -1) {
return "Windows";
} else if (window.navigator.platform.indexOf("Mac") != -1) {
return "Mac";
} else {
return "Unknown";
}
})();
Your system should meet or exceed the following minimum requirements
if (getOperatingSystem === "Windows") { return ( <>Windows Requirements:
); }else if (getOperatingSystem=== "Mac") {
return (
<>
Mac Requirements:
</>
);
}
return ("you are currently running " + getOperatingSystem);
What's the expected result?
The Windows content would display on my Firefox browser running on Windows 11
Link to Minimal Reproducible Example
No link, code in bug description
Participation
The text was updated successfully, but these errors were encountered: