parent
8200993af4
commit
b741a0e1ee
7 changed files with 117 additions and 10 deletions
@ -0,0 +1,13 @@ |
|||||||
|
--- |
||||||
|
import BaseLayout, { Props as BaseLayoutProps } from './BaseLayout.astro'; |
||||||
|
|
||||||
|
export interface Props extends BaseLayoutProps {} |
||||||
|
|
||||||
|
const props = Astro.props; |
||||||
|
--- |
||||||
|
|
||||||
|
<BaseLayout {...props}> |
||||||
|
<div slot='page-header'></div> |
||||||
|
<slot /> |
||||||
|
<div slot='page-footer'></div> |
||||||
|
</BaseLayout> |
@ -0,0 +1,39 @@ |
|||||||
|
import type { MarkdownFileType } from './file'; |
||||||
|
|
||||||
|
export interface LinkGroupFrontmatter { |
||||||
|
[key: string]: string; |
||||||
|
} |
||||||
|
|
||||||
|
export type LinkGroupFileType = MarkdownFileType<LinkGroupFrontmatter> & { |
||||||
|
id: string; |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Generates id from the given linkGroup file |
||||||
|
* @param filePath Markdown file path |
||||||
|
* |
||||||
|
* @returns unique linkGroup identifier |
||||||
|
*/ |
||||||
|
function linkGroupPathToId(filePath: string): string { |
||||||
|
const fileName = filePath.split('/').pop() || ''; |
||||||
|
|
||||||
|
return fileName.replace('.md', ''); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Gets all the linkGroups sorted by the publishing date |
||||||
|
* @returns Promisifed linkGroup files |
||||||
|
*/ |
||||||
|
export async function getAllLinkGroups(): Promise<LinkGroupFileType[]> { |
||||||
|
const linkGroups = await import.meta.glob<LinkGroupFileType>('/src/link-groups/*.md', { |
||||||
|
eager: true, |
||||||
|
}); |
||||||
|
|
||||||
|
const linkGroupFiles = Object.values(linkGroups); |
||||||
|
const enrichedLinkGroups = linkGroupFiles.map((linkGroupFile) => ({ |
||||||
|
...linkGroupFile, |
||||||
|
id: linkGroupPathToId(linkGroupFile.file), |
||||||
|
})); |
||||||
|
|
||||||
|
return enrichedLinkGroups; |
||||||
|
} |
@ -0,0 +1,7 @@ |
|||||||
|
--- |
||||||
|
speedup-js: https://marvinh.dev/blog/speeding-up-javascript-ecosystem/ |
||||||
|
23-min-ts: https://www.youtube.com/watch?v=YmxwicpROps |
||||||
|
bun-vs-node: https://www.youtube.com/watch?v=qCX8rw4qOSA |
||||||
|
aws-2023: https://cs.fyi/guide/how-to-learn-aws/ |
||||||
|
db-playground: https://github.com/kamranahmedse/db-playground |
||||||
|
--- |
@ -0,0 +1,39 @@ |
|||||||
|
--- |
||||||
|
import BaseLayout from '../../../layouts/BaseLayout.astro'; |
||||||
|
import SkeletonLayout from '../../../layouts/SkeletonLayout.astro'; |
||||||
|
import { getAllLinkGroups } from '../../../lib/link-group'; |
||||||
|
|
||||||
|
export async function getStaticPaths() { |
||||||
|
const linkGroups = await getAllLinkGroups(); |
||||||
|
|
||||||
|
return linkGroups.flatMap((linkGroup) => { |
||||||
|
const linkGroupLinks = linkGroup.frontmatter; |
||||||
|
|
||||||
|
return Object.keys(linkGroupLinks).map((slug) => { |
||||||
|
return { |
||||||
|
params: { |
||||||
|
linkGroupId: linkGroup.id, |
||||||
|
linkId: slug, |
||||||
|
}, |
||||||
|
props: { |
||||||
|
linkGroup, |
||||||
|
}, |
||||||
|
}; |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
const { linkId } = Astro.params; |
||||||
|
const { linkGroup } = Astro.props; |
||||||
|
|
||||||
|
const fullUrl = linkGroup.frontmatter[linkId!]; |
||||||
|
--- |
||||||
|
|
||||||
|
<SkeletonLayout title='Redirecting..' noIndex={true} redirectUrl={fullUrl}> |
||||||
|
<div class='p-8'> |
||||||
|
<h2 class='text-xl font-bold'>Redirecting ..</h2> |
||||||
|
<p>Click the link below if you are not redirected automatically.</p> |
||||||
|
|
||||||
|
<p><a href={fullUrl} class='underline text-blue-700'>{fullUrl}</a></p> |
||||||
|
</div> |
||||||
|
</SkeletonLayout> |
Loading…
Reference in new issue