-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a69d1ca
commit b990290
Showing
4 changed files
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
cff-version: 1.2.0 | ||
message: "If you use this software, please cite it as below." | ||
authors: | ||
- family-names: "{author}" # Replace with last name | ||
given-names: "{author}" # Replace with first name | ||
name-particle: "{author}" # Replace with name particle(s) | ||
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with ORCID | ||
# More authors can be listed here in the same format as above | ||
contact: # Contact person for this extension | ||
- family-names: "{author}" | ||
given-names: "{author}" | ||
email: "{email}" # Replace with contact person's email | ||
orcid: "https://orcid.org/0000-0000-0000-0000" # Replace with contact person's ORCID | ||
title: "{globalName}" | ||
version: 0.0.0 | ||
doi: 10.5281/zenodo.1234 # Replace with DOI | ||
date-released: 2000-01-01 | ||
url: "{softwareUrl}" # Replace with URL to this extension | ||
|
||
# If you wish to cite a paper on this extension instead, you can use the following template: | ||
preferred-citation: | ||
authors: | ||
- family-names: "{author}" | ||
given-names: "{author}" | ||
name-particle: "{author}" | ||
orcid: "https://orcid.org/0000-0000-0000-0000" | ||
# More authors can be listed here in the same format as above | ||
date-published: 2023-05-11 | ||
doi: 10.21105/joss.12345 | ||
issn: 1234-5678 | ||
issue: 01 | ||
journal: Journal for Open Source Software | ||
publisher: | ||
name: Open Journals | ||
start: 0001 | ||
title: "{title}" | ||
type: article # Other options include: book, pamphlet, conference-paper... | ||
url: "{linkToPublicationInJournal}" | ||
volume: 1 | ||
|
||
# More information on the preffered-citation CFF format can be found at https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files#citing-something-other-than-software |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import "@citation-js/plugin-software-formats"; | ||
|
||
import fs from "node:fs"; | ||
import { fileURLToPath } from "node:url"; | ||
import path from "path"; | ||
|
||
import { Cite } from "@citation-js/core"; | ||
|
||
const srcDir = path.dirname(fileURLToPath(import.meta.url)); | ||
const indexFilePath = path.join(srcDir, "index.ts"); | ||
|
||
const updateCitations = (indexFilePath, apaCitation, bibtexCitation) => { | ||
let fileContent = fs.readFileSync(indexFilePath, "utf-8"); | ||
fileContent = fileContent.replace(/`{apaJson}`/g, apaCitation); | ||
fileContent = fileContent.replace(/`{bibtexJson}`/g, bibtexCitation); | ||
fs.writeFileSync(indexFilePath, fileContent, "utf-8"); | ||
}; | ||
|
||
function cffToJson() { | ||
const templateDir = path.dirname(srcDir); | ||
const cffFilePath = path.join(templateDir, "CITATION.cff"); | ||
let cffCitation = fs.readFileSync(cffFilePath, "utf-8").toString(); | ||
Cite.async(cffCitation).then((data) => { | ||
const apaJson = JSON.stringify( | ||
data.format("data", { | ||
format: "object", | ||
template: "citation-apa", | ||
lang: "en-US", | ||
}), | ||
null, | ||
2 | ||
); | ||
const bibtexJson = JSON.stringify( | ||
data.format("data", { | ||
format: "object", | ||
template: "citation-bibtex", | ||
lang: "en-US", | ||
}), | ||
null, | ||
2 | ||
); | ||
updateCitations(indexFilePath, apaJson, bibtexJson); | ||
}); | ||
} | ||
|
||
export { cffToJson, updateCitations }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters