feat(blog): add file-based blog with dynamic slugs, MDX content and layout shell

- Introduced blog routing using Next.js App Router
- Implemented dynamic [slug] pages for blog posts
- Added MDX-based content loading via lib/posts
- Integrated shared TopBar layout with navigation
- Established clear content, lib and component separation
This commit is contained in:
PascalSchattenburg
2026-01-22 14:14:15 +01:00
parent b717952234
commit d147843c76
10412 changed files with 2475583 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/**
* HTTPAccessFallbackBoundary is a boundary that catches errors and renders a
* fallback component for HTTP errors.
*
* It receives the status code, and determine if it should render fallbacks for few HTTP 4xx errors.
*
* e.g. 404
* 404 represents not found, and the fallback component pair contains the component and its styles.
*
*/
import React from 'react';
interface HTTPAccessFallbackBoundaryProps {
notFound?: React.ReactNode;
forbidden?: React.ReactNode;
unauthorized?: React.ReactNode;
children?: React.ReactNode;
missingSlots?: Set<string>;
}
export declare function HTTPAccessFallbackBoundary({ notFound, forbidden, unauthorized, children, }: HTTPAccessFallbackBoundaryProps): import("react/jsx-runtime").JSX.Element;
export {};

View File

@@ -0,0 +1,125 @@
'use client';
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "HTTPAccessFallbackBoundary", {
enumerable: true,
get: function() {
return HTTPAccessFallbackBoundary;
}
});
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
const _jsxruntime = require("react/jsx-runtime");
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
const _navigationuntracked = require("../navigation-untracked");
const _httpaccessfallback = require("./http-access-fallback");
const _warnonce = require("../../../shared/lib/utils/warn-once");
const _approutercontextsharedruntime = require("../../../shared/lib/app-router-context.shared-runtime");
class HTTPAccessFallbackErrorBoundary extends _react.default.Component {
constructor(props){
super(props);
this.state = {
triggeredStatus: undefined,
previousPathname: props.pathname
};
}
componentDidCatch() {
if (process.env.NODE_ENV === 'development' && this.props.missingSlots && this.props.missingSlots.size > 0 && // A missing children slot is the typical not-found case, so no need to warn
!this.props.missingSlots.has('children')) {
let warningMessage = 'No default component was found for a parallel route rendered on this page. Falling back to nearest NotFound boundary.\n' + 'Learn more: https://nextjs.org/docs/app/building-your-application/routing/parallel-routes#defaultjs\n\n';
const formattedSlots = Array.from(this.props.missingSlots).sort((a, b)=>a.localeCompare(b)).map((slot)=>`@${slot}`).join(', ');
warningMessage += 'Missing slots: ' + formattedSlots;
(0, _warnonce.warnOnce)(warningMessage);
}
}
static getDerivedStateFromError(error) {
if ((0, _httpaccessfallback.isHTTPAccessFallbackError)(error)) {
const httpStatus = (0, _httpaccessfallback.getAccessFallbackHTTPStatus)(error);
return {
triggeredStatus: httpStatus
};
}
// Re-throw if error is not for 404
throw error;
}
static getDerivedStateFromProps(props, state) {
/**
* Handles reset of the error boundary when a navigation happens.
* Ensures the error boundary does not stay enabled when navigating to a new page.
* Approach of setState in render is safe as it checks the previous pathname and then overrides
* it as outlined in https://react.dev/reference/react/useState#storing-information-from-previous-renders
*/ if (props.pathname !== state.previousPathname && state.triggeredStatus) {
return {
triggeredStatus: undefined,
previousPathname: props.pathname
};
}
return {
triggeredStatus: state.triggeredStatus,
previousPathname: props.pathname
};
}
render() {
const { notFound, forbidden, unauthorized, children } = this.props;
const { triggeredStatus } = this.state;
const errorComponents = {
[_httpaccessfallback.HTTPAccessErrorStatus.NOT_FOUND]: notFound,
[_httpaccessfallback.HTTPAccessErrorStatus.FORBIDDEN]: forbidden,
[_httpaccessfallback.HTTPAccessErrorStatus.UNAUTHORIZED]: unauthorized
};
if (triggeredStatus) {
const isNotFound = triggeredStatus === _httpaccessfallback.HTTPAccessErrorStatus.NOT_FOUND && notFound;
const isForbidden = triggeredStatus === _httpaccessfallback.HTTPAccessErrorStatus.FORBIDDEN && forbidden;
const isUnauthorized = triggeredStatus === _httpaccessfallback.HTTPAccessErrorStatus.UNAUTHORIZED && unauthorized;
// If there's no matched boundary in this layer, keep throwing the error by rendering the children
if (!(isNotFound || isForbidden || isUnauthorized)) {
return children;
}
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
name: "robots",
content: "noindex"
}),
process.env.NODE_ENV === 'development' && /*#__PURE__*/ (0, _jsxruntime.jsx)("meta", {
name: "boundary-next-error",
content: (0, _httpaccessfallback.getAccessFallbackErrorTypeByStatus)(triggeredStatus)
}),
errorComponents[triggeredStatus]
]
});
}
return children;
}
}
function HTTPAccessFallbackBoundary({ notFound, forbidden, unauthorized, children }) {
// When we're rendering the missing params shell, this will return null. This
// is because we won't be rendering any not found boundaries or error
// boundaries for the missing params shell. When this runs on the client
// (where these error can occur), we will get the correct pathname.
const pathname = (0, _navigationuntracked.useUntrackedPathname)();
const missingSlots = (0, _react.useContext)(_approutercontextsharedruntime.MissingSlotContext);
const hasErrorFallback = !!(notFound || forbidden || unauthorized);
if (hasErrorFallback) {
return /*#__PURE__*/ (0, _jsxruntime.jsx)(HTTPAccessFallbackErrorBoundary, {
pathname: pathname,
notFound: notFound,
forbidden: forbidden,
unauthorized: unauthorized,
missingSlots: missingSlots,
children: children
});
}
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
children: children
});
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=error-boundary.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
export declare function HTTPAccessErrorFallback({ status, message, }: {
status: number;
message: string;
}): import("react/jsx-runtime").JSX.Element;

View File

@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "HTTPAccessErrorFallback", {
enumerable: true,
get: function() {
return HTTPAccessErrorFallback;
}
});
const _jsxruntime = require("react/jsx-runtime");
const _accesserrorstyles = require("../styles/access-error-styles");
function HTTPAccessErrorFallback({ status, message }) {
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("title", {
children: `${status}: ${message}`
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
style: _accesserrorstyles.styles.error,
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
children: [
/*#__PURE__*/ (0, _jsxruntime.jsx)("style", {
dangerouslySetInnerHTML: {
/* Minified CSS from
body { margin: 0; color: #000; background: #fff; }
.next-error-h1 {
border-right: 1px solid rgba(0, 0, 0, .3);
}
@media (prefers-color-scheme: dark) {
body { color: #fff; background: #000; }
.next-error-h1 {
border-right: 1px solid rgba(255, 255, 255, .3);
}
}
*/ __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`
}
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("h1", {
className: "next-error-h1",
style: _accesserrorstyles.styles.h1,
children: status
}),
/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
style: _accesserrorstyles.styles.desc,
children: /*#__PURE__*/ (0, _jsxruntime.jsx)("h2", {
style: _accesserrorstyles.styles.h2,
children: message
})
})
]
})
})
]
});
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=error-fallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/http-access-fallback/error-fallback.tsx"],"sourcesContent":["import { styles } from '../styles/access-error-styles'\n\nexport function HTTPAccessErrorFallback({\n status,\n message,\n}: {\n status: number\n message: string\n}) {\n return (\n <>\n {/* <head> */}\n <title>{`${status}: ${message}`}</title>\n {/* </head> */}\n <div style={styles.error}>\n <div>\n <style\n dangerouslySetInnerHTML={{\n /* Minified CSS from\n body { margin: 0; color: #000; background: #fff; }\n .next-error-h1 {\n border-right: 1px solid rgba(0, 0, 0, .3);\n }\n\n @media (prefers-color-scheme: dark) {\n body { color: #fff; background: #000; }\n .next-error-h1 {\n border-right: 1px solid rgba(255, 255, 255, .3);\n }\n }\n */\n __html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`,\n }}\n />\n <h1 className=\"next-error-h1\" style={styles.h1}>\n {status}\n </h1>\n <div style={styles.desc}>\n <h2 style={styles.h2}>{message}</h2>\n </div>\n </div>\n </div>\n </>\n )\n}\n"],"names":["HTTPAccessErrorFallback","status","message","title","div","style","styles","error","dangerouslySetInnerHTML","__html","h1","className","desc","h2"],"mappings":";;;;+BAEgBA;;;eAAAA;;;;mCAFO;AAEhB,SAASA,wBAAwB,EACtCC,MAAM,EACNC,OAAO,EAIR;IACC,qBACE;;0BAEE,qBAACC;0BAAO,GAAGF,OAAO,EAAE,EAAEC,SAAS;;0BAE/B,qBAACE;gBAAIC,OAAOC,yBAAM,CAACC,KAAK;0BACtB,cAAA,sBAACH;;sCACC,qBAACC;4BACCG,yBAAyB;gCACvB;;;;;;;;;;;;cAYA,GACAC,QAAQ,CAAC,6NAA6N,CAAC;4BACzO;;sCAEF,qBAACC;4BAAGC,WAAU;4BAAgBN,OAAOC,yBAAM,CAACI,EAAE;sCAC3CT;;sCAEH,qBAACG;4BAAIC,OAAOC,yBAAM,CAACM,IAAI;sCACrB,cAAA,qBAACC;gCAAGR,OAAOC,yBAAM,CAACO,EAAE;0CAAGX;;;;;;;;AAMnC","ignoreList":[0]}

View File

@@ -0,0 +1,19 @@
export declare const HTTPAccessErrorStatus: {
NOT_FOUND: number;
FORBIDDEN: number;
UNAUTHORIZED: number;
};
export declare const HTTP_ERROR_FALLBACK_ERROR_CODE = "NEXT_HTTP_ERROR_FALLBACK";
export type HTTPAccessFallbackError = Error & {
digest: `${typeof HTTP_ERROR_FALLBACK_ERROR_CODE};${string}`;
};
/**
* Checks an error to determine if it's an error generated by
* the HTTP navigation APIs `notFound()`, `forbidden()` or `unauthorized()`.
*
* @param error the error that may reference a HTTP access error
* @returns true if the error is a HTTP access error
*/
export declare function isHTTPAccessFallbackError(error: unknown): error is HTTPAccessFallbackError;
export declare function getAccessFallbackHTTPStatus(error: HTTPAccessFallbackError): number;
export declare function getAccessFallbackErrorTypeByStatus(status: number): 'not-found' | 'forbidden' | 'unauthorized' | undefined;

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
HTTPAccessErrorStatus: null,
HTTP_ERROR_FALLBACK_ERROR_CODE: null,
getAccessFallbackErrorTypeByStatus: null,
getAccessFallbackHTTPStatus: null,
isHTTPAccessFallbackError: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
HTTPAccessErrorStatus: function() {
return HTTPAccessErrorStatus;
},
HTTP_ERROR_FALLBACK_ERROR_CODE: function() {
return HTTP_ERROR_FALLBACK_ERROR_CODE;
},
getAccessFallbackErrorTypeByStatus: function() {
return getAccessFallbackErrorTypeByStatus;
},
getAccessFallbackHTTPStatus: function() {
return getAccessFallbackHTTPStatus;
},
isHTTPAccessFallbackError: function() {
return isHTTPAccessFallbackError;
}
});
const HTTPAccessErrorStatus = {
NOT_FOUND: 404,
FORBIDDEN: 403,
UNAUTHORIZED: 401
};
const ALLOWED_CODES = new Set(Object.values(HTTPAccessErrorStatus));
const HTTP_ERROR_FALLBACK_ERROR_CODE = 'NEXT_HTTP_ERROR_FALLBACK';
function isHTTPAccessFallbackError(error) {
if (typeof error !== 'object' || error === null || !('digest' in error) || typeof error.digest !== 'string') {
return false;
}
const [prefix, httpStatus] = error.digest.split(';');
return prefix === HTTP_ERROR_FALLBACK_ERROR_CODE && ALLOWED_CODES.has(Number(httpStatus));
}
function getAccessFallbackHTTPStatus(error) {
const httpStatus = error.digest.split(';')[1];
return Number(httpStatus);
}
function getAccessFallbackErrorTypeByStatus(status) {
switch(status){
case 401:
return 'unauthorized';
case 403:
return 'forbidden';
case 404:
return 'not-found';
default:
return;
}
}
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=http-access-fallback.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/client/components/http-access-fallback/http-access-fallback.ts"],"sourcesContent":["export const HTTPAccessErrorStatus = {\n NOT_FOUND: 404,\n FORBIDDEN: 403,\n UNAUTHORIZED: 401,\n}\n\nconst ALLOWED_CODES = new Set(Object.values(HTTPAccessErrorStatus))\n\nexport const HTTP_ERROR_FALLBACK_ERROR_CODE = 'NEXT_HTTP_ERROR_FALLBACK'\n\nexport type HTTPAccessFallbackError = Error & {\n digest: `${typeof HTTP_ERROR_FALLBACK_ERROR_CODE};${string}`\n}\n\n/**\n * Checks an error to determine if it's an error generated by\n * the HTTP navigation APIs `notFound()`, `forbidden()` or `unauthorized()`.\n *\n * @param error the error that may reference a HTTP access error\n * @returns true if the error is a HTTP access error\n */\nexport function isHTTPAccessFallbackError(\n error: unknown\n): error is HTTPAccessFallbackError {\n if (\n typeof error !== 'object' ||\n error === null ||\n !('digest' in error) ||\n typeof error.digest !== 'string'\n ) {\n return false\n }\n const [prefix, httpStatus] = error.digest.split(';')\n\n return (\n prefix === HTTP_ERROR_FALLBACK_ERROR_CODE &&\n ALLOWED_CODES.has(Number(httpStatus))\n )\n}\n\nexport function getAccessFallbackHTTPStatus(\n error: HTTPAccessFallbackError\n): number {\n const httpStatus = error.digest.split(';')[1]\n return Number(httpStatus)\n}\n\nexport function getAccessFallbackErrorTypeByStatus(\n status: number\n): 'not-found' | 'forbidden' | 'unauthorized' | undefined {\n switch (status) {\n case 401:\n return 'unauthorized'\n case 403:\n return 'forbidden'\n case 404:\n return 'not-found'\n default:\n return\n }\n}\n"],"names":["HTTPAccessErrorStatus","HTTP_ERROR_FALLBACK_ERROR_CODE","getAccessFallbackErrorTypeByStatus","getAccessFallbackHTTPStatus","isHTTPAccessFallbackError","NOT_FOUND","FORBIDDEN","UNAUTHORIZED","ALLOWED_CODES","Set","Object","values","error","digest","prefix","httpStatus","split","has","Number","status"],"mappings":";;;;;;;;;;;;;;;;;;IAAaA,qBAAqB;eAArBA;;IAQAC,8BAA8B;eAA9BA;;IAuCGC,kCAAkC;eAAlCA;;IAPAC,2BAA2B;eAA3BA;;IAnBAC,yBAAyB;eAAzBA;;;AArBT,MAAMJ,wBAAwB;IACnCK,WAAW;IACXC,WAAW;IACXC,cAAc;AAChB;AAEA,MAAMC,gBAAgB,IAAIC,IAAIC,OAAOC,MAAM,CAACX;AAErC,MAAMC,iCAAiC;AAavC,SAASG,0BACdQ,KAAc;IAEd,IACE,OAAOA,UAAU,YACjBA,UAAU,QACV,CAAE,CAAA,YAAYA,KAAI,KAClB,OAAOA,MAAMC,MAAM,KAAK,UACxB;QACA,OAAO;IACT;IACA,MAAM,CAACC,QAAQC,WAAW,GAAGH,MAAMC,MAAM,CAACG,KAAK,CAAC;IAEhD,OACEF,WAAWb,kCACXO,cAAcS,GAAG,CAACC,OAAOH;AAE7B;AAEO,SAASZ,4BACdS,KAA8B;IAE9B,MAAMG,aAAaH,MAAMC,MAAM,CAACG,KAAK,CAAC,IAAI,CAAC,EAAE;IAC7C,OAAOE,OAAOH;AAChB;AAEO,SAASb,mCACdiB,MAAc;IAEd,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE;IACJ;AACF","ignoreList":[0]}