diff --git a/core/core/src/configuration.ts b/core/core/src/configuration.ts
index f25115a6f..204981376 100644
--- a/core/core/src/configuration.ts
+++ b/core/core/src/configuration.ts
@@ -124,14 +124,15 @@ export type PagesOnlyRoutes = Record<
export interface SitemapConfigPage {
priority: number;
}
-export interface SitemapConfig {
- outputFolder: string;
- pages?: {
- home: SitemapConfigPage;
- index: SitemapConfigPage;
- doc: SitemapConfigPage;
- };
-}
+export type SitemapConfig =
+ | {
+ pages?: {
+ home: SitemapConfigPage;
+ index: SitemapConfigPage;
+ doc: SitemapConfigPage;
+ };
+ }
+ | boolean;
/**
* global configuration used at build time
@@ -377,7 +378,6 @@ export const convertConfig = (config: RunConfiguration): RunConfiguration => {
export const defaultBuildConfig: BuildConfiguration = {
siteRoot: '/',
siteMap: {
- outputFolder: 'public/',
pages: {
home: {
priority: 1,
diff --git a/core/store/src/create-pages/pages-paths.ts b/core/store/src/create-pages/pages-paths.ts
index 0136fcf14..8ccd47f27 100644
--- a/core/store/src/create-pages/pages-paths.ts
+++ b/core/store/src/create-pages/pages-paths.ts
@@ -11,6 +11,7 @@ import {
TabConfiguration,
getDocPath,
getStoryPath,
+ dateToLocalString,
} from '@component-controls/core';
import { HomePageInfo } from '../types';
@@ -34,6 +35,7 @@ export const getIndexPage = (store: Store): HomePageInfo => {
? docStories[0]
: undefined;
return {
+ lastModified: dateToLocalString(homePage?.dateModified),
path: homePath,
storyId,
docId,
@@ -46,6 +48,7 @@ export interface DocHomePagesPath {
path: string;
docId?: string;
storyId?: string;
+ lastModified?: string;
}
export const getHomePages = (store: Store): DocHomePagesPath[] => {
const { pages = {} } = store?.config || {};
@@ -66,12 +69,13 @@ export const getHomePages = (store: Store): DocHomePagesPath[] => {
);
}) ||
docs.find(key => (store.docs[key].type || defDocType) === type);
- const docStories: string[] =
- docId && store.docs[docId] ? store.docs[docId].stories || [] : [];
+ const doc = docId ? store.docs[docId] : undefined;
+ const docStories: string[] = doc?.stories || [];
const storyId: string | undefined = docStories.length
? docStories[0]
: undefined;
return {
+ lastModified: dateToLocalString(doc?.dateModified),
type,
path,
docId,
@@ -129,6 +133,7 @@ export const getUniquesByField = (
export interface DocPagesPath {
type: DocType;
path: string;
+ lastModified?: string;
docId?: string | null;
storyId?: string | null;
category?: string | null;
@@ -160,6 +165,7 @@ export const getDocPages = (store: Store): DocPagesPath[] => {
stories.forEach((storyId?: string) => {
const path = getStoryPath(storyId, doc, store, route);
docPaths.push({
+ lastModified: dateToLocalString(doc.dateModified),
path,
type: docType,
activeTab: route,
diff --git a/core/store/src/serialization/sitemap.ts b/core/store/src/serialization/sitemap.ts
index 6ce4b8013..d97f3f442 100644
--- a/core/store/src/serialization/sitemap.ts
+++ b/core/store/src/serialization/sitemap.ts
@@ -9,26 +9,44 @@ import {
export const getSiteMap = (store: Store): string => {
const config = store.config.siteMap;
- const pages: { path?: string; priority: number }[] = [];
+ const pages: {
+ path?: string;
+ priority: number;
+ lastModified?: string;
+ }[] = [];
//home page
- const { path } = getIndexPage(store) || {};
- pages.push({ path, priority: config?.pages?.home.priority || 1 });
+ const { path, lastModified } = getIndexPage(store) || {};
+ pages.push({
+ path,
+ priority: config?.pages?.home.priority || 1,
+ lastModified,
+ });
const homePages = getHomePages(store);
- homePages.forEach(({ path }: DocHomePagesPath) => {
- pages.push({ path, priority: config?.pages?.index.priority || 1 });
+ homePages.forEach(({ path, lastModified }: DocHomePagesPath) => {
+ pages.push({
+ path,
+ priority: config?.pages?.index.priority || 1,
+ lastModified,
+ });
});
const docPages = getDocPages(store);
- docPages.forEach(({ path }: DocPagesPath) => {
- pages.push({ path, priority: config?.pages?.doc.priority || 1 });
+ docPages.forEach(({ path, lastModified }: DocPagesPath) => {
+ pages.push({
+ path,
+ priority: config?.pages?.doc.priority || 1,
+ lastModified,
+ });
});
const sitemap = `
${pages
.map(
- ({ path, priority }) =>
- ` ${path}daily ${priority} `,
+ ({ path, priority, lastModified }) =>
+ `${path}${
+ lastModified ? `${lastModified}` : ''
+ }daily${priority}`,
)
.join('\n')}
diff --git a/core/store/src/types.ts b/core/store/src/types.ts
index 788e53625..7f6ceddc1 100644
--- a/core/store/src/types.ts
+++ b/core/store/src/types.ts
@@ -14,12 +14,14 @@ export interface DocPageInfo {
docId?: string;
storyId?: string;
category?: string;
+ lastModified?: string;
}
export interface HomePageInfo {
type: string;
docId?: string;
storyId?: string;
path: string;
+ lastModified?: string;
}
export interface StoryStore {
diff --git a/integrations/gatsby-theme-stories/package.json b/integrations/gatsby-theme-stories/package.json
index a02ebe55b..c26f10c9b 100644
--- a/integrations/gatsby-theme-stories/package.json
+++ b/integrations/gatsby-theme-stories/package.json
@@ -52,6 +52,7 @@
"theme-ui": "^0.4.0-rc.1"
},
"devDependencies": {
+ "@component-controls/logger": "^1.22.0",
"@component-controls/ts-markdown-docs": "^1.21.0",
"@types/react": "^16.9.34",
"eslint-plugin-react-hooks": "^4.1.2",
diff --git a/integrations/gatsby-theme-stories/src/gatsby-node.ts b/integrations/gatsby-theme-stories/src/gatsby-node.ts
index 713c3bb44..db2111721 100644
--- a/integrations/gatsby-theme-stories/src/gatsby-node.ts
+++ b/integrations/gatsby-theme-stories/src/gatsby-node.ts
@@ -1,5 +1,6 @@
import fs from 'fs';
import sysPath from 'path';
+import { log } from '@component-controls/logger';
import {
compile,
watch,
@@ -104,11 +105,11 @@ export const createPagesStatefully = async (
);
if (process.env.NODE_ENV === 'production' && store.config.siteMap) {
const sitemap = getSiteMap(store);
- const sitemapname = sysPath.resolve(
- process.cwd(),
- store.config.siteMap.outputFolder,
- 'sitemap.xml',
- );
+ const staticFolder =
+ config.staticFolder ||
+ sysPath.join(process.cwd(), 'public', 'static');
+ const sitemapname = sysPath.resolve(staticFolder, 'sitemap.xml');
+ log('creating sitemap', sitemapname);
fs.writeFileSync(sitemapname, sitemap, 'utf8');
}
}
diff --git a/integrations/nextjs-plugin/package.json b/integrations/nextjs-plugin/package.json
index b69f0e181..6098bf13c 100644
--- a/integrations/nextjs-plugin/package.json
+++ b/integrations/nextjs-plugin/package.json
@@ -37,12 +37,14 @@
"license": "MIT",
"dependencies": {
"@component-controls/app": "^1.32.2",
+
"@component-controls/webpack-compile": "^1.32.2",
"@component-controls/webpack-configs": "^1.32.2",
"next": "^9.5.0"
},
"devDependencies": {
"@component-controls/ts-markdown-docs": "^1.21.0",
+ "@component-controls/logger": "^1.22.0",
"typescript": "^3.8.3"
},
"publishConfig": {
diff --git a/integrations/nextjs-plugin/src/build.ts b/integrations/nextjs-plugin/src/build.ts
index 9d6fef979..a8e8ca919 100644
--- a/integrations/nextjs-plugin/src/build.ts
+++ b/integrations/nextjs-plugin/src/build.ts
@@ -5,6 +5,7 @@ import {
watch,
CompilerCallbackFn,
} from '@component-controls/webpack-compile';
+import { log } from '@component-controls/logger';
import {
CompileProps,
defaultCompileProps,
@@ -48,10 +49,10 @@ module.exports = ({
if (process.env.NODE_ENV === 'production' && store.config.siteMap) {
const sitemap = getSiteMap(store);
const sitemapname = path.resolve(
- store.config.siteMap.outputFolder,
- './',
+ config.staticFolder as string,
'sitemap.xml',
);
+ log('creating sitemap', sitemapname);
fs.writeFileSync(sitemapname, sitemap, 'utf8');
}
}
diff --git a/ui/app/src/SEO/SEO.tsx b/ui/app/src/SEO/SEO.tsx
index df26510a3..c53b825fa 100644
--- a/ui/app/src/SEO/SEO.tsx
+++ b/ui/app/src/SEO/SEO.tsx
@@ -50,7 +50,7 @@ export const SEO = ({
{seo.image && }
{siteMap && (
-
+
)}