Skip to content

Commit

Permalink
add services and bookmarks as manifest shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
benphelps committed Oct 9, 2022
1 parent d26ae30 commit d2dc51d
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/pages/site.webmanifest.jsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
import checkAndCopyConfig, { getSettings } from "utils/config/config";
import themes from "utils/styles/themes";
import { servicesResponse, bookmarksResponse } from "utils/config/api-response";

export async function getServerSideProps({ res }) {
checkAndCopyConfig("settings.yaml");
const settings = getSettings();
const services = await servicesResponse();
const bookmarks = await bookmarksResponse();

const color = settings.color || "slate";
const theme = settings.theme || "dark";

const serviceShortcuts = services.map((group) =>
group.services.map((service) => ({
name: service.name,
url: service.href,
description: service.description,
}))
);

const bookmarkShortcuts = bookmarks.map((group) =>
group.bookmarks.map((service) => ({
name: service.name,
url: service.href,
}))
);

const shortcuts = [...serviceShortcuts, ...bookmarkShortcuts].flat();

const manifest = {
name: "Homepage",
short_name: "Homepage",
name: settings.title || "Homepage",
short_name: settings.title || "Homepage",
icons: [
{
src: "/android-chrome-192x192.png?v=2",
Expand All @@ -23,6 +43,7 @@ export async function getServerSideProps({ res }) {
type: "image/png",
},
],
shortcuts,
theme_color: themes[color][theme],
background_color: themes[color][theme],
display: "standalone",
Expand Down

0 comments on commit d2dc51d

Please sign in to comment.