Skip to content

Commit

Permalink
Formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
xbubbo committed Nov 26, 2024
1 parent 035e505 commit c8f6a02
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 26 deletions.
4 changes: 2 additions & 2 deletions astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from "node:child_process";
import path from "node:path";
import node from "@astrojs/node";
import tailwind from "@astrojs/tailwind";
import { baremuxPath } from "@mercuryworkshop/bare-mux/node";
Expand All @@ -9,7 +10,6 @@ import { server as wisp } from "@mercuryworkshop/wisp-js/server";
import { uvPath } from "@titaniumnetwork-dev/ultraviolet";
import { defineConfig } from "astro/config";
import { viteStaticCopy } from "vite-plugin-static-copy";
import path from "path";

// https://astro.build/config
export default defineConfig({
Expand Down Expand Up @@ -39,7 +39,7 @@ export default defineConfig({
},
resolve: {
alias: {
"@": path.resolve("./src"),
"@": path.resolve("./src"),
},
},
plugins: [
Expand Down
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config: Config = {
// Server Configuration
server: {
port: 8080, // The port on which Interstellar runs (Default: 8080)
assets: "local", // Source for app/game images and JSON. Use 'external' if you don't want to use local assets
assets: "local", // Source for app/game images and JSON. Use 'external' if you don't want to use local assets
},

// Authentication Configuration (Optional)
Expand Down
5 changes: 4 additions & 1 deletion randomize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ export function UpdateImports() {

OriginalPatterns.forEach((pattern, index) => {
content = content.replace(
new RegExp(`['"]${pattern.replace(/\\/g, "\\\\").replace(/\./g, "\\.")}['"]`, "g"),
new RegExp(
`['"]${pattern.replace(/\\/g, "\\\\").replace(/\./g, "\\.")}['"]`,
"g",
),
`'${NewPatterns[index]}'`,
);
});
Expand Down
9 changes: 5 additions & 4 deletions src/lib/assets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Cookies from "js-cookie";
import INConfig from "config.ts";
import Cookies from "js-cookie";

export const ASSET_URL = INConfig.server && INConfig.server.assets === "external"
? "https://raw.githubusercontent.com/UseInterstellar/Interstellar-Assets/main"
: "/assets";
export const ASSET_URL =
INConfig.server && INConfig.server.assets === "external"
? "https://raw.githubusercontent.com/UseInterstellar/Interstellar-Assets/main"
: "/assets";

export type Asset = {
name: string;
Expand Down
6 changes: 4 additions & 2 deletions src/lib/global.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import DOMPurify from 'dompurify';
import DOMPurify from "dompurify";

document.addEventListener("astro:page-load", () => {
// Cloak
document.title = localStorage.getItem("title") ?? "Home";
const icon = DOMPurify.sanitize(localStorage.getItem("icon") ?? "/assets/media/favicons/default.png");
const icon = DOMPurify.sanitize(
localStorage.getItem("icon") ?? "/assets/media/favicons/default.png",
);
const iconElm = document.getElementById("icon");
if (iconElm) (iconElm as HTMLLinkElement).href = icon;

Expand Down
7 changes: 4 additions & 3 deletions src/lib/home.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
let searchUrl = localStorage.getItem("engine") || "https://www.google.com/search?q=";
let input = document.getElementById("search") as HTMLInputElement | null;
const searchUrl =
localStorage.getItem("engine") || "https://www.google.com/search?q=";
const input = document.getElementById("search") as HTMLInputElement | null;

function isUrl(val: string = ""): boolean {
function isUrl(val = ""): boolean {
return /^http(s?):\/\//.test(val) || (val.includes(".") && !val.includes(" "));
}

Expand Down
14 changes: 7 additions & 7 deletions src/pages/apps.astro
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
import fs from "node:fs";
import path from "node:path";
import AssetCard from "@/components/AssetCard.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/assets.ts";
import { PlusCircle } from "lucide-astro";
import fs from 'fs';
import path from 'path';
export const prerender = false;
const local = path.resolve('./public/assets/json/apps.min.json');
const local = path.resolve("./public/assets/json/apps.min.json");
const external = `${ASSET_URL}/json/apps.min.json`;
let apps: Asset[]
let apps: Asset[];
if (ASSET_URL === "/assets") {
try {
const data = fs.readFileSync(local, 'utf-8');
apps = JSON.parse(data);
const data = fs.readFileSync(local, "utf-8");
apps = JSON.parse(data);
} catch (error) {
apps = [];
apps = [];
}
} else {
const response = await fetch(external);
Expand Down
12 changes: 6 additions & 6 deletions src/pages/games.astro
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
---
import fs from "node:fs";
import path from "node:path";
import AssetCard from "@/components/AssetCard.astro";
import Layout from "@/layouts/Main.astro";
import { ASSET_URL, type Asset } from "@/lib/assets.ts";
import { PlusCircle } from "lucide-astro";
import fs from 'fs';
import path from 'path';
export const prerender = false;
const local = path.resolve('./public/assets/json/games.min.json');
const local = path.resolve("./public/assets/json/games.min.json");
const external = `${ASSET_URL}/json/games.min.json`;
let games: Asset[];
if (ASSET_URL === "/assets") {
try {
const data = fs.readFileSync(local, 'utf-8');
games = JSON.parse(data);
const data = fs.readFileSync(local, "utf-8");
games = JSON.parse(data);
} catch (error) {
games = [];
games = [];
}
} else {
const response = await fetch(external);
Expand Down

0 comments on commit c8f6a02

Please sign in to comment.