Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(view): cannot specify “type” of archives widget #60

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/view/widget/archives.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ class Archives extends Component {
* url_for: function() {...},
* _p: function() {...}
* }}
* type="monthly"
* group_by="monthly"
* order={-1}
* showCount={true}
* format="MMMM YYYY" />
*/
Archives.Cacheable = cacheComponent(Archives, 'widget.archives', (props) => {
const { site, config, page, helper, widget } = props;
const { type = 'monthly', order = -1, showCount = true, format = null } = widget;
const { group_by = 'monthly', order = -1, showCount = true, format = null } = widget;

const { url_for, _p } = helper;
const posts = site.posts.sort('date', order);
Expand All @@ -110,7 +110,7 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', (props) => {

const year = date.year();
const month = date.month() + 1;
const name = date.format(format || (type === 'monthly' ? 'MMMM YYYY' : 'YYYY'));
const name = date.format(format || (group_by === 'monthly' ? 'MMMM YYYY' : 'YYYY'));
const lastData = data[length - 1];

if (!lastData || lastData.name !== name) {
Expand All @@ -128,7 +128,7 @@ Archives.Cacheable = cacheComponent(Archives, 'widget.archives', (props) => {
const link = (item) => {
let url = `${config.archive_dir}/${item.year}/`;

if (type === 'monthly') {
if (group_by === 'monthly') {
if (item.month < 10) url += '0';
url += `${item.month}/`;
}
Expand Down