Skip to content

Commit

Permalink
Merge pull request #2 from vincenzocaputo/develop
Browse files Browse the repository at this point in the history
Version 1.2.0
  • Loading branch information
vincenzocaputo authored Oct 27, 2024
2 parents ddf90ef + 4192876 commit ba7c47c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "metal-archives",
"name": "Metal Archives (Unofficial)",
"version": "1.1.0",
"version": "1.2.0",
"minAppVersion": "0.15.0",
"description": "Create notes about metal bands and album from Metal Archives",
"author": "Vincenzo Caputo",
Expand Down
32 changes: 21 additions & 11 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,16 @@ export default class MetalArchivesPlugin extends Plugin {
async renderAlbumNote(album: Album) {
const vaultBasePath = this.app.vault.adapter.basePath;

const albumsDir = `${vaultBasePath}/${this.settings.albumsPathLocation}/${album.band}`;
const bandFilename = album.band.replace(/[:\/]/g, " ");
const albumFilename = album.name.replace(/[:\/]/g, " ");
const albumsDir = `${vaultBasePath}/${this.settings.albumsPathLocation}/${bandFilename}`;

this.app.vault.adapter.exists(albumsDir).then( (r) => {
return this.app.vault.adapter.mkdir(this.settings.albumsPathLocation.toString());
}).then((r) => {
return this.app.vault.adapter.mkdir(`${this.settings.albumsPathLocation}/${album.band}`);
return this.app.vault.adapter.mkdir(`${this.settings.albumsPathLocation}/${bandFilename}`);
}).then((r) => {
const noteFilename = `${this.settings.albumsPathLocation}/${album.band}/${album.name}.md`;
const noteFilename = `${this.settings.albumsPathLocation}/${album.band}/${albumFilename}.md`;

let songsTable = ``;
for (const song of album.songs) {
Expand All @@ -180,6 +182,8 @@ format: ${album.format}
reference: ${album.url}
---
# ${album.name}
![cover|400x400](${album.cover})
## Songs
Expand Down Expand Up @@ -208,13 +212,14 @@ ${songsTable}
const vaultBasePath = this.app.vault.adapter.basePath;

const bandsDir = `${vaultBasePath}/${this.settings.bandsPathLocation}`;
const albumsDir = `${this.settings.albumsPathLocation}/${band.name}`;

const albumsDir = `${this.settings.albumsPathLocation}/${band.name.replace(/[:\/]/g," ")}`;

this.app.vault.adapter.exists(bandsDir).then( (r) => {
return this.app.vault.adapter.mkdir(this.settings.bandsPathLocation.toString());
}).then((r) => {

const noteFilename = `${this.settings.bandsPathLocation}/${band.name}.md`;
const noteFilename = `${this.settings.bandsPathLocation}/${band.name.replace(/[:\/]/g, " ")}.md`;

let tags = ``;
for (const tag of band.tags) {
Expand All @@ -227,13 +232,16 @@ ${songsTable}

let discogTable = ``;
for (const disc of band.discography) {
const albumDir = `${albumsDir}/${disc.discName}`
if ("Full-length" === disc.discType) {
discogTable += `|**[[${albumDir}\\|${disc.discName}]]**|${disc.discType}|${disc.discYear}|\n`;
} else {
discogTable += `|[[${disc.discName}]]|${disc.discType}|${disc.discYear}|\n`;
if (disc.discName.length > 0) {
const albumDir = `${albumsDir}/${disc.discName.replace(/[:\/]/g, " ")}`
if ("Full-length" === disc.discType) {
discogTable += `|**[[${albumDir}\\|${disc.discName}]]**|${disc.discType}|${disc.discYear}|\n`;
} else {
discogTable += `|[[${disc.discName}]]|${disc.discType}|${disc.discYear}|\n`;
}
}
}

const body = `---
Country: ${band.country}
Status: ${band.status}
Expand All @@ -246,9 +254,11 @@ Reference: ${band.url}
tags:
${tags}
---
# ${band.name}
${band.description.replace(/Compilation (a|A)ppearances:.*(?:\n.*)*/g, "")}
## Members
| | |
|Member name|Instrument|
|---|---|
${membersTable}
## Discography
Expand Down

0 comments on commit ba7c47c

Please sign in to comment.