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:
102
apps/public-web/node_modules/next/dist/shared/lib/segment.js
generated
vendored
Normal file
102
apps/public-web/node_modules/next/dist/shared/lib/segment.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
0 && (module.exports = {
|
||||
DEFAULT_SEGMENT_KEY: null,
|
||||
NOT_FOUND_SEGMENT_KEY: null,
|
||||
PAGE_SEGMENT_KEY: null,
|
||||
addSearchParamsIfPageSegment: null,
|
||||
computeSelectedLayoutSegment: null,
|
||||
getSegmentValue: null,
|
||||
getSelectedLayoutSegmentPath: null,
|
||||
isGroupSegment: null,
|
||||
isParallelRouteSegment: null
|
||||
});
|
||||
function _export(target, all) {
|
||||
for(var name in all)Object.defineProperty(target, name, {
|
||||
enumerable: true,
|
||||
get: all[name]
|
||||
});
|
||||
}
|
||||
_export(exports, {
|
||||
DEFAULT_SEGMENT_KEY: function() {
|
||||
return DEFAULT_SEGMENT_KEY;
|
||||
},
|
||||
NOT_FOUND_SEGMENT_KEY: function() {
|
||||
return NOT_FOUND_SEGMENT_KEY;
|
||||
},
|
||||
PAGE_SEGMENT_KEY: function() {
|
||||
return PAGE_SEGMENT_KEY;
|
||||
},
|
||||
addSearchParamsIfPageSegment: function() {
|
||||
return addSearchParamsIfPageSegment;
|
||||
},
|
||||
computeSelectedLayoutSegment: function() {
|
||||
return computeSelectedLayoutSegment;
|
||||
},
|
||||
getSegmentValue: function() {
|
||||
return getSegmentValue;
|
||||
},
|
||||
getSelectedLayoutSegmentPath: function() {
|
||||
return getSelectedLayoutSegmentPath;
|
||||
},
|
||||
isGroupSegment: function() {
|
||||
return isGroupSegment;
|
||||
},
|
||||
isParallelRouteSegment: function() {
|
||||
return isParallelRouteSegment;
|
||||
}
|
||||
});
|
||||
function getSegmentValue(segment) {
|
||||
return Array.isArray(segment) ? segment[1] : segment;
|
||||
}
|
||||
function isGroupSegment(segment) {
|
||||
// Use array[0] for performant purpose
|
||||
return segment[0] === '(' && segment.endsWith(')');
|
||||
}
|
||||
function isParallelRouteSegment(segment) {
|
||||
return segment.startsWith('@') && segment !== '@children';
|
||||
}
|
||||
function addSearchParamsIfPageSegment(segment, searchParams) {
|
||||
const isPageSegment = segment.includes(PAGE_SEGMENT_KEY);
|
||||
if (isPageSegment) {
|
||||
const stringifiedQuery = JSON.stringify(searchParams);
|
||||
return stringifiedQuery !== '{}' ? PAGE_SEGMENT_KEY + '?' + stringifiedQuery : PAGE_SEGMENT_KEY;
|
||||
}
|
||||
return segment;
|
||||
}
|
||||
function computeSelectedLayoutSegment(segments, parallelRouteKey) {
|
||||
if (!segments || segments.length === 0) {
|
||||
return null;
|
||||
}
|
||||
// For 'children', use first segment; for other parallel routes, use last segment
|
||||
const rawSegment = parallelRouteKey === 'children' ? segments[0] : segments[segments.length - 1];
|
||||
// If the default slot is showing, return null since it's not technically "selected" (it's a fallback)
|
||||
// Returning an internal value like `__DEFAULT__` would be confusing
|
||||
return rawSegment === DEFAULT_SEGMENT_KEY ? null : rawSegment;
|
||||
}
|
||||
function getSelectedLayoutSegmentPath(tree, parallelRouteKey, first = true, segmentPath = []) {
|
||||
let node;
|
||||
if (first) {
|
||||
// Use the provided parallel route key on the first parallel route
|
||||
node = tree[1][parallelRouteKey];
|
||||
} else {
|
||||
// After first parallel route prefer children, if there's no children pick the first parallel route.
|
||||
const parallelRoutes = tree[1];
|
||||
node = parallelRoutes.children ?? Object.values(parallelRoutes)[0];
|
||||
}
|
||||
if (!node) return segmentPath;
|
||||
const segment = node[0];
|
||||
let segmentValue = getSegmentValue(segment);
|
||||
if (!segmentValue || segmentValue.startsWith(PAGE_SEGMENT_KEY)) {
|
||||
return segmentPath;
|
||||
}
|
||||
segmentPath.push(segmentValue);
|
||||
return getSelectedLayoutSegmentPath(node, parallelRouteKey, false, segmentPath);
|
||||
}
|
||||
const PAGE_SEGMENT_KEY = '__PAGE__';
|
||||
const DEFAULT_SEGMENT_KEY = '__DEFAULT__';
|
||||
const NOT_FOUND_SEGMENT_KEY = '/_not-found';
|
||||
|
||||
//# sourceMappingURL=segment.js.map
|
||||
Reference in New Issue
Block a user