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