Skip to content

Commit

Permalink
fix: update file paths creation
Browse files Browse the repository at this point in the history
  • Loading branch information
reymon359 committed Aug 17, 2021
1 parent ec66d40 commit 316280b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "collman",
"version": "1.0.5",
"version": "1.0.6",
"description": "easily manage and display agnostic collections",
"main": "./bin/index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/addDocsify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getSidebarFileContent = async (collection: Collection) => {
const classificationValuesUnorderedList = []
classificationValuesUnorderedList.push({ link: { title: 'All', source: `${urlifyString(classification.name)}/index.md` } })
classification.values.sort().forEach(value => {
classificationValuesUnorderedList.push({ link: { title: value, source: `../${urlifyString(classification.name)}/${urlifyString(value)}.md` } })
classificationValuesUnorderedList.push({ link: { title: value, source: `./${urlifyString(classification.name)}/${urlifyString(value)}.md` } })
})
classificationUnorderedList.push({ ul: sortUnorderedListOfLinks(classificationValuesUnorderedList) })
mainUnorderedList.push({ ul: classificationUnorderedList })
Expand Down
8 changes: 4 additions & 4 deletions src/saveCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ export const getItemIndexFileContent = async (item:Item) => {
const itemClassifications: string[] = []
if (item.classifications.length > 0) {
item.classifications.forEach((classification, i) => {
itemClassifications[i] = `[${classification.name}:](../${urlifyString(classification.name)}/index.md)`
itemClassifications[i] = `[${classification.name}:](${urlifyString(classification.name)}/index.md)`

classification.values.sort().forEach((value) => {
itemClassifications[i] += ` [${value}](../${urlifyString(classification.name)}/${urlifyString(value)}.md)`
itemClassifications[i] += ` [${value}](${urlifyString(classification.name)}/${urlifyString(value)}.md)`
})
})
}
Expand Down Expand Up @@ -76,7 +76,7 @@ export const getClassificationValueFileContent = async (classificationValue:stri
if (itemClassification.name === classification.name) {
// If the items has values in that classification and includes the value
if (itemClassification.values.length > 0 && itemClassification.values.includes(classificationValue)) {
listOfItemWithValue.push({ link: { title: item.name, source: `../${urlifyString(item.name)}/index.md` } })
listOfItemWithValue.push({ link: { title: item.name, source: `${urlifyString(item.name)}/index.md` } })
}
}
})
Expand All @@ -93,7 +93,7 @@ export const getClassificationIndexFileContent = async (classification:Classific
classificationIndexContent.push({ h1: classification.name })

for (const classificationValue of classification.values) {
listOfValues.push({ link: { title: classificationValue, source: `../${urlifyString(classification.name)}/${urlifyString(classificationValue)}.md` } })
listOfValues.push({ link: { title: classificationValue, source: `/${urlifyString(classification.name)}/${urlifyString(classificationValue)}.md` } })
}

classificationIndexContent.push({ ul: sortUnorderedListOfLinks(listOfValues) })
Expand Down
2 changes: 1 addition & 1 deletion src/test/addDocsify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Add Docsify', () => {
]
}
}
const mockedSidebarFileContent = '\n - Content: items\n - [Apple](Apple/index.md)\n \n - [Orange](Orange/index.md)\n \n - [Watermelon](Watermelon/index.md)\n \n \n\n\n - Color\n - [All](Color/index.md)\n \n - [Green](../Color/Green.md)\n \n - [Orange](../Color/Orange.md)\n \n - [Red](../Color/Red.md)\n \n - [Yellow](../Color/Yellow.md)\n \n \n\n\n - Size\n - [All](Size/index.md)\n \n - [Big](../Size/Big.md)\n \n - [Medium](../Size/Medium.md)\n \n \n'
const mockedSidebarFileContent = '\n - Content: items\n - [Apple](Apple/index.md)\n \n - [Orange](Orange/index.md)\n \n - [Watermelon](Watermelon/index.md)\n \n \n\n\n - Color\n - [All](Color/index.md)\n \n - [Green](./Color/Green.md)\n \n - [Orange](./Color/Orange.md)\n \n - [Red](./Color/Red.md)\n \n - [Yellow](./Color/Yellow.md)\n \n \n\n\n - Size\n - [All](Size/index.md)\n \n - [Big](./Size/Big.md)\n \n - [Medium](./Size/Medium.md)\n \n \n'

const sidebarFileContent = await getSidebarFileContent(mockedCollection)

Expand Down
6 changes: 3 additions & 3 deletions src/test/saveCollection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Save collection', () => {
{ name: 'Size', values: ['Medium'] }
]
}
const mockedItemIndexFileContent = 'Apples are **amazing.**<hr/><br/>[Color:](../Color/index.md) [Green](../Color/Green.md) [Red](../Color/Red.md) [Yellow](../Color/Yellow.md)<br/>[Size:](../Size/index.md) [Medium](../Size/Medium.md)'
const mockedItemIndexFileContent = 'Apples are **amazing.**<hr/><br/>[Color:](Color/index.md) [Green](Color/Green.md) [Red](Color/Red.md) [Yellow](Color/Yellow.md)<br/>[Size:](Size/index.md) [Medium](Size/Medium.md)'

const itemIndexFileContent = await getItemIndexFileContent(mockedItem)

Expand Down Expand Up @@ -108,7 +108,7 @@ describe('Save collection', () => {
}
}
const mockedClassification = { name: 'Color', values: ['Green', 'Orange', 'Red', 'Yellow'] }
const mockedClassificationValueFileContent = '# Green\n\n\n - [Apple](../Apple/index.md)\n \n - [Watermelon](../Watermelon/index.md)\n \n'
const mockedClassificationValueFileContent = '# Green\n\n\n - [Apple](Apple/index.md)\n \n - [Watermelon](Watermelon/index.md)\n \n'

const classificationValueFileContent = await getClassificationValueFileContent(mockedClassificationValue, mockedCollection, mockedClassification)

Expand All @@ -117,7 +117,7 @@ describe('Save collection', () => {

it('Gets the Classification index file content', async () => {
const mockedClassification = { name: 'Color', values: ['Green', 'Orange', 'Red', 'Yellow'] }
const mockedClassificationIndexFileContent = '# Color\n\n\n - [Green](../Color/Green.md)\n \n - [Orange](../Color/Orange.md)\n \n - [Red](../Color/Red.md)\n \n - [Yellow](../Color/Yellow.md)\n \n'
const mockedClassificationIndexFileContent = '# Color\n\n\n - [Green](/Color/Green.md)\n \n - [Orange](/Color/Orange.md)\n \n - [Red](/Color/Red.md)\n \n - [Yellow](/Color/Yellow.md)\n \n'

const classificationIndexFileContent = await getClassificationIndexFileContent(mockedClassification)

Expand Down

0 comments on commit 316280b

Please sign in to comment.