mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-12-16 23:20:14 +00:00
intégration des objets magiques + filtres
This commit is contained in:
parent
1330db17af
commit
d80cbc2600
315 changed files with 13824 additions and 2 deletions
39
import/import-items.js
Normal file
39
import/import-items.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
const fs = require('fs')
|
||||
const slugify = require('slugify')
|
||||
slugify.extend({"'": '-'})
|
||||
const items = require('./magic-items.json')
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
let filecontent = buildFileContent(items[i])
|
||||
let filename = slugify(items[i].header.title, {lower: true, strict: true})
|
||||
fs.writeFile("./_magicitems/" + filename + ".md", filecontent, function(err) {
|
||||
if(err) {
|
||||
return console.log(err);
|
||||
}
|
||||
console.log("Saved: " + filename +".md")
|
||||
})
|
||||
}
|
||||
|
||||
function buildFileContent(item) {
|
||||
let c = ''
|
||||
// Frontmatter
|
||||
c += '---\n'
|
||||
c += 'title: "' + item.header.title + '"\n'
|
||||
c += 'type: "' + item.header.magicitem.type + '"\n'
|
||||
if (item.header.magicitem.subtype) {
|
||||
c += 'subtype: "' + item.header.magicitem.subtype + '"\n'
|
||||
} else {
|
||||
c += 'subtype: false\n'
|
||||
}
|
||||
c += 'rarity: "' + item.header.magicitem.rarity + '"\n'
|
||||
if (item.header.magicitem.attunement) {
|
||||
c += 'attunement: "' + item.header.magicitem.attunement + '"\n'
|
||||
} else {
|
||||
c += 'attunement: false\n'
|
||||
}
|
||||
c += 'source: "' + item.header.taxonomy.source[0] + '"\n'
|
||||
c += '---\n'
|
||||
// Content
|
||||
c += item.content
|
||||
return c
|
||||
}
|
||||
9238
import/magic-items.json
Normal file
9238
import/magic-items.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue