mirror of
https://github.com/waynesutton/markdown-site.git
synced 2026-01-12 04:09:14 +00:00
Update: added stats page public or private option in siteconfig
This commit is contained in:
@@ -61,7 +61,10 @@ function App() {
|
||||
element={<Home />}
|
||||
/>
|
||||
)}
|
||||
<Route path="/stats" element={<Stats />} />
|
||||
{/* Stats page route - only enabled when statsPage.enabled is true */}
|
||||
{siteConfig.statsPage?.enabled && (
|
||||
<Route path="/stats" element={<Stats />} />
|
||||
)}
|
||||
{/* Unsubscribe route for newsletter */}
|
||||
<Route path="/unsubscribe" element={<Unsubscribe />} />
|
||||
{/* Blog page route - only enabled when blogPage.enabled is true */}
|
||||
|
||||
@@ -104,6 +104,10 @@ export default function Layout({ children }: LayoutProps) {
|
||||
// Add hardcoded nav items (React routes like /stats, /write)
|
||||
if (siteConfig.hardcodedNavItems && siteConfig.hardcodedNavItems.length > 0) {
|
||||
siteConfig.hardcodedNavItems.forEach((item) => {
|
||||
// Skip stats nav item if stats page is disabled
|
||||
if (item.slug === "stats" && !siteConfig.statsPage?.enabled) {
|
||||
return;
|
||||
}
|
||||
// Only add if showInNav is true (defaults to true)
|
||||
if (item.showInNav !== false) {
|
||||
navItems.push({
|
||||
|
||||
@@ -154,6 +154,13 @@ export interface NewsletterAdminConfig {
|
||||
showInNav: boolean; // Show link in navigation (hidden by default for security)
|
||||
}
|
||||
|
||||
// Stats page configuration
|
||||
// Controls access to the /stats route for viewing site analytics
|
||||
export interface StatsPageConfig {
|
||||
enabled: boolean; // Global toggle for stats page
|
||||
showInNav: boolean; // Show link in navigation (controlled via hardcodedNavItems)
|
||||
}
|
||||
|
||||
// Newsletter notifications configuration
|
||||
// Sends developer notifications for subscriber events
|
||||
// Uses AGENTMAIL_CONTACT_EMAIL or AGENTMAIL_INBOX as recipient
|
||||
@@ -284,6 +291,9 @@ export interface SiteConfig {
|
||||
// Newsletter admin configuration (optional)
|
||||
newsletterAdmin?: NewsletterAdminConfig;
|
||||
|
||||
// Stats page configuration (optional)
|
||||
statsPage?: StatsPageConfig;
|
||||
|
||||
// Newsletter notifications configuration (optional)
|
||||
newsletterNotifications?: NewsletterNotificationsConfig;
|
||||
|
||||
@@ -558,6 +568,14 @@ Created by [Wayne](https://x.com/waynesutton) with Convex, Cursor, and Claude Op
|
||||
showInNav: false, // Hide from navigation for security
|
||||
},
|
||||
|
||||
// Stats page configuration
|
||||
// Controls access to the /stats route for viewing site analytics
|
||||
// Set enabled: false to make stats page private (route still accessible but shows disabled message)
|
||||
statsPage: {
|
||||
enabled: true, // Global toggle for stats page
|
||||
showInNav: true, // Show link in navigation (also controlled via hardcodedNavItems)
|
||||
},
|
||||
|
||||
// Newsletter notifications configuration
|
||||
// Sends developer notifications for subscriber events via AgentMail
|
||||
newsletterNotifications: {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useQuery } from "convex/react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useNavigate, Link } from "react-router-dom";
|
||||
import { api } from "../../convex/_generated/api";
|
||||
import {
|
||||
ArrowLeft,
|
||||
@@ -37,6 +37,42 @@ export default function Stats() {
|
||||
const navigate = useNavigate();
|
||||
const stats = useQuery(api.stats.getStats);
|
||||
|
||||
// Check if stats page is enabled
|
||||
if (!siteConfig.statsPage?.enabled) {
|
||||
return (
|
||||
<div className="stats-page-wide">
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
minHeight: "60vh",
|
||||
gap: "1rem",
|
||||
padding: "2rem",
|
||||
textAlign: "center",
|
||||
}}
|
||||
>
|
||||
<h1 style={{ fontSize: "1.5rem", marginBottom: "0.5rem" }}>
|
||||
Site Statistics
|
||||
</h1>
|
||||
<p style={{ color: "var(--text-secondary)", marginBottom: "1rem" }}>
|
||||
Stats page is disabled in site configuration.
|
||||
</p>
|
||||
<Link
|
||||
to="/"
|
||||
style={{
|
||||
color: "var(--link-color)",
|
||||
textDecoration: "underline",
|
||||
}}
|
||||
>
|
||||
Back to Home
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// GitHub stars state
|
||||
const [githubStars, setGithubStars] = useState<number | null>(null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user