Merge pull request #53 from yougotwill/updates_tag
added updates tag and changed Dev Updates page to Updates
This commit is contained in:
commit
f63948d951
|
@ -80,8 +80,8 @@ const MENU_ITEMS: IMenuItem[] = [
|
|||
external: false,
|
||||
},
|
||||
{
|
||||
label: 'Dev Updates',
|
||||
href: '/tag/dev-update',
|
||||
label: 'Updates',
|
||||
href: '/tag/updates',
|
||||
newTab: false,
|
||||
subtle: true,
|
||||
external: false,
|
||||
|
|
|
@ -101,13 +101,13 @@ export default async function handler(
|
|||
bloglistPages.push(`${baseUrl}/blog/${i}`);
|
||||
}
|
||||
|
||||
const devUpdateUrl = `${baseUrl}/tag/dev-update`;
|
||||
const { entries, total } = await cms.fetchBlogEntriesByTag('dev-update');
|
||||
const updatesUrl = `${baseUrl}/tag/updates`;
|
||||
const { entries, total } = await cms.fetchBlogEntriesByTag('updates');
|
||||
const pageCount = Math.ceil(total / CMS.BLOG_RESULTS_PER_PAGE);
|
||||
const devUpdatePages = [devUpdateUrl];
|
||||
const updatesPages = [updatesUrl];
|
||||
|
||||
for (let i = 1; i <= pageCount; i++) {
|
||||
devUpdatePages.push(`${devUpdateUrl}/${i}`);
|
||||
updatesPages.push(`${updatesUrl}/${i}`);
|
||||
}
|
||||
|
||||
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
@ -117,7 +117,7 @@ export default async function handler(
|
|||
...navigationPages,
|
||||
...redirectPages,
|
||||
...bloglistPages,
|
||||
...devUpdatePages,
|
||||
...updatesPages,
|
||||
]
|
||||
.map(url => {
|
||||
return `
|
||||
|
|
|
@ -97,10 +97,7 @@ export const getStaticProps: GetStaticProps = async (
|
|||
const page = context.params.page ? Number(context.params.page[0]) : 1;
|
||||
|
||||
try {
|
||||
const {
|
||||
entries: posts,
|
||||
total,
|
||||
} = await cms.fetchBlogEntriesWithoutDevUpdates(
|
||||
const { entries: posts, total } = await cms.fetchBlogEntriesWithoutUpdates(
|
||||
CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page,
|
||||
);
|
||||
|
@ -131,7 +128,7 @@ export const getStaticProps: GetStaticProps = async (
|
|||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
const cms = new CmsApi();
|
||||
|
||||
const { entries, total } = await cms.fetchBlogEntriesWithoutDevUpdates();
|
||||
const { entries, total } = await cms.fetchBlogEntriesWithoutUpdates();
|
||||
const pageCount = Math.ceil(total / CMS.BLOG_RESULTS_PER_PAGE);
|
||||
const paths: IPath[] = [];
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ export default function Tag(props: Props): ReactElement {
|
|||
return (
|
||||
<>
|
||||
<CustomHead
|
||||
title={tag === 'dev-update' ? 'Dev Updates' : `${tag} Archives`}
|
||||
title={tag === 'update' ? 'Updates' : `${tag} Archives`}
|
||||
metadata={{
|
||||
TYPE: METADATA.TAG_PAGE.TYPE,
|
||||
DESCRIPTION: METADATA.TAG_PAGE.DESCRIPTION,
|
||||
|
|
|
@ -104,15 +104,14 @@ export class CmsApi {
|
|||
return Promise.reject(new Error(`Failed to fetch entries for ${tag}`));
|
||||
}
|
||||
|
||||
public async fetchBlogEntriesWithoutDevUpdates(
|
||||
public async fetchBlogEntriesWithoutUpdates(
|
||||
quantity = CMS.BLOG_RESULTS_PER_PAGE,
|
||||
page = 1,
|
||||
): Promise<IFetchBlogEntriesReturn> {
|
||||
const DEV_UPDATE_TAG = 'devUpdate';
|
||||
const _entries = await this.client.getEntries({
|
||||
content_type: 'post', // only fetch blog post entry
|
||||
order: '-fields.date',
|
||||
'metadata.tags.sys.id[nin]': DEV_UPDATE_TAG, // Exclude blog posts with the "dev-update" tag
|
||||
'metadata.tags.sys.id[nin]': 'updates', // Exclude blog posts with the "updates" tag
|
||||
limit: quantity,
|
||||
skip: (page - 1) * quantity,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue