Răsfoiți Sursa

create attachTitleHeader util

Shun Miyazawa 4 ani în urmă
părinte
comite
31a8a15db0

+ 1 - 1
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -269,7 +269,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
 
     const isEnabledAttachTitleHeader = props.appContainer.getConfig().isEnabledAttachTitleHeader;
     if (isEnabledAttachTitleHeader) {
-      initialBody = `# ${newPagePath}`;
+      initialBody = pathUtils.attachTitleHeader(newPagePath);
     }
 
     if (isCreatable) {

+ 4 - 0
packages/app/src/server/util/swigFunctions.js

@@ -171,6 +171,10 @@ module.exports = function(crowi, req, locals) {
     });
   };
 
+  locals.attachTitleHeader = function(path) {
+    return pathUtils.attachTitleHeader(path);
+  };
+
   locals.css = {
     grant(pageData) {
       if (!pageData) {

+ 2 - 2
packages/app/src/server/views/widget/not_found_content.html

@@ -17,9 +17,9 @@
 
     {% if getConfig('crowi', 'customize:isEnabledAttachTitleHeader') %}
     {% if template %}
-    <script type="text/template" id="raw-text-original"># {{ path | path2name | preventXss }}&NewLine;{{ template }}</script>
+    <script type="text/template" id="raw-text-original"># {{ attachTitleHeader(path | path2name | preventXss) }}&NewLine;{{ template }}</script>
     {% else %}
-    <script type="text/template" id="raw-text-original"># {{ path | path2name | preventXss }}</script>
+    <script type="text/template" id="raw-text-original">{{ attachTitleHeader(path | path2name | preventXss) }}</script>
     {% endif %}
     {% else %}
     {% if template %}

+ 4 - 0
packages/core/src/utils/path-utils.js

@@ -106,3 +106,7 @@ export function normalizePath(path) {
   }
   return `/${match[3]}`;
 }
+
+export function attachTitleHeader(path) {
+  return `# ${path}`;
+}