
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@apostrophecms/blog
Advanced tools
Add blog functionality to ApostropheCMS sites with article management, date-based filtering, and multiple blog support. Provides both the blog piece type and page templates to get started quickly.
To install the module, use the command line to run this command in an Apostrophe project's root directory:
npm install @apostrophecms/blog
Configure the blog modules in your app.js
file:
import apostrophe from 'apostrophe';
export default apostrophe({
root: import.meta,
shortName: 'my-project',
bundles: [ '@apostrophecms/blog' ],
modules: {
'@apostrophecms/blog': {},
'@apostrophecms/blog-page': {}
}
});
Add the blog page type to your page configuration:
// modules/@apostrophecms/page/index.js
export default {
options: {
types: [
{
name: '@apostrophecms/home-page',
label: 'Home'
},
{
name: '@apostrophecms/blog-page',
label: 'Blog'
}
]
}
};
The included templates (index.html
, show.html
, filters.html
) are starting points that demonstrate the available data. Override them in your project to implement your own styling and layout:
modules/
├── @apostrophecms/
│ └── blog-page/
│ └── views/
│ ├── index.html # Blog listing page
│ ├── show.html # Individual blog post
│ └── filters.html # Date filtering controls
The blog includes built-in query filters for creating archive navigation and date-based URLs:
Filter | Format | Example URL |
---|---|---|
year | YYYY | /blog?year=2024 |
month | YYYY-MM | /blog?month=2024-03 |
day | YYYY-MM-DD | /blog?day=2024-03-15 |
Blog posts use the publishedAt
field to control visibility. Only articles with publication dates in the past appear on the public site. Editors see all articles in the admin interface.
Note: This doesn't automatically publish draft changes on the publication date. For scheduled publishing of draft content, consider the @apostrophecms/scheduled-publishing module.
Sometimes a website needs multiple, distinct types of blog posts. If the blog posts types can be managed together, it might be easiest to add a new field and query builder to customize blog views. But if the blog posts types should be managed completely separately, it may be better to create separate piece types for each.
// modules/news-blog/index.js - for news articles
export default {
extend: '@apostrophecms/blog',
options: {
label: 'News Article',
pluralLabel: 'News Articles'
},
fields: {
add: {
priority: {
type: 'select',
choices: [
{ label: 'Standard', value: 'standard' },
{ label: 'Breaking', value: 'breaking' },
{ label: 'Featured', value: 'featured' }
]
},
source: {
type: 'string',
label: 'News Source',
help: 'Original source of this news item'
}
},
group: {
basics: { fields: ['priority', 'source'] }
}
}
};
Every blog piece type needs a corresponding page type that extends @apostrophecms/blog-page
:
// modules/news-blog-page/index.js - page type for news articles
export default {
extend: '@apostrophecms/blog-page'
};
Each blog type can have its own templates. Create them in the corresponding page module:
modules/
├── news-blog-page/
│ └── views/
│ ├── index.html # News listing page
│ ├── show.html # Individual news article
│ └── filters.html # Custom filters for news
└── @apostrophecms/
└── blog-page/
└── views/
├── index.html # Default blog listing
└── show.html # Default blog post
This allows you to:
This approach works well when blog types have different:
/blog/
, /news/
, /updates/
with distinct navigationThe blog piece type includes these fields by default:
title
) - Article headlineslug
) - URL-friendly identifierpublishedAt
) - Controls public visibilitybody
) - Rich text content areametaDescription
) - SEO descriptiontags
) - Taxonomy for categorizationFound this useful? Give us a star on GitHub ⭐
1.0.6 (2025-09-03)
FAQs
Blog module for ApostropheCMS websites
The npm package @apostrophecms/blog receives a total of 2,231 weekly downloads. As such, @apostrophecms/blog popularity was classified as popular.
We found that @apostrophecms/blog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.