Skip to content

Commit

Permalink
Add filter index by condition arg "--no-index"
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikage777 committed Dec 28, 2022
1 parent e3c99ca commit 3748ac9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
13 changes: 12 additions & 1 deletion next.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@ const nextConfig = withBundleAnalyzer({
),
);

module.exports = nextConfig;
module.exports = {
...nextConfig,
async rewrites() {
return [
{
source: '/icons/:icon',
destination: 'https://redneckz.github.io/wildless-cms-uni-blocks/icons/:icon',
basePath: false,
},
];
},
};
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import generate from './generate.js';

const rmrf = promisify(rimraf);

export default async function build(isMobile) {
export default async function build(isMobile, noIndex) {
await rmrf('./.next');
await generate(isMobile);
await generate(isMobile, noIndex);
execSync('npx next build', { stdio: 'inherit' });
execSync(`npx next export -o ./${BUILD_DIR}/${isMobile ? 'mobile/' : ''}`, { stdio: 'inherit' });
}
8 changes: 6 additions & 2 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { generatePage } from './generatePage.js';
const mkdir = promisify(fs.mkdir);
const writeFile = promisify(fs.writeFile);

export default async function generate(isMobile) {
export default async function generate(isMobile, noIndex) {
try {
await simpleGit().clean(
[CleanOptions.RECURSIVE, CleanOptions.FORCE, CleanOptions.IGNORED_ONLY],
Expand All @@ -25,7 +25,11 @@ export default async function generate(isMobile) {
});

const pagePathsList = await contentPageRepository.listAllContentPages();
for (const pagePath of pagePathsList.filter((pagePath) => !pagePath.includes('/index'))) {
const pagePathsFilteredList = noIndex
? pagePathsList.filter((pagePath) => !pagePath.includes('/index'))
: pagePathsList;

for (const pagePath of pagePathsFilteredList) {
const page = await contentPageRepository.readPage(pagePath);
const generatedPagePath = toGeneratedPagePath(pagePath);

Expand Down
6 changes: 1 addition & 5 deletions scripts/prebuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ export default async function prebuild() {
// Do nothing
}

await copy([`${CONTENT_DIR}/manifest.json`, `${CONTENT_DIR}/wcms-resources/**/*`, PUBLIC_DIR], 1);
await copy(
['./node_modules/@redneckz/wildless-cms-uni-blocks/cosmos-static/icons/**/*', PUBLIC_DIR],
4,
);
await copy([`${CONTENT_DIR}/wcms-resources/**/*`, PUBLIC_DIR], 1);
}
2 changes: 1 addition & 1 deletion wcms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ import process from 'process';
const [, , cmd] = process.argv;

const task = await import(`./scripts/${cmd}.js`);
await task.default(process.argv.includes('--mobile'));
await task.default(process.argv.includes('--mobile'), process.argv.includes('--no-index'));

0 comments on commit 3748ac9

Please sign in to comment.