如何取消发布gatsby页面而不删除它? [英] How to unpublish a gatsby page without deleting it?

查看:54
本文介绍了如何取消发布gatsby页面而不删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的静态网站上使用了一个盖茨比启动器,该启动器中包含的页面之一是带有所有UI元素的演示页面.

I used a Gatsby starter for my static site, and one of the pages included in that starter is a demo page with all of the UI elements.

我想保留该页面(以便可以从演示中复制和粘贴),但不想公开使用.如何在不删除文件的情况下取消发布"?

I want to keep the page (so I can copy and paste from the demo) but don't want to be publicly available. How do I "unpublish" without deleting the file?

是否有一种方法可以告诉gatsby-node.js在生成面向公众的网站时跳过该页面?

Is there a way to tell gatsby-node.js to skip that page when generating the public facing site?

推荐答案

有一堆 deletePage

如果页面为src/pages/demo.js,则会在创建过程中删除该页面.

If you have a page src/pages/demo.js, this will delete that page during creation.

// gatsby-node.js
exports.onCreatePage = async ({ page, actions: { deletePage } }) => {
    if (page.path.match(/^\/demo/)) {
      deletePage(page)
    }
}

这篇关于如何取消发布gatsby页面而不删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆