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,151 @@
import { InvariantError } from '../../shared/lib/invariant-error';
import { workAsyncStorage } from '../app-render/work-async-storage.external';
import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external';
function validateCacheLife(profile) {
if (profile.stale !== undefined) {
if (profile.stale === false) {
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you want to cache on the client forever ' + 'without checking with the server.'), "__NEXT_ERROR_CODE", {
value: "E407",
enumerable: false,
configurable: true
});
} else if (typeof profile.stale !== 'number') {
throw Object.defineProperty(new Error('The stale option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
value: "E308",
enumerable: false,
configurable: true
});
}
}
if (profile.revalidate !== undefined) {
if (profile.revalidate === false) {
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you do not want to revalidate by time.'), "__NEXT_ERROR_CODE", {
value: "E104",
enumerable: false,
configurable: true
});
} else if (typeof profile.revalidate !== 'number') {
throw Object.defineProperty(new Error('The revalidate option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
value: "E233",
enumerable: false,
configurable: true
});
}
}
if (profile.expire !== undefined) {
if (profile.expire === false) {
throw Object.defineProperty(new Error('Pass `Infinity` instead of `false` if you want to cache on the server forever ' + 'without checking with the origin.'), "__NEXT_ERROR_CODE", {
value: "E658",
enumerable: false,
configurable: true
});
} else if (typeof profile.expire !== 'number') {
throw Object.defineProperty(new Error('The expire option must be a number of seconds.'), "__NEXT_ERROR_CODE", {
value: "E3",
enumerable: false,
configurable: true
});
}
}
if (profile.revalidate !== undefined && profile.expire !== undefined) {
if (profile.revalidate > profile.expire) {
throw Object.defineProperty(new Error('If providing both the revalidate and expire options, ' + 'the expire option must be greater than the revalidate option. ' + 'The expire option indicates how many seconds from the start ' + 'until it can no longer be used.'), "__NEXT_ERROR_CODE", {
value: "E656",
enumerable: false,
configurable: true
});
}
}
}
export function cacheLife(profile) {
if (!process.env.__NEXT_USE_CACHE) {
throw Object.defineProperty(new Error('`cacheLife()` is only available with the `cacheComponents` config.'), "__NEXT_ERROR_CODE", {
value: "E887",
enumerable: false,
configurable: true
});
}
const workUnitStore = workUnitAsyncStorage.getStore();
switch(workUnitStore == null ? void 0 : workUnitStore.type){
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
case undefined:
throw Object.defineProperty(new Error('`cacheLife()` can only be called inside a "use cache" function.'), "__NEXT_ERROR_CODE", {
value: "E818",
enumerable: false,
configurable: true
});
case 'cache':
case 'private-cache':
break;
default:
workUnitStore;
}
if (typeof profile === 'string') {
const workStore = workAsyncStorage.getStore();
if (!workStore) {
throw Object.defineProperty(new Error('`cacheLife()` can only be called during App Router rendering at the moment.'), "__NEXT_ERROR_CODE", {
value: "E820",
enumerable: false,
configurable: true
});
}
if (!workStore.cacheLifeProfiles) {
throw Object.defineProperty(new InvariantError('`cacheLifeProfiles` should always be provided.'), "__NEXT_ERROR_CODE", {
value: "E817",
enumerable: false,
configurable: true
});
}
// TODO: This should be globally available and not require an AsyncLocalStorage.
const configuredProfile = workStore.cacheLifeProfiles[profile];
if (configuredProfile === undefined) {
if (workStore.cacheLifeProfiles[profile.trim()]) {
throw Object.defineProperty(new Error(`Unknown \`cacheLife()\` profile "${profile}" is not configured in next.config.js\n` + `Did you mean "${profile.trim()}" without the spaces?`), "__NEXT_ERROR_CODE", {
value: "E816",
enumerable: false,
configurable: true
});
}
throw Object.defineProperty(new Error(`Unknown \`cacheLife()\` profile "${profile}" is not configured in next.config.js\n` + 'module.exports = {\n' + ' cacheLife: {\n' + ` "${profile}": ...\n` + ' }\n' + '}'), "__NEXT_ERROR_CODE", {
value: "E888",
enumerable: false,
configurable: true
});
}
profile = configuredProfile;
} else if (typeof profile !== 'object' || profile === null || Array.isArray(profile)) {
throw Object.defineProperty(new Error('Invalid `cacheLife()` option. Either pass a profile name or object.'), "__NEXT_ERROR_CODE", {
value: "E814",
enumerable: false,
configurable: true
});
} else {
validateCacheLife(profile);
}
if (profile.revalidate !== undefined) {
// Track the explicit revalidate time.
if (workUnitStore.explicitRevalidate === undefined || workUnitStore.explicitRevalidate > profile.revalidate) {
workUnitStore.explicitRevalidate = profile.revalidate;
}
}
if (profile.expire !== undefined) {
// Track the explicit expire time.
if (workUnitStore.explicitExpire === undefined || workUnitStore.explicitExpire > profile.expire) {
workUnitStore.explicitExpire = profile.expire;
}
}
if (profile.stale !== undefined) {
// Track the explicit stale time.
if (workUnitStore.explicitStale === undefined || workUnitStore.explicitStale > profile.stale) {
workUnitStore.explicitStale = profile.stale;
}
}
}
//# sourceMappingURL=cache-life.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external';
import { validateTags } from '../lib/patch-fetch';
export function cacheTag(...tags) {
if (!process.env.__NEXT_USE_CACHE) {
throw Object.defineProperty(new Error('`cacheTag()` is only available with the `cacheComponents` config.'), "__NEXT_ERROR_CODE", {
value: "E886",
enumerable: false,
configurable: true
});
}
const workUnitStore = workUnitAsyncStorage.getStore();
switch(workUnitStore == null ? void 0 : workUnitStore.type){
case 'prerender':
case 'prerender-client':
case 'prerender-runtime':
case 'prerender-ppr':
case 'prerender-legacy':
case 'request':
case 'unstable-cache':
case undefined:
throw Object.defineProperty(new Error('`cacheTag()` can only be called inside a "use cache" function.'), "__NEXT_ERROR_CODE", {
value: "E819",
enumerable: false,
configurable: true
});
case 'cache':
case 'private-cache':
break;
default:
workUnitStore;
}
const validTags = validateTags(tags, '`cacheTag()`');
if (!workUnitStore.tags) {
workUnitStore.tags = validTags;
} else {
workUnitStore.tags.push(...validTags);
}
}
//# sourceMappingURL=cache-tag.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/use-cache/cache-tag.ts"],"sourcesContent":["import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external'\nimport { validateTags } from '../lib/patch-fetch'\n\nexport function cacheTag(...tags: string[]): void {\n if (!process.env.__NEXT_USE_CACHE) {\n throw new Error(\n '`cacheTag()` is only available with the `cacheComponents` config.'\n )\n }\n\n const workUnitStore = workUnitAsyncStorage.getStore()\n\n switch (workUnitStore?.type) {\n case 'prerender':\n case 'prerender-client':\n case 'prerender-runtime':\n case 'prerender-ppr':\n case 'prerender-legacy':\n case 'request':\n case 'unstable-cache':\n case undefined:\n throw new Error(\n '`cacheTag()` can only be called inside a \"use cache\" function.'\n )\n case 'cache':\n case 'private-cache':\n break\n default:\n workUnitStore satisfies never\n }\n\n const validTags = validateTags(tags, '`cacheTag()`')\n\n if (!workUnitStore.tags) {\n workUnitStore.tags = validTags\n } else {\n workUnitStore.tags.push(...validTags)\n }\n}\n"],"names":["workUnitAsyncStorage","validateTags","cacheTag","tags","process","env","__NEXT_USE_CACHE","Error","workUnitStore","getStore","type","undefined","validTags","push"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,iDAAgD;AACrF,SAASC,YAAY,QAAQ,qBAAoB;AAEjD,OAAO,SAASC,SAAS,GAAGC,IAAc;IACxC,IAAI,CAACC,QAAQC,GAAG,CAACC,gBAAgB,EAAE;QACjC,MAAM,qBAEL,CAFK,IAAIC,MACR,sEADI,qBAAA;mBAAA;wBAAA;0BAAA;QAEN;IACF;IAEA,MAAMC,gBAAgBR,qBAAqBS,QAAQ;IAEnD,OAAQD,iCAAAA,cAAeE,IAAI;QACzB,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAKC;YACH,MAAM,qBAEL,CAFK,IAAIJ,MACR,mEADI,qBAAA;uBAAA;4BAAA;8BAAA;YAEN;QACF,KAAK;QACL,KAAK;YACH;QACF;YACEC;IACJ;IAEA,MAAMI,YAAYX,aAAaE,MAAM;IAErC,IAAI,CAACK,cAAcL,IAAI,EAAE;QACvBK,cAAcL,IAAI,GAAGS;IACvB,OAAO;QACLJ,cAAcL,IAAI,CAACU,IAAI,IAAID;IAC7B;AACF","ignoreList":[0]}

View File

@@ -0,0 +1,6 @@
export const DYNAMIC_EXPIRE = 300 // 5 minutes
;
export const RUNTIME_PREFETCH_DYNAMIC_STALE = 30 // 30 seconds
;
//# sourceMappingURL=constants.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/use-cache/constants.ts"],"sourcesContent":["export const DYNAMIC_EXPIRE = 300 // 5 minutes\nexport const RUNTIME_PREFETCH_DYNAMIC_STALE = 30 // 30 seconds\n"],"names":["DYNAMIC_EXPIRE","RUNTIME_PREFETCH_DYNAMIC_STALE"],"mappings":"AAAA,OAAO,MAAMA,iBAAiB,IAAI,YAAY;CAAb;AACjC,OAAO,MAAMC,iCAAiC,GAAG,aAAa;CAAd","ignoreList":[0]}

View File

@@ -0,0 +1,110 @@
import { createDefaultCacheHandler } from '../lib/cache-handlers/default';
const debug = process.env.NEXT_PRIVATE_DEBUG_CACHE ? (message, ...args)=>{
console.log(`use-cache: ${message}`, ...args);
} : undefined;
const handlersSymbol = Symbol.for('@next/cache-handlers');
const handlersMapSymbol = Symbol.for('@next/cache-handlers-map');
const handlersSetSymbol = Symbol.for('@next/cache-handlers-set');
/**
* The reference to the cache handlers. We store the cache handlers on the
* global object so that we can access the same instance across different
* boundaries (such as different copies of the same module).
*/ const reference = globalThis;
/**
* Initialize the cache handlers.
* @param cacheMaxMemorySize - The maximum memory size of the cache in bytes, if
* not provided, the default memory size will be used.
* @returns `true` if the cache handlers were initialized, `false` if they were already initialized.
*/ export function initializeCacheHandlers(cacheMaxMemorySize) {
// If the cache handlers have already been initialized, don't do it again.
if (reference[handlersMapSymbol]) {
debug == null ? void 0 : debug('cache handlers already initialized');
return false;
}
debug == null ? void 0 : debug('initializing cache handlers');
reference[handlersMapSymbol] = new Map();
// Initialize the cache from the symbol contents first.
if (reference[handlersSymbol]) {
let fallback;
if (reference[handlersSymbol].DefaultCache) {
debug == null ? void 0 : debug('setting "default" cache handler from symbol');
fallback = reference[handlersSymbol].DefaultCache;
} else {
debug == null ? void 0 : debug('setting "default" cache handler from default');
fallback = createDefaultCacheHandler(cacheMaxMemorySize);
}
reference[handlersMapSymbol].set('default', fallback);
if (reference[handlersSymbol].RemoteCache) {
debug == null ? void 0 : debug('setting "remote" cache handler from symbol');
reference[handlersMapSymbol].set('remote', reference[handlersSymbol].RemoteCache);
} else {
debug == null ? void 0 : debug('setting "remote" cache handler from default');
reference[handlersMapSymbol].set('remote', fallback);
}
} else {
const handler = createDefaultCacheHandler(cacheMaxMemorySize);
debug == null ? void 0 : debug('setting "default" cache handler from default');
reference[handlersMapSymbol].set('default', handler);
debug == null ? void 0 : debug('setting "remote" cache handler from default');
reference[handlersMapSymbol].set('remote', handler);
}
// Create a set of the cache handlers.
reference[handlersSetSymbol] = new Set(reference[handlersMapSymbol].values());
return true;
}
/**
* Get a cache handler by kind.
* @param kind - The kind of cache handler to get.
* @returns The cache handler, or `undefined` if it does not exist.
* @throws If the cache handlers are not initialized.
*/ export function getCacheHandler(kind) {
// This should never be called before initializeCacheHandlers.
if (!reference[handlersMapSymbol]) {
throw Object.defineProperty(new Error('Cache handlers not initialized'), "__NEXT_ERROR_CODE", {
value: "E649",
enumerable: false,
configurable: true
});
}
return reference[handlersMapSymbol].get(kind);
}
/**
* Get a set iterator over the cache handlers.
* @returns An iterator over the cache handlers, or `undefined` if they are not
* initialized.
*/ export function getCacheHandlers() {
if (!reference[handlersSetSymbol]) {
return undefined;
}
return reference[handlersSetSymbol].values();
}
/**
* Get a map iterator over the cache handlers (keyed by kind).
* @returns An iterator over the cache handler entries, or `undefined` if they
* are not initialized.
* @throws If the cache handlers are not initialized.
*/ export function getCacheHandlerEntries() {
if (!reference[handlersMapSymbol]) {
return undefined;
}
return reference[handlersMapSymbol].entries();
}
/**
* Set a cache handler by kind.
* @param kind - The kind of cache handler to set.
* @param cacheHandler - The cache handler to set.
*/ export function setCacheHandler(kind, cacheHandler) {
// This should never be called before initializeCacheHandlers.
if (!reference[handlersMapSymbol] || !reference[handlersSetSymbol]) {
throw Object.defineProperty(new Error('Cache handlers not initialized'), "__NEXT_ERROR_CODE", {
value: "E649",
enumerable: false,
configurable: true
});
}
debug == null ? void 0 : debug('setting cache handler for "%s"', kind);
reference[handlersMapSymbol].set(kind, cacheHandler);
reference[handlersSetSymbol].add(cacheHandler);
}
//# sourceMappingURL=handlers.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
const USE_CACHE_TIMEOUT_ERROR_CODE = 'USE_CACHE_TIMEOUT';
export class UseCacheTimeoutError extends Error {
constructor(){
super('Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or dynamic data were used inside "use cache".'), this.digest = USE_CACHE_TIMEOUT_ERROR_CODE;
}
}
export function isUseCacheTimeoutError(err) {
if (typeof err !== 'object' || err === null || !('digest' in err) || typeof err.digest !== 'string') {
return false;
}
return err.digest === USE_CACHE_TIMEOUT_ERROR_CODE;
}
//# sourceMappingURL=use-cache-errors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["../../../../src/server/use-cache/use-cache-errors.ts"],"sourcesContent":["const USE_CACHE_TIMEOUT_ERROR_CODE = 'USE_CACHE_TIMEOUT'\n\nexport class UseCacheTimeoutError extends Error {\n digest: typeof USE_CACHE_TIMEOUT_ERROR_CODE = USE_CACHE_TIMEOUT_ERROR_CODE\n\n constructor() {\n super(\n 'Filling a cache during prerender timed out, likely because request-specific arguments such as params, searchParams, cookies() or dynamic data were used inside \"use cache\".'\n )\n }\n}\n\nexport function isUseCacheTimeoutError(\n err: unknown\n): err is UseCacheTimeoutError {\n if (\n typeof err !== 'object' ||\n err === null ||\n !('digest' in err) ||\n typeof err.digest !== 'string'\n ) {\n return false\n }\n\n return err.digest === USE_CACHE_TIMEOUT_ERROR_CODE\n}\n"],"names":["USE_CACHE_TIMEOUT_ERROR_CODE","UseCacheTimeoutError","Error","constructor","digest","isUseCacheTimeoutError","err"],"mappings":"AAAA,MAAMA,+BAA+B;AAErC,OAAO,MAAMC,6BAA6BC;IAGxCC,aAAc;QACZ,KAAK,CACH,qLAJJC,SAA8CJ;IAM9C;AACF;AAEA,OAAO,SAASK,uBACdC,GAAY;IAEZ,IACE,OAAOA,QAAQ,YACfA,QAAQ,QACR,CAAE,CAAA,YAAYA,GAAE,KAChB,OAAOA,IAAIF,MAAM,KAAK,UACtB;QACA,OAAO;IACT;IAEA,OAAOE,IAAIF,MAAM,KAAKJ;AACxB","ignoreList":[0]}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long