Gmeek
Gmeek copied to clipboard
上传css、js等等到docs目录,但是会被删。
试着将代码改成下面这样,能保留自行上传的文件或文件夹,但是可能维护不方便,因为指定了只处理固定的文件或文件夹, 关于操作文件夹的部分。
def __init__(self, options):
self.options = options
self.root_dir = 'docs/'
self.post_folder = 'post/'
self.backup_dir = 'backup/'
self.post_dir = self.root_dir + self.post_folder
user = Github(self.options.github_token)
self.repo = self.get_repo(user, options.repo_name)
self.feed = FeedGenerator()
self.oldFeedString = ''
self.labelColorDict = json.loads('{}')
for label in self.repo.get_labels():
self.labelColorDict[label.name] = '#' + label.color
print(self.labelColorDict)
self.defaultConfig()
def cleanFile(self):
workspace_path = os.environ.get('GITHUB_WORKSPACE')
if os.path.exists(workspace_path + "/" + self.root_dir):
self.clean_root_dir(workspace_path + "/" + self.root_dir)
if os.path.exists(self.root_dir):
self.clean_root_dir(self.root_dir)
os.makedirs(self.post_dir, exist_ok=True)
def clean_root_dir(self, root_dir):
delete_files = {'index.html', 'postList.json', 'rss.xml', 'tag.html'}
delete_dirs = {'post'}
for item in os.listdir(root_dir):
item_path = os.path.join(root_dir, item)
if item in delete_files:
if os.path.isfile(item_path):
os.remove(item_path)
elif item in delete_dirs:
if os.path.isdir(item_path):
shutil.rmtree(item_path)
为什么要上传到docs文件能?每次全局生成都会清空docs文件夹。你如果只是想添加一些自定义的CSS和JS文件,那么,上传到仓库的其他位置,然后用jsdelivr就行。例如我在仓库的根目录上传了一张图片:
https://cdn.jsdelivr.net/gh/Meekdai/meekdai.github.io/logo64.jpg
嗯……因为gh pages有些人可能访问不了,于是用cf pages绑定存储库发布了, 部署设置了构建输出目录为“/docs”。
了解了,后续我看看在docs文件夹内增加一个文件夹,用于存储用户固定的文件。
@molikai-work 已经添加static文件夹功能 更新日志:https://blog.meekdai.com/post/Gmeek-geng-xin-ri-zhi.html
您好,请问能不能实现可以设置添加robots.txt文件。
您好,请问能不能实现可以设置添加robots.txt文件。
@wwwgitcodetop 可以的,请参考 https://blog.meekdai.com/post/%E3%80%90Gmeek-jin-jie-%E3%80%91static-wen-jian-jia-shi-yong.html