Skip to content

Commit

Permalink
add rs file to test syntax highlighting, add tooltips to nav icons
Browse files Browse the repository at this point in the history
  • Loading branch information
jonnysmillie committed May 9, 2022
1 parent 14d3fdc commit 466459a
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 38 deletions.
24 changes: 24 additions & 0 deletions content/code-snippets/markdown.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;

fn main() {
// Create a path to the desired file
let path = Path::new("hello.txt");
let display = path.display();

// Open the path in read-only mode, returns `io::Result<File>`
let mut file = match File::open(&path) {
Err(why) => panic!("couldn't open {}: {}", display, why),
Ok(file) => file,
};

// Read the file contents into a string, returns `io::Result<usize>`
let mut s = String::new();
match file.read_to_string(&mut s) {
Err(why) => panic!("couldn't read {}: {}", display, why),
Ok(_) => print!("{} contains:\n{}", display, s),
}

// `file` goes out of scope, and the "hello.txt" file gets closed
}
2 changes: 2 additions & 0 deletions content/md/en/docs/quick-start/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ This file highlights lines 8-12 using a comment inside the file // highlight-ran

`embed:markdown2.js`

`embed:markdown.rs`

### Subset of a file

This code block only shows a subset of a file (lines 8 to 12) by embedding the file with a suffix of #L8-12
Expand Down
72 changes: 40 additions & 32 deletions src/components/layout/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,38 +33,46 @@ const Sidebar = ({ children, currentPath }) => {
<div className="mt-14">
{isOpen ? (
<>
<Link to="/quick-start/quickstart/">
<Icon
name="quickStart"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/quick-start/'),
})}
/>
</Link>
<Link to="/main-docs/">
<Icon
name="docsIcon"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/main-docs/'),
})}
/>
</Link>
<Link to="/tutorials/">
<Icon
name="tutorials"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/tutorials/'),
})}
/>
</Link>
<Link to="/reference/">
<Icon
name="reference"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/reference/'),
})}
/>
</Link>
<span title="Quick Start">
<Link to="/quick-start/quickstart/">
<Icon
name="quickStart"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/quick-start/'),
})}
/>
</Link>
</span>
<span title="Docs">
<Link to="/main-docs/">
<Icon
name="docsIcon"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/main-docs/'),
})}
/>
</Link>
</span>
<span title="Tutorials">
<Link to="/tutorials/">
<Icon
name="tutorials"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/tutorials/'),
})}
/>
</Link>
</span>
<span title="Reference">
<Link to="/reference/">
<Icon
name="reference"
className={cx('p-0 my-7 mx-auto block fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath.includes('/reference/'),
})}
/>
</Link>
</span>
</>
) : (
''
Expand Down
14 changes: 8 additions & 6 deletions src/components/site/NavSidebar/MobileMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ const MobileMenu = ({ page, currentPath }) => {
>
<span className="inline-block py-3 collapse-button w-full" onClick={() => setIsOpen(!isOpen)}>
{page.title === 'Quick start' && (
<Icon
name="quickStart"
className={cx('p-0 mx-2 inline fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath === page.url,
})}
/>
<span title="Quick Start">
<Icon
name="quickStart"
className={cx('p-0 mx-2 inline fill-current text-substrateDark dark:text-white', {
'fill-substrateBlue': currentPath === page.url,
})}
/>
</span>
)}
{page.title === 'Docs' && (
<Icon
Expand Down

0 comments on commit 466459a

Please sign in to comment.