-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show titles index with DDC notation in K10plus
Related to #26 (show total number). Shows up to 10 titles in citation format.
- Loading branch information
Showing
2 changed files
with
75 additions
and
1 deletion.
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
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,71 @@ | ||
<template> | ||
<div v-if="titles.length"> | ||
<h5>Titles in K10plus catalog</h5> | ||
<ul style="list-style-type: none; padding-left: 0"> | ||
<li v-for="title of titles"> | ||
<a | ||
:href="`https://opac.k10plus.de/DB=2.299/PPNSET?PPN=${title.ppn}`" | ||
target="k10plus" | ||
title="show in K10plus catalog"> | ||
📚 | ||
</a> | ||
<span v-html="title.citation" /> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { watch, ref, computed } from "vue" | ||
export default { | ||
props: { | ||
notation: { | ||
type: String, | ||
default: "", | ||
}, | ||
language: { | ||
type: String, | ||
default: "en", | ||
}, | ||
citationstyle: { | ||
type: String, | ||
default: "ieee", | ||
} | ||
}, | ||
setup(props) { | ||
const titles = ref({}) | ||
const fetchTitles = async () => { | ||
const { notation, language, citationstyle } = props | ||
if (!notation) { | ||
titles.value = [] | ||
return | ||
} | ||
try { | ||
const url = `http://ws.gbv.de/suggest/csl2?query=pica.ddc=${notation}&citationstyle=${citationstyle}&language=${language}&highlight=1` | ||
const response = await fetch(url) | ||
const data = await response.json() | ||
titles.value = data[1].map((title, i) => { | ||
const ppn = data[3][i].replace(/^.+:/,'') | ||
return { citation: title, ppn } | ||
}) | ||
} catch (error) { | ||
titles.value = [] | ||
} | ||
} | ||
fetchTitles() | ||
watch( | ||
() => props, | ||
async () => { await fetchTitles() }, | ||
{ deep: true }, | ||
) | ||
return { | ||
fetchTitles, | ||
titles | ||
} | ||
} | ||
} | ||
</script> |