Obsidian Random Facts
Obsidian Random Facts
Random Space Facts in Obsidian with DataviewJS
Add some excitement to your Obsidian vault by displaying a random fact each time you view your note. Using DataviewJS, you can create a dynamic block that shows a random space fact whenever you open your note.
Hereβs the code for the Random Space Facts:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
```dataviewjs
// Space Facts Array
const spaceFacts = [
"A day on Venus is longer than a year on Venus.",
"There are more stars in the universe than grains of sand on all the Earth's beaches.",
"Neutron stars are so dense that a teaspoon of their material would weigh about 6 billion tons.",
"The largest volcano in the solar system, Olympus Mons, is on Mars.",
"A solar flare can release as much energy as the Sun does in 24 hours.",
"Saturn's moon Titan has lakes and rivers of liquid methane.",
"Jupiter's Great Red Spot is a massive storm that's been raging for over 350 years.",
"The first living creatures to orbit the Earth were fruit flies.",
"A full NASA space suit costs about $12 million.",
"The largest known star, UY Scuti, could fit 1,700 of our suns inside it.",
"A day on Mercury is twice as long as its year.",
"The Hubble Space Telescope has taken some of the most detailed images of deep space.",
"The Milky Way galaxy is on a collision course with the Andromeda galaxy.",
"Astronauts' height can increase by up to 2 inches in space due to the lack of gravity.",
"Saturn's rings are made up of billions of ice and rock particles.",
"There is a planet made of diamond, 55 Cancri e, located 40 light years from Earth.",
"Black holes are regions of space where gravity is so strong that not even light can escape.",
"The first human to walk on the Moon, Neil Armstrong, left behind a footprint that will last millions of years.",
"The largest moon of Neptune, Triton, orbits the planet in the opposite direction of the planet's rotation.",
"The Sun is about 109 times the size of Earth."
];
// Get a random space fact
const randomFact = spaceFacts[Math.floor(Math.random() * spaceFacts.length)];
// Display the random space fact
const container = this.container;
container.createEl("h1", { text: `π Random Space Fact π ` });
container.createEl("p", { text: randomFact });
Random Space Facts Script Explanation
This script displays a random space fact each time you open your Obsidian note, adding a fun and dynamic element to your vault. It will show one fact at a time, and you can refresh the page to get a new one.
How It Works:
- Create the Facts Array: The script contains an array of space-related facts.
- Random Fact Selection: It selects a random fact from the array each time the note is viewed.
- Display the Fact: The script creates two elements in your Obsidian note β a heading (
h1
) and a paragraph (p
) β to display the randomly selected space fact.
Why Use This?
- Ever-changing Content: Each time you view the note, a new random space fact is displayed, keeping things interesting.
- Educational and Fun: A great way to add some learning and fun to your notes, all while exploring space-related trivia.
- Customization: You can easily replace the facts in the array or adapt the script to show facts about any other topic you prefer.
Give it a try and enjoy your dynamic facts! ππ
This post is licensed under
CC BY 4.0
by the author.