mirror of
https://github.com/em-squared/5e-drs.git
synced 2025-12-16 23:20:14 +00:00
Cleaning id
This commit is contained in:
parent
1aa2a16289
commit
952d9b3a45
1 changed files with 8 additions and 5 deletions
|
|
@ -10,7 +10,7 @@ from meilisearch import Client
|
||||||
|
|
||||||
def pages():
|
def pages():
|
||||||
"return all pages"
|
"return all pages"
|
||||||
for readme in Path('.').glob('**/README.md'):
|
for readme in Path('../..').glob('**/README.md'):
|
||||||
if readme == Path("README.md"): # it's the home
|
if readme == Path("README.md"): # it's the home
|
||||||
continue
|
continue
|
||||||
with open(readme, 'r') as file:
|
with open(readme, 'r') as file:
|
||||||
|
|
@ -34,7 +34,8 @@ def pages():
|
||||||
head = yaml.safe_load(head)
|
head = yaml.safe_load(head)
|
||||||
body.seek(0)
|
body.seek(0)
|
||||||
txt = markdown(body.read())
|
txt = markdown(body.read())
|
||||||
yield str(readme), head['title'], txt
|
# removing ../../, README.md and replace / with _
|
||||||
|
yield str(readme)[11:-10].replace("/", "_"), head['title'], txt
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
@ -43,12 +44,14 @@ if __name__ == "__main__":
|
||||||
idx = client.get_index('pages')
|
idx = client.get_index('pages')
|
||||||
except Exception:
|
except Exception:
|
||||||
client.create_index('pages', dict(primaryKey='path'))
|
client.create_index('pages', dict(primaryKey='path'))
|
||||||
print(idx)
|
print("the index is created")
|
||||||
|
else:
|
||||||
|
print("the index is already here")
|
||||||
|
|
||||||
for path, title, body in pages():
|
for path, title, body in pages():
|
||||||
client.index('pages').add_documents([{
|
client.index('pages').add_documents([{
|
||||||
'path': path,
|
'path': path,
|
||||||
'title': title,
|
'title': title,
|
||||||
'body': body,
|
'body': body,
|
||||||
}])
|
}])
|
||||||
print(title)
|
print(title, path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue