1.0.2 โ€ข Published 5 months ago

@goobits/blog v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

@goobits/blog

๐Ÿš€ STABLE RELEASE - v1.0.1

Markdown-based blog framework with flexible i18n support and content categorization.

๐Ÿ”’ Security Notice

This package processes user-generated markdown content. Always sanitize markdown on the server-side before rendering. Do not trust user input.

โœจ Features

  • Content in src/content/Blog/{year}/{month}/
  • Frontmatter for metadata (title, date, categories, tags)
  • Framework-agnostic i18n support
  • RSS feed generation
  • Category and tag filtering
  • Pagination and search
  • Responsive layouts

๐Ÿ“ฆ Installation

npm install @goobits/blog

๐Ÿš€ Quick Start

1. Configure Your Blog

Create a configuration file at src/lib/blog-config.js:

export const blogConfig = {
  // Basic Information
  name: 'My Blog',
  description: 'Welcome to my blog',
  uri: '/blog',
  
  // Customize settings as needed
  theme: {
    colors: {
      primary: '#3b82f6',
    }
  }
}

// Define blog post files location
export function getBlogPostFiles() {
  return import.meta.glob('/src/content/Blog/**/*.md')
}

2. Initialize the Configuration

// src/app.js
import { initBlogConfig } from '@goobits/blog/config'
import { blogConfig, getBlogPostFiles } from '$lib/blog-config.js'

initBlogConfig(blogConfig, {
  getBlogPostFiles
})

3. Create Blog Routes

Copy templates from node_modules/@goobits/blog/templates/ to your routes directory:

src/routes/
โ””โ”€โ”€ blog/
    โ”œโ”€โ”€ +page.server.js  # Blog index
    โ”œโ”€โ”€ +page.svelte     # Blog index display
    โ”œโ”€โ”€ [...slug]/       # Blog posts, categories, tags
    โ””โ”€โ”€ rss.xml/         # RSS feed

4. Use Components

<script>
  import { PostList, Sidebar } from '@goobits/blog/ui'
  import { defaultMessages } from '@goobits/blog/config'
  
  let { posts, categories, tags } = $props()
</script>

<div class="blog-layout">
  <PostList {posts} />
  <Sidebar {categories} {tags} />
</div>

๐ŸŒ Internationalization (i18n)

The blog package supports full internationalization through multiple integration methods:

1. Component-level Translation

All components accept a messages prop for direct translation override:

<script>
  import { BlogCard } from '@goobits/blog'
  
  // Custom translations
  const messages = {
    readMore: 'Leer mรกs',
    author: 'Autor',
    tags: 'Etiquetas'
  }
</script>

<BlogCard post={post} {messages} />

2. Server Integration

For full i18n with automatic language detection and routing:

// hooks.server.js
import { handleBlogI18n } from '@goobits/blog/i18n'

export async function handle({ event, resolve }) {
  // Add language info to event.locals
  await handleBlogI18n(event)
  
  // Continue with request handling
  return await resolve(event)
}

3. Page Integration

Enhance blog pages with i18n data:

// blog/+page.server.js
import { loadWithBlogI18n } from '@goobits/blog/i18n'

export const load = async (event) => {
  return await loadWithBlogI18n(event, async () => {
    // Your original blog data loading
    return { posts, categories, tags }
  })
}

4. Paraglide Integration

For seamless integration with Paraglide (recommended):

import { createMessageGetter } from '@goobits/blog/i18n'
import * as m from '$paraglide/messages'

// Map blog message keys to Paraglide translations
const getMessage = createMessageGetter({
  readMore: m.readMore,
  author: m.author,
  tags: m.tags
})

๐Ÿงฉ Components

  • BlogRouter - Main router component
  • BlogListPage - Blog index/archive page
  • BlogPostPage - Individual post page
  • BlogCard - Post preview card
  • PostList - List of blog posts with layouts
  • Sidebar - Blog sidebar with search/filters
  • TagCategoryList - Tag and category display
  • SocialShare - Social sharing buttons
  • Newsletter - Newsletter subscription form
  • Breadcrumbs - Navigation breadcrumbs

๐ŸŽจ Styling

Import component-specific SCSS files:

import '@goobits/blog/ui/BlogCard.scss'
import '@goobits/blog/ui/Sidebar.scss'

๐Ÿ”ง Configuration Options

The blog can be configured with many options:

initBlogConfig({
  // Basic info
  name: 'My Blog',
  description: 'Welcome to my blog',
  uri: '/blog',
  
  // Content settings
  posts: {
    excerptLength: 200,
    relatedPostsCount: 5,
    readTime: {
      wordsPerMinute: 200
    }
  },
  
  // Theme
  theme: {
    colors: {
      primary: '#3b82f6',
      secondary: '#10b981'
    }
  },
  
  // i18n
  i18n: {
    enabled: true,
    supportedLanguages: ['en', 'es', 'fr']
  }
})

โ™ฟ Accessibility

Components include proper ARIA attributes, semantic HTML, and keyboard navigation support.

๐Ÿ“„ License

MIT

1.0.2

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.0.1-alpha

6 months ago