Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hyperlink 在GitLab页面上发布Docusaurus站点时如何修复内部链接问题_Hyperlink_Gitlab Pages_Docusaurus - Fatal编程技术网

Hyperlink 在GitLab页面上发布Docusaurus站点时如何修复内部链接问题

Hyperlink 在GitLab页面上发布Docusaurus站点时如何修复内部链接问题,hyperlink,gitlab-pages,docusaurus,Hyperlink,Gitlab Pages,Docusaurus,在我的Docusaurus项目中,我的内部链接在本地环境中工作,但当我推到GitLab时,它们就不再工作了。它没有用新的文档标题替换原始文档标题,而是将其添加到url末尾(“”)。我查看了我的配置文件,但我不明白为什么会发生这种情况 我尝试更新页面前面的id,并确保它与sidebars.json文件中的id匹配。我还添加了customDocsPath,并在配置文件中将其设置为“docs/”,尽管这应该是默认设置 --- id: "process-designer-overview" title:

在我的Docusaurus项目中,我的内部链接在本地环境中工作,但当我推到GitLab时,它们就不再工作了。它没有用新的文档标题替换原始文档标题,而是将其添加到url末尾(“”)。我查看了我的配置文件,但我不明白为什么会发生这种情况

我尝试更新页面前面的id,并确保它与sidebars.json文件中的id匹配。我还添加了customDocsPath,并在配置文件中将其设置为“docs/”,尽管这应该是默认设置

---
id: "process-designer-overview"
title: "Process Designer Overview"
sidebar_label: "Overview"
---
# Process Designer

The Process Designer is a collaborative business process modeling and 
design workspace for the business processes, scenarios, roles and tasks 
that make up governed data processes.

Use the Process Designer to:

 - [Add a Category](add-a-category.html)
 - [Add a Process or Scenario](Add%20a%20Process%20or%20Scenario.html)
 - [Edit a Process or Scenario](Edit%20a%20Process%20or%20Scenario.html)

我更新了将括号中的AddaCategory链接添加到md扩展,但这破坏了我本地的链接,并且它在GitLab上仍然不起作用。我希望,当用户单击链接时,它会将url中的文档标题替换为新的文档标题(“”),但它只是将其固定在末尾(“”),因此链接会断开,因为该链接不是文档所在的位置。

我的链接有几个问题。首先,我使用Pandoc将这些文件从html转换为markdown,并没有添加前置内容,而是依赖文件名将文件连接到侧栏。这很好,除了几乎所有的文件名中都有空格,您可以在上面的代码示例中看到。这导致了真正的问题,所以我找到了一个Bash脚本,用下划线替换文件名中的所有空格,但现在我所有的链接都断了。我在代码编辑器中使用搜索和替换更新了文件中的所有链接,并将“%20”替换为“\ux”。我还需要将“.html”扩展名替换为“.md”,否则我的项目将无法在本地工作。同样,我在我的代码编辑器中通过搜索和替换实现了这一点

最后,我添加了前面的内容,因为我的边栏标题都用下划线表示。因为我正在处理90个文件,所以我不想手动执行此操作。我找了一会儿,找到了一个,并对它进行了调整,这样它将采用文件名并将其添加为id,第一个标题并将其添加为标题和侧边栏标签,因为它恰好适用于我们的项目。下面是我在网上找到的Bash脚本,如果感兴趣,可以将文件名中的空格转换为下划线:

find $1 -name "* *.md" -type f -print0 | \
  while read -d $'\0' f; do mv -v "$f" "${f// /_}"; done
如果其他任何人有类似的设置,并且不想用front matter更新大量文件,我将使用以下脚本:

# Given a file path as an argument
# 1. get the file name
# 2. prepend template string to the top of the source file
# 3. resave original source file

# command: find . -name "*.md" -print0 | xargs -0 -I file ./prepend.sh file

filepath="$1"
file_name=$("basename" -a "$filepath")

# Getting the file name (title)
md='.md'
title=${file_name%$md}
heading=$(grep -r "^# \b" ~/Documents/docs/$title.md)
heading1=${heading#*\#}

# Prepend front-matter to files
TEMPLATE="---
id: $title
title: $heading1
sidebar_label: $heading1
---
"
echo "$TEMPLATE" | cat - "$filepath" > temp && mv temp "$filepath"