Skip to content

Commit

Permalink
Merge pull request #60 from imaegoo/patch-1
Browse files Browse the repository at this point in the history
fix(view): cannot specify “type” of archives widget
  • Loading branch information
ppoffice authored Jul 12, 2023
2 parents f286267 + 10dd8d3 commit 34fd4df
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit 34fd4df

Please sign in to comment.