-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add blog / portfolio template. (#897)
- Loading branch information
Showing
24 changed files
with
2,615 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
.vscode | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# env files | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Portfolio Blog Starter | ||
|
||
This is a porfolio site template complete with a blog. Includes: | ||
|
||
- MDX and Markdown support | ||
- Optimized for SEO (sitemap, robots, JSON-LD schema) | ||
- RSS Feed | ||
- Dynamic OG images | ||
- Syntax highlighting | ||
- Tailwind v4 | ||
- Vercel Speed Insights / Web Analytics | ||
- Geist font | ||
|
||
## Demo | ||
|
||
https://portfolio-blog-starter.vercel.app | ||
|
||
## How to Use | ||
|
||
You can choose from one of the following two methods to use this repository: | ||
|
||
### One-Click Deploy | ||
|
||
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=vercel-examples): | ||
|
||
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https://github.com/vercel/examples/tree/main/solutions/blog&project-name=blog&repository-name=blog) | ||
|
||
### Clone and Deploy | ||
|
||
Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [pnpm](https://pnpm.io/installation) to bootstrap the example: | ||
|
||
```bash | ||
pnpm create next-app --example https://github.com/vercel/examples/tree/main/solutions/blog blog | ||
``` | ||
|
||
Then, run Next.js in development mode: | ||
|
||
```bash | ||
pnpm dev | ||
``` | ||
|
||
Deploy it to the cloud with [Vercel](https://vercel.com/templates) ([Documentation](https://nextjs.org/docs/app/building-your-application/deploying)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import type { Metadata } from 'next' | ||
import { notFound } from 'next/navigation' | ||
import { CustomMDX } from 'app/components/mdx' | ||
import { formatDate, getBlogPosts } from 'app/blog/utils' | ||
import { baseUrl } from 'app/sitemap' | ||
|
||
export async function generateStaticParams() { | ||
let posts = getBlogPosts() | ||
|
||
return posts.map((post) => ({ | ||
slug: post.slug, | ||
})) | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}): Promise<Metadata | undefined> { | ||
let post = getBlogPosts().find((post) => post.slug === params.slug) | ||
if (!post) { | ||
return | ||
} | ||
|
||
let { | ||
title, | ||
publishedAt: publishedTime, | ||
summary: description, | ||
image, | ||
} = post.metadata | ||
let ogImage = image ? image : `/og?title=${encodeURIComponent(title)}` | ||
|
||
return { | ||
title, | ||
description, | ||
openGraph: { | ||
title, | ||
description, | ||
type: 'article', | ||
publishedTime, | ||
url: `${baseUrl}/blog/${post.slug}`, | ||
images: [ | ||
{ | ||
url: ogImage, | ||
}, | ||
], | ||
}, | ||
twitter: { | ||
card: 'summary_large_image', | ||
title, | ||
description, | ||
images: [ogImage], | ||
}, | ||
} | ||
} | ||
|
||
export default function Blog({ params }) { | ||
let post = getBlogPosts().find((post) => post.slug === params.slug) | ||
|
||
if (!post) { | ||
notFound() | ||
} | ||
|
||
return ( | ||
<section> | ||
<script | ||
type="application/ld+json" | ||
suppressHydrationWarning | ||
dangerouslySetInnerHTML={{ | ||
__html: JSON.stringify({ | ||
'@context': 'https://schema.org', | ||
'@type': 'BlogPosting', | ||
headline: post.metadata.title, | ||
datePublished: post.metadata.publishedAt, | ||
dateModified: post.metadata.publishedAt, | ||
description: post.metadata.summary, | ||
image: post.metadata.image | ||
? `${baseUrl}${post.metadata.image}` | ||
: `/og?title=${encodeURIComponent(post.metadata.title)}`, | ||
url: `${baseUrl}/blog/${post.slug}`, | ||
author: { | ||
'@type': 'Person', | ||
name: 'My Portfolio', | ||
}, | ||
}), | ||
}} | ||
/> | ||
<h1 className="title font-semibold text-2xl tracking-tighter"> | ||
{post.metadata.title} | ||
</h1> | ||
<div className="flex justify-between items-center mt-2 mb-8 text-sm"> | ||
<p className="text-sm text-neutral-600 dark:text-neutral-400"> | ||
{formatDate(post.metadata.publishedAt)} | ||
</p> | ||
</div> | ||
<article className="prose"> | ||
<CustomMDX source={post.content} /> | ||
</article> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BlogPosts } from 'app/components/posts' | ||
|
||
export const metadata = { | ||
title: 'Blog', | ||
description: 'Read my blog.', | ||
} | ||
|
||
export default function Page() { | ||
return ( | ||
<section> | ||
<h1 className="font-semibold text-2xl mb-8 tracking-tighter">My Blog</h1> | ||
<BlogPosts /> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
title: 'Spaces vs. Tabs: The Indentation Debate Continues' | ||
publishedAt: '2024-04-08' | ||
summary: 'Explore the enduring debate between using spaces and tabs for code indentation, and why this choice matters more than you might think.' | ||
--- | ||
|
||
The debate between using spaces and tabs for indentation in coding may seem trivial to the uninitiated, but it is a topic that continues to inspire passionate discussions among developers. This seemingly minor choice can affect code readability, maintenance, and even team dynamics. | ||
|
||
Let's delve into the arguments for both sides and consider why this debate remains relevant in the software development world. | ||
|
||
## The Case for Spaces | ||
|
||
Advocates for using spaces argue that it ensures consistent code appearance across different editors, tools, and platforms. Because a space is a universally recognized character with a consistent width, code indented with spaces will look the same no matter where it's viewed. This consistency is crucial for maintaining readability and avoiding formatting issues when code is shared between team members or published online. | ||
|
||
Additionally, some programming languages and style guides explicitly recommend spaces for indentation, suggesting a certain number of spaces (often two or four) per indentation level. Adhering to these recommendations can be essential for projects that aim for best practices in code quality and readability. | ||
|
||
## The Case for Tabs | ||
|
||
On the other side of the debate, proponents of tabs highlight the flexibility that tabs offer. Because the width of a tab can be adjusted in most text editors, individual developers can choose how much indentation they prefer to see, making the code more accessible and comfortable to read on a personal level. This adaptability can be particularly beneficial in teams with diverse preferences regarding code layout. | ||
|
||
Tabs also have the advantage of semantic meaning. A tab is explicitly meant to represent indentation, whereas a space is used for many purposes within code. This distinction can make automated parsing and manipulation of code simpler, as tools can more easily recognize and adjust indentation levels without confusing them with spaces used for alignment. | ||
|
||
## Hybrid Approaches and Team Dynamics | ||
|
||
The debate often extends into discussions about hybrid approaches, where teams might use tabs for indentation and spaces for alignment within lines, attempting to combine the best of both worlds. However, such strategies require clear team agreements and disciplined adherence to coding standards to prevent formatting chaos. | ||
|
||
Ultimately, the choice between spaces and tabs often comes down to team consensus and project guidelines. In environments where collaboration and code sharing are common, agreeing on a standard that everyone follows is more important than the individual preferences of spaces versus tabs. Modern development tools and linters can help enforce these standards, making the choice less about technical limitations and more about team dynamics and coding philosophy. | ||
|
||
## Conclusion | ||
|
||
While the spaces vs. tabs debate might not have a one-size-fits-all answer, it underscores the importance of consistency, readability, and team collaboration in software development. Whether a team chooses spaces, tabs, or a hybrid approach, the key is to make a conscious choice that serves the project's needs and to adhere to it throughout the codebase. As with many aspects of coding, communication and agreement among team members are paramount to navigating this classic programming debate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
title: 'The Power of Static Typing in Programming' | ||
publishedAt: '2024-04-07' | ||
summary: 'In the ever-evolving landscape of software development, the debate between dynamic and static typing continues to be a hot topic.' | ||
--- | ||
|
||
In the ever-evolving landscape of software development, the debate between dynamic and static typing continues to be a hot topic. While dynamic typing offers flexibility and rapid development, static typing brings its own set of powerful advantages that can significantly improve the quality and maintainability of code. In this post, we'll explore why static typing is crucial for developers, accompanied by practical examples through markdown code snippets. | ||
|
||
## Improved Code Quality and Safety | ||
|
||
One of the most compelling reasons to use static typing is the improvement it brings to code quality and safety. By enforcing type checks at compile time, static typing catches errors early in the development process, reducing the chances of runtime errors. | ||
|
||
```ts | ||
function greet(name: string): string { | ||
return `Hello, ${name}!` | ||
} | ||
|
||
// This will throw an error at compile time, preventing potential runtime issues. | ||
let message: string = greet(123) | ||
``` | ||
|
||
## Enhanced Readability and Maintainability | ||
|
||
Static typing makes code more readable and maintainable. By explicitly declaring types, developers provide a clear contract of what the code does, making it easier for others (or themselves in the future) to understand and modify the codebase. | ||
|
||
## Facilitates Tooling and Refactoring | ||
|
||
Modern IDEs leverage static typing to offer advanced features like code completion, refactoring, and static analysis. These tools can automatically detect issues, suggest fixes, and safely refactor code, enhancing developer productivity and reducing the likelihood of introducing bugs during refactoring. | ||
|
||
```csharp | ||
// Refactoring example: Renaming a method in C# | ||
public class Calculator { | ||
public int Add(int a, int b) { | ||
return a + b; | ||
} | ||
} | ||
|
||
// After refactoring `Add` to `Sum`, all references are automatically updated. | ||
public class Calculator { | ||
public int Sum(int a, int b) { | ||
return a + b; | ||
} | ||
} | ||
``` | ||
|
||
## Performance Optimizations | ||
|
||
Static typing can lead to better performance. Since types are known at compile time, compilers can optimize the generated code more effectively. This can result in faster execution times and lower resource consumption. | ||
|
||
## Conclusion | ||
|
||
Static typing offers numerous benefits that contribute to the development of robust, efficient, and maintainable software. By catching errors early, enhancing readability, facilitating tooling, and enabling optimizations, static typing is an invaluable asset for developers. As the software industry continues to mature, the importance of static typing in ensuring code quality and performance cannot be overstated. Whether you're working on a large-scale enterprise application or a small project, embracing static typing can lead to better software development outcomes. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
title: 'Embracing Vim: The Unsung Hero of Code Editors' | ||
publishedAt: '2024-04-09' | ||
summary: 'Discover why Vim, with its steep learning curve, remains a beloved tool among developers for editing code efficiently and effectively.' | ||
--- | ||
|
||
In the world of software development, where the latest and greatest tools frequently capture the spotlight, Vim stands out as a timeless classic. Despite its age and initial complexity, Vim has managed to retain a devoted following of developers who swear by its efficiency, versatility, and power. | ||
|
||
This article delves into the reasons behind Vim's enduring appeal and why it continues to be a great tool for coding in the modern era. | ||
|
||
## Efficiency and Speed | ||
|
||
At the heart of Vim's philosophy is the idea of minimizing keystrokes to achieve maximum efficiency. | ||
|
||
Unlike other text editors where the mouse is often relied upon for navigation and text manipulation, Vim's keyboard-centric design allows developers to perform virtually all coding tasks without leaving the home row. This not only speeds up coding but also reduces the risk of repetitive strain injuries. | ||
|
||
## Highly Customizable | ||
|
||
Vim can be extensively customized to suit any developer's preferences and workflow. With a vibrant ecosystem of plugins and a robust scripting language, users can tailor the editor to their specific needs, whether it's programming in Python, writing in Markdown, or managing projects. | ||
|
||
This level of customization ensures that Vim remains relevant and highly functional for a wide range of programming tasks and languages. | ||
|
||
## Ubiquity and Portability | ||
|
||
Vim is virtually everywhere. It's available on all major platforms, and because it's lightweight and terminal-based, it can be used on remote servers through SSH, making it an indispensable tool for sysadmins and developers working in a cloud-based environment. | ||
|
||
The ability to use the same editor across different systems without a graphical interface is a significant advantage for those who need to maintain a consistent workflow across multiple environments. | ||
|
||
## Vibrant Community | ||
|
||
Despite—or perhaps because of—its learning curve, Vim has cultivated a passionate and active community. Online forums, dedicated websites, and plugins abound, offering support, advice, and improvements. | ||
|
||
This community not only helps newcomers climb the steep learning curve but also continually contributes to Vim's evolution, ensuring it remains adaptable and up-to-date with the latest programming trends and technologies. | ||
|
||
## Conclusion | ||
|
||
Vim is not just a text editor; it's a way of approaching coding with efficiency and thoughtfulness. Its steep learning curve is a small price to pay for the speed, flexibility, and control it offers. | ||
|
||
For those willing to invest the time to master its commands, Vim proves to be an invaluable tool that enhances productivity and enjoyment in coding. In an age of ever-changing development tools, the continued popularity of Vim is a testament to its enduring value and utility. |
Oops, something went wrong.