テスト記事 Test Article
このページではブログの各種機能をテストします。
OGP リンクカード機能のテスト
記事内で外部リンクをOGP付きのカードとして表示できます。
使い方
通常のリンクとの比較:Hugo公式サイト
画像表示のテスト
Markdownで画像を表示できます。

相対パスや外部URLで画像を表示:

Youtube動画の埋め込みテスト
Hugoの組み込みショートコードでYoutube動画を埋め込めます。
コードブロックのテスト
シンタックスハイライト付きで様々な言語のコードを表示できます。
TypeScript
interface User {
id: number;
name: string;
email: string;
}
async function fetchUser(id: number): Promise<User> {
const response = await fetch(`/api/users/${id}`);
if (!response.ok) {
throw new Error("Failed to fetch user");
}
return response.json();
}
const user = await fetchUser(1);
console.log(`Hello, ${user.name}!`);
C#
using System;
using System.Collections.Generic;
using System.Linq;
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
public class UserService
{
private readonly List<User> _users = new();
public async Task<User?> GetUserAsync(int id)
{
return await Task.FromResult(
_users.FirstOrDefault(u => u.Id == id)
);
}
public void AddUser(User user)
{
_users.Add(user);
Console.WriteLine($"Added user: {user.Name}");
}
}
Rust
use std::collections::HashMap;
#[derive(Debug, Clone)]
struct User {
id: u32,
name: String,
email: String,
}
impl User {
fn new(id: u32, name: &str, email: &str) -> Self {
User {
id,
name: name.to_string(),
email: email.to_string(),
}
}
}
struct UserRepository {
users: HashMap<u32, User>,
}
impl UserRepository {
fn new() -> Self {
UserRepository {
users: HashMap::new(),
}
}
fn add_user(&mut self, user: User) {
println!("Adding user: {:?}", user.name);
self.users.insert(user.id, user);
}
fn get_user(&self, id: u32) -> Option<&User> {
self.users.get(&id)
}
}
fn main() {
let mut repo = UserRepository::new();
let user = User::new(1, "Alice", "alice@example.com");
repo.add_user(user);
if let Some(u) = repo.get_user(1) {
println!("Found user: {}", u.name);
}
}