Skip to content

Commit 964eaa8

Browse files
committed
thumbnail subdirs and custom IDs
1 parent 36e66a5 commit 964eaa8

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

index.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ def update_meta(meta, new_meta):
2424

2525
# TODO this is just for a unique id for each document. maybe make it stable?
2626
ID = it.count(0)
27+
all_ids = set()
2728
def init_doc(docs, prefix):
2829
for doc in docs:
2930
doc['src'] = os.path.join(prefix, doc['src'])
30-
assert 'id' not in doc
31-
doc['id'] = 'doc-{}'.format(next(ID))
31+
if 'thumbnail' in doc:
32+
doc['thumbnail'] = os.path.join(prefix, doc['thumbnail'])
33+
if 'id' in doc:
34+
assert doc['id'] not in all_ids
35+
all_ids.add(doc['id'])
36+
else:
37+
newid = 'doc-{}'.format(next(ID))
38+
assert newid not in all_ids
39+
all_ids.add(newid)
40+
doc['id'] = newid
3241

3342
# prefix is the path to prefix
3443
def resolve_references(meta, docs, prefix=''):

index.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ tags:
2525
descriptions: |
2626
Quick introduction to CoCalc interface and basic functionalities.
2727
---
28+
id: 'bayes-for-hackers'
2829
title: "Bayesian Methods for Hackers"
2930
src: bayesian-methods-for-hackers/
3031
thumbnail: thumbs/bayesian.png

0 commit comments

Comments
 (0)