Truncate filenames to 255 characters
This commit is contained in:
parent
803602179d
commit
45c126ce80
1 changed files with 24 additions and 6 deletions
|
@ -431,7 +431,14 @@ async function generateGitDirectory(
|
||||||
articleId,
|
articleId,
|
||||||
)) as LegiArticle
|
)) as LegiArticle
|
||||||
const articleTitle = `Article ${article.META.META_SPEC.META_ARTICLE.NUM ?? articleId}`
|
const articleTitle = `Article ${article.META.META_SPEC.META_ARTICLE.NUM ?? articleId}`
|
||||||
const articleFilename = `${slugify(articleTitle, "_")}.md`
|
let articleSlug = slugify(articleTitle, "_")
|
||||||
|
if (articleSlug.length > 252) {
|
||||||
|
articleSlug = articleSlug.slice(0, 251)
|
||||||
|
if (articleSlug.at(-1) !== "_") {
|
||||||
|
articleSlug += "_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const articleFilename = `${articleSlug}.md`
|
||||||
const articleRepositoryRelativeFilePath = path.join(
|
const articleRepositoryRelativeFilePath = path.join(
|
||||||
repositoryRelativeDir,
|
repositoryRelativeDir,
|
||||||
articleFilename,
|
articleFilename,
|
||||||
|
@ -482,7 +489,14 @@ async function generateGitDirectory(
|
||||||
sectionTaId,
|
sectionTaId,
|
||||||
)) as LegiSectionTa
|
)) as LegiSectionTa
|
||||||
const sectionTaTitle = sectionTa.TITRE_TA ?? sectionTaId
|
const sectionTaTitle = sectionTa.TITRE_TA ?? sectionTaId
|
||||||
const sectionTaDirName = slugify(sectionTaTitle.split(":")[0].trim(), "_")
|
let sectionTaSlug = slugify(sectionTaTitle.split(":")[0].trim(), "_")
|
||||||
|
if (sectionTaSlug.length > 255) {
|
||||||
|
sectionTaSlug = sectionTaSlug.slice(0, 254)
|
||||||
|
if (sectionTaSlug.at(-1) !== "_") {
|
||||||
|
sectionTaSlug += "_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const sectionTaDirName = sectionTaSlug
|
||||||
const sectionTaRepositoryRelativeDir = path.join(
|
const sectionTaRepositoryRelativeDir = path.join(
|
||||||
repositoryRelativeDir,
|
repositoryRelativeDir,
|
||||||
sectionTaDirName,
|
sectionTaDirName,
|
||||||
|
@ -539,10 +553,14 @@ async function generateGitDirectory(
|
||||||
sectionTaId,
|
sectionTaId,
|
||||||
)) as LegiSectionTa
|
)) as LegiSectionTa
|
||||||
const sectionTaTitle = sectionTa.TITRE_TA ?? sectionTaId
|
const sectionTaTitle = sectionTa.TITRE_TA ?? sectionTaId
|
||||||
const sectionTaDirName = slugify(
|
let sectionTaSlug = slugify(sectionTaTitle.split(":")[0].trim(), "_")
|
||||||
sectionTaTitle.split(":")[0].trim(),
|
if (sectionTaSlug.length > 255) {
|
||||||
"_",
|
sectionTaSlug = sectionTaSlug.slice(0, 254)
|
||||||
)
|
if (sectionTaSlug.at(-1) !== "_") {
|
||||||
|
sectionTaSlug += "_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const sectionTaDirName = sectionTaSlug
|
||||||
const sectionTaRepositoryRelativeDir = path.join(
|
const sectionTaRepositoryRelativeDir = path.join(
|
||||||
repositoryRelativeDir,
|
repositoryRelativeDir,
|
||||||
sectionTaDirName,
|
sectionTaDirName,
|
||||||
|
|
Loading…
Reference in a new issue