Skip to content

Commit

Permalink
Add user config type (#626)
Browse files Browse the repository at this point in the history
* Add user config type

* Fix TSC error after merge

---------

Co-authored-by: mohamed yahia <[email protected]>
  • Loading branch information
homostellaris and mohamedsalem401 authored Feb 26, 2024
1 parent 6a1e55f commit 9d3da90
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ node_modules/
out/
.obsidian/
.markdowndb/
tsconfig.tsbuildinfo
.vscode/
.idea/
.idea/
31 changes: 28 additions & 3 deletions config/siteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { defaultConfig } from "@portaljs/core";
import userConfig from "@/content/config.mjs";
import {
AnalyticsConfig,
AuthorConfig,
CommentsConfig,
NavConfig,
defaultConfig,
} from "@portaljs/core";
import { DefaultSeoProps } from "next-seo";

// TODO types
const siteConfig: any = {
const siteConfig: SiteConfig = {
...defaultConfig,
...userConfig,
// prevent theme object overrides for
Expand All @@ -14,3 +20,22 @@ const siteConfig: any = {
};

export default siteConfig;

export type UserConfig = {
analyticsConfig?: AnalyticsConfig;
comments?: CommentsConfig;
defaultAuthor: string;
editLinkRoot?: string;
logo?: AuthorConfig["logo"];
navbarTitle?: {
text?: NavConfig["title"];
logo?: NavConfig["logo"];
};
nextSeo?: Partial<DefaultSeoProps>;
preProcess: (source: any) => any;
showComments?: boolean;
search?: NavConfig["search"];
social?: NavConfig["social"];
} & Partial<typeof defaultConfig>;

export type SiteConfig = typeof defaultConfig & typeof userConfig;
4 changes: 4 additions & 0 deletions content/config.mjs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@

/**
* @type {import("../config/siteConfig").UserConfig}
*/
export default {};
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const MyApp = ({ Component, pageProps }: AppProps<CustomAppProps>) => {
logo: siteConfig.logo,
},
theme: {
defaultTheme: siteConfig.theme.default,
defaultTheme: siteConfig.theme.default as "light" | "dark",
themeToggleIcon: siteConfig.theme.toggleIcon,
},
siteMap,
Expand Down
48 changes: 48 additions & 0 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://homostellaris.io/dev/columns-vs-flex-vs-grid</loc>
</url>

<url>
<loc>https://homostellaris.io/marketing/seo</loc>
</url>

<url>
<loc
>https://homostellaris.io/productivity/effective-macos-task-management</loc
>
</url>

<url>
<loc>https://homostellaris.io/about</loc>
</url>

<url>
<loc>https://homostellaris.io/blog/blog-post-fail</loc>
</url>

<url>
<loc>https://homostellaris.io/productivity/productivity-system</loc>
</url>

<url>
<loc>https://homostellaris.io/tech/roll-your-own-personal-backups</loc>
</url>

<url>
<loc>https://homostellaris.io/blog/schedule-your-social-marketing</loc>
</url>

<url>
<loc>https://homostellaris.io//</loc>
</url>

<url>
<loc>https://homostellaris.io/dev/how-to-test-web-apps</loc>
</url>

<url>
<loc>https://homostellaris.io/dev/instance-type</loc>
</url>
</urlset>

0 comments on commit 9d3da90

Please sign in to comment.