Skip to content

Commit

Permalink
fix: truncate filename length to 100
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed May 23, 2023
1 parent 03c01a8 commit 12ebcf7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@semantic-release/git": "^10.0.1",
"@types/diff-match-patch": "^1.0.32",
"@types/jest": "^29.4.0",
"@types/lodash": "^4.14.194",
"@types/luxon": "^3.1.0",
"@types/markdown-escape": "^1.1.0",
"@types/mustache": "^4.2.2",
Expand All @@ -44,6 +45,7 @@
},
"dependencies": {
"diff-match-patch": "^1.0.5",
"lodash": "^4.17.21",
"luxon": "^3.1.1",
"markdown-escape": "^2.0.0",
"mustache": "^4.2.0",
Expand Down
9 changes: 7 additions & 2 deletions src/settings/template.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { truncate } from "lodash";
import Mustache from "mustache";
import { stringifyYaml } from "obsidian";
import { Article, HighlightType, PageType } from "../api";
Expand Down Expand Up @@ -124,10 +125,15 @@ export const renderFilename = (
folderDateFormat: string
) => {
const date = formatDate(article.savedAt, folderDateFormat);
return Mustache.render(filename, {
const renderedFilename = Mustache.render(filename, {
...article,
date,
});

// truncate the filename to 100 characters
return truncate(renderedFilename, {
length: 100,
});
};

export const renderAttachmentFolder = (
Expand Down Expand Up @@ -294,4 +300,3 @@ export const renderFolderName = (folder: string, folderDate: string) => {
export const preParseTemplate = (template: string) => {
Mustache.parse(template);
};

0 comments on commit 12ebcf7

Please sign in to comment.