diff --git a/ops/scaffold-pages.py b/ops/scaffold-pages.py new file mode 100644 index 0000000..93e7703 --- /dev/null +++ b/ops/scaffold-pages.py @@ -0,0 +1,34 @@ +import json + +default_file_content = '''\ +--- +title: {title} +layout: '@/layouts/learn.astro' +--- + +TODO: add content +''' + + +def get_json_contents(filename): + with open(f'src/navData/{filename}.json') as f: + return json.load(f) + + +def create_doc(route): + filepath = f"src/pages/{route.get('path')}.md" + file_content = default_file_content.format(title=route.get('title')) + with open(filepath, 'w+') as file: + file.write(file_content) + + +def iterate_toc(toc): + for route in toc.get('routes'): + if bool(route.get('routes')): + iterate_toc(route) + create_doc(route) + + +filename = input('Source File: ') +toc = get_json_contents(filename) +iterate_toc(toc) diff --git a/src/components/Header.astro b/src/components/Header.astro index 918a8fa..8be5c08 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -12,6 +12,7 @@ import Logo from '@/components/Logo.astro';
About Blog + Learn diff --git a/src/components/Icons/CaretRightIcon.jsx b/src/components/Icons/CaretRightIcon.jsx new file mode 100644 index 0000000..5ef37c7 --- /dev/null +++ b/src/components/Icons/CaretRightIcon.jsx @@ -0,0 +1,19 @@ +function CaretRightIcon({ className = '' }) { + return ( + + + + ); +} + +export default CaretRightIcon; diff --git a/src/components/Icons/CloseIcon.jsx b/src/components/Icons/CloseIcon.jsx new file mode 100644 index 0000000..dfe46d6 --- /dev/null +++ b/src/components/Icons/CloseIcon.jsx @@ -0,0 +1,17 @@ +function CloseIcon({ className = '' }) { + return ( + + + + + ); +} + +export default CloseIcon; diff --git a/src/components/Icons/IconNavArrow.jsx b/src/components/Icons/IconNavArrow.jsx new file mode 100644 index 0000000..f727a5c --- /dev/null +++ b/src/components/Icons/IconNavArrow.jsx @@ -0,0 +1,35 @@ +import cn from 'classnames'; + +function IconNavArrow({ displayDirection = 'right', className }) { + const classes = cn( + 'duration-100 ease-in transition', + { + 'rotate-0': displayDirection === 'down', + '-rotate-90': displayDirection === 'right', + 'rotate-90': displayDirection === 'left', + }, + className + ); + + return ( + + + + + + + ); +} + +export default IconNavArrow; diff --git a/src/components/Icons/MenuIcon.jsx b/src/components/Icons/MenuIcon.jsx new file mode 100644 index 0000000..5727867 --- /dev/null +++ b/src/components/Icons/MenuIcon.jsx @@ -0,0 +1,17 @@ +function MenuIcon({ className = '' }) { + return ( + + + + + ); +} + +export default MenuIcon; diff --git a/src/components/Icons/index.jsx b/src/components/Icons/index.jsx index 549a4ed..96928ad 100644 --- a/src/components/Icons/index.jsx +++ b/src/components/Icons/index.jsx @@ -1,6 +1,10 @@ +export { default as CaretRightIcon } from './CaretRightIcon'; +export { default as CloseIcon } from './CloseIcon'; export { default as CodeIcon } from './CodeIcon'; export { default as DevToIcon } from './DevToIcon'; export { default as GithubIcon } from './GithubIcon'; +export { default as IconNavArrow } from './IconNavArrow'; +export { default as MenuIcon } from './MenuIcon'; export { default as MicIcon } from './MicIcon'; export { default as MoonIcon } from './MoonIcon'; export { default as PencilIcon } from './PencilIcon'; diff --git a/src/components/Learn/Breadcrumbs.astro b/src/components/Learn/Breadcrumbs.astro new file mode 100644 index 0000000..32ba23b --- /dev/null +++ b/src/components/Learn/Breadcrumbs.astro @@ -0,0 +1,35 @@ +--- +import { RouteItem } from '@/utils/nav'; +import { CaretRightIcon } from '@/components/Icons'; + +export interface Props { + breadcrumbs: RouteItem[]; +} + +const { breadcrumbs } = Astro.props as Props; +--- + +
+ { + breadcrumbs.map((crumb) => { + if (!crumb.path) { + return null; + } + return ( +
+ <> + + {crumb.title} + + + + + +
+ ); + }) + } +
diff --git a/src/components/Learn/Nav.astro b/src/components/Learn/Nav.astro new file mode 100644 index 0000000..bd351ac --- /dev/null +++ b/src/components/Learn/Nav.astro @@ -0,0 +1,34 @@ +--- +import { RouteItem } from '@/utils/nav'; + +export interface Props { + navContent: RouteItem; +} + +const { navContent } = Astro.props as Props; +const navPaths = navContent.routes; +--- + + diff --git a/src/components/Learn/Pagination.astro b/src/components/Learn/Pagination.astro new file mode 100644 index 0000000..422916a --- /dev/null +++ b/src/components/Learn/Pagination.astro @@ -0,0 +1,36 @@ +--- +import { RouteMeta } from '@/utils/nav'; +import PaginationLink from './PaginationLink.astro'; + +export type Props = Pick; + +const { nextRoute, prevRoute } = Astro.props as Props; +--- + +{ + (prevRoute?.path || nextRoute?.path) && ( + <> +
+ {prevRoute?.path ? ( + + ) : ( +
+ )} + + {nextRoute?.path ? ( + + ) : ( +
+ )} +
+ + ) +} diff --git a/src/components/Learn/PaginationLink.astro b/src/components/Learn/PaginationLink.astro new file mode 100644 index 0000000..c47b735 --- /dev/null +++ b/src/components/Learn/PaginationLink.astro @@ -0,0 +1,33 @@ +--- +import cn from 'classnames'; +import { IconNavArrow } from '@/components/Icons'; + +export interface Props { + href: string; + title: string; + type: 'Previous' | 'Next'; +} + +const { href, title, type } = Astro.props as Props; +--- + + + + + + {type} + + {title} + + diff --git a/src/components/Learn/TableOfContents.tsx b/src/components/Learn/TableOfContents.tsx new file mode 100644 index 0000000..f34c5df --- /dev/null +++ b/src/components/Learn/TableOfContents.tsx @@ -0,0 +1,99 @@ +import type { FunctionalComponent } from 'preact'; +import { useState, useEffect, useRef } from 'preact/hooks'; +import cn from 'classnames'; +import { unescapeHtml } from '@/utils/unescapeHtml'; + +interface Props { + headers: { depth: number; slug: string; text: string }[]; +} + +const TableOfContents: FunctionalComponent = ({ headers = [] }) => { + const targetedHeaders = [...headers].filter( + ({ depth }) => depth > 1 && depth < 4 + ); + targetedHeaders.unshift({ + depth: 1, + text: 'Overview', + slug: '', + }); + const toc = useRef(); + const [currentID, setCurrentID] = useState(targetedHeaders?.[0]?.slug); + const onThisPageID = 'on-this-page-heading'; + + useEffect(() => { + if (!toc.current) { + return; + } + + const setCurrent: IntersectionObserverCallback = (entries) => { + for (const entry of entries) { + if (entry.isIntersecting) { + const { id } = entry.target; + if (id === onThisPageID) { + continue; + } + setCurrentID(entry.target.id); + break; + } + } + }; + + const observerOptions: IntersectionObserverInit = { + // Negative top margin accounts for `scroll-margin`. + // Negative bottom margin means heading needs to be towards top of viewport to trigger intersection. + rootMargin: '-90px 0% -66%', + threshold: 1, + }; + + const headingsObserver = new IntersectionObserver( + setCurrent, + observerOptions + ); + + // Observe all the headings in the main page content. + document + .querySelectorAll('main :is(h1,h2,h3)') + .forEach((h) => headingsObserver.observe(h)); + + // Stop observing when the component is unmounted. + return () => headingsObserver.disconnect(); + }, [toc.current]); + + const onLinkClick = (e) => { + setCurrentID(e.target.getAttribute('href').replace('#', '')); + }; + + return ( + <> +

+ On This Page +

+ + + ); +}; + +export default TableOfContents; diff --git a/src/layouts/base.astro b/src/layouts/base.astro index 5849b67..26c2e01 100644 --- a/src/layouts/base.astro +++ b/src/layouts/base.astro @@ -19,7 +19,7 @@ const { title, description, socialImage, canonicalURL, redirectUrl } = +
+
+ + +
+
+ {breadcrumbs && } +

+ {content.title} +

+ + +
+
+
+
+ diff --git a/src/navData/programming-fundamentals.json b/src/navData/programming-fundamentals.json new file mode 100644 index 0000000..3c57643 --- /dev/null +++ b/src/navData/programming-fundamentals.json @@ -0,0 +1,303 @@ +{ + "title": "Programming Fundamentals", + "path": "/learn/programming-fundamentals", + "heading": true, + "routes": [ + { + "title": "Chapter 0: Introduction", + "path": "/learn/programming-fundamentals", + "routes": [ + { + "title": "Programming", + "path": "/learn/programming-fundamentals/introduction/programming" + }, + { + "title": "The Command Line", + "path": "/learn/programming-fundamentals/introduction/the-command-line" + }, + { + "title": "How programs work", + "path": "/learn/programming-fundamentals/introduction/how-programs-work" + }, + { + "title": "Compiled v Interpretted", + "path": "/learn/programming-fundamentals/introduction/compiled-v-interpretted" + }, + { + "title": "Syntax", + "path": "/learn/programming-fundamentals/introduction/syntax" + }, + { + "title": "Styles of Programming", + "path": "/learn/programming-fundamentals/introduction/styles-of-programming" + } + ] + }, + { + "title": "Chapter 1: Data Types", + "path": "/learn/programming-fundamentals/data-types", + "routes": [ + { + "title": "What are data types?", + "path": "/learn/programming-fundamentals/data-types/what-are-data-types" + }, + { + "title": "Variables", + "path": "/learn/programming-fundamentals/data-types/variables" + }, + { + "title": "Variable Assignment", + "path": "/learn/programming-fundamentals/data-types/variable-assignment" + }, + { + "title": "Arithmetic Operators", + "path": "/learn/programming-fundamentals/data-types/arithmetic-operators" + }, + { + "title": "Logical Operators", + "path": "/learn/programming-fundamentals/data-types/logical-operators" + }, + { + "title": "Bitwise Operators", + "path": "/learn/programming-fundamentals/data-types/bitwise-operators" + }, + { + "title": "Arrays", + "path": "/learn/programming-fundamentals/data-types/arrays" + }, + { + "title": "Multi-dimensional Arrays", + "path": "/learn/programming-fundamentals/data-types/multi-dimensional-arrays" + } + ] + }, + { + "title": "Chapter 2: Functions and Running Programs", + "path": "/learn/programming-fundamentals/functions-and-running-programs", + "routes": [ + { + "title": "Functions and Methods", + "path": "/learn/programming-fundamentals/functions-and-running-programs/functions-and-methods" + }, + { + "title": "Function Parameters", + "path": "/learn/programming-fundamentals/functions-and-running-programs/function-parameters" + }, + { + "title": "Value v Reference", + "path": "/learn/programming-fundamentals/functions-and-running-programs/value-v-reference" + }, + { + "title": "Functional Decomposition", + "path": "/learn/programming-fundamentals/functions-and-running-programs/functional-decomposition" + }, + { + "title": "Return Values", + "path": "/learn/programming-fundamentals/functions-and-running-programs/return-values" + }, + { + "title": "Displaying Output", + "path": "/learn/programming-fundamentals/functions-and-running-programs/displaying-output" + }, + { + "title": "Errors", + "path": "/learn/programming-fundamentals/functions-and-running-programs/errors" + }, + { + "title": "Debugging", + "path": "/learn/programming-fundamentals/functions-and-running-programs/debugging" + } + ] + }, + { + "title": "Chapter 3: Conditional Statements", + "path": "/learn/programming-fundamentals/conditional-statements", + "routes": [ + { + "title": "What are conditional statements?", + "path": "/learn/programming-fundamentals/conditional-statements/what-are-conditional-statements" + }, + { + "title": "The if Statement", + "path": "/learn/programming-fundamentals/conditional-statements/the-if-statement" + }, + { + "title": "The else Statement", + "path": "/learn/programming-fundamentals/conditional-statements/the-else-statement" + }, + { + "title": "The else if statement", + "path": "/learn/programming-fundamentals/conditional-statements/the-else-if-statement" + }, + { + "title": "The Ternary Operator", + "path": "/learn/programming-fundamentals/conditional-statements/the-ternary-operator" + }, + { + "title": "The switch statement", + "path": "/learn/programming-fundamentals/conditional-statements/the-switch-statement" + }, + { + "title": "How to pick your conditional pattern", + "path": "/learn/programming-fundamentals/conditional-statements/picking-conditional-pattern" + } + ] + }, + { + "title": "Chapter 4: Loops", + "path": "/learn/programming-fundamentals/loops", + "routes": [ + { + "title": "What are loops?", + "path": "/learn/programming-fundamentals/loops/what-are-loops" + }, + { + "title": "The while Loop", + "path": "/learn/programming-fundamentals/loops/the-while-loop" + }, + { + "title": "The do while Loop", + "path": "/learn/programming-fundamentals/loops/the-do-while-loop" + }, + { + "title": "The for Loop", + "path": "/learn/programming-fundamentals/loops/the-for-loop" + }, + { + "title": "Functional Looping", + "path": "/learn/programming-fundamentals/loops/functional-looping" + }, + { + "title": "Special Loops", + "path": "/learn/programming-fundamentals/loops/special-loops" + } + ] + }, + { + "title": "Chapter 5: Recursion", + "path": "/learn/programming-fundamentals/recursion", + "routes": [ + { + "title": "What is recursion?", + "path": "/learn/programming-fundamentals/recursion/what-is-recursion" + }, + { + "title": "Why use recursion?", + "path": "/learn/programming-fundamentals/recursion/why-use-recursion" + }, + { + "title": "Our first recursive function", + "path": "/learn/programming-fundamentals/recursion/our-first-recursive-function" + }, + { + "title": "Tracing recursive functions", + "path": "/learn/programming-fundamentals/recursion/tracing-recursive-functions" + }, + { + "title": "Converting Recursion to Loops", + "path": "/learn/programming-fundamentals/recursion/converting-recrusion-to-loops" + } + ] + }, + { + "title": "Chapter 6: Objects", + "path": "/learn/programming-fundamentals/objects", + "routes": [ + { + "title": "What is an object?", + "path": "/learn/programming-fundamentals/objects/what-is-an-object" + }, + { + "title": "Maps, Dictionaries, Tables", + "path": "/learn/programming-fundamentals/objects/maps-dictionaries-tables" + }, + { + "title": "Creating Objects", + "path": "/learn/programming-fundamentals/objects/creating-objects" + }, + { + "title": "Class Inheritence", + "path": "/learn/programming-fundamentals/objects/class-inheritence" + }, + { + "title": "Abstract Classes and Interfaces", + "path": "/learn/programming-fundamentals/objects/abstract-classes-and-interfaces" + }, + { + "title": "Polymorphism", + "path": "/learn/programming-fundamentals/objects/polymorphism" + } + ] + }, + { + "title": "Chapter 7: Regular Expressions", + "path": "/learn/programming-fundamentals/regular-expressions", + "routes": [ + { + "title": "How to use regular expressions?", + "path": "/learn/programming-fundamentals/regular-expressions/how-to-use-regular-expressions" + }, + { + "title": "Regular Expression Special Tokens", + "path": "/learn/programming-fundamentals/regular-expressions/regular-expression-special-tokens" + }, + { + "title": "Pattern Matching and Grouping", + "path": "/learn/programming-fundamentals/regular-expressions/pattern-matching-and-grouping" + } + ] + }, + { + "title": "Chapter 8: File I/O", + "path": "/learn/programming-fundamentals/file-io", + "routes": [ + { + "title": "File Permissions", + "path": "/learn/programming-fundamentals/file-io/file-permissions" + }, + { + "title": "Command Line Interactions", + "path": "/learn/programming-fundamentals/file-io/command-line-interactions" + }, + { + "title": "Reading Files", + "path": "/learn/programming-fundamentals/file-io/reading-files" + }, + { + "title": "Writing Files", + "path": "/learn/programming-fundamentals/file-io/writing-files" + }, + { + "title": "File Streaming", + "path": "/learn/programming-fundamentals/file-io/file-streaming" + } + ] + }, + { + "title": "Chapter 9: Exception Handling", + "path": "/learn/programming-fundamentals/exception-handling", + "routes": [ + { + "title": "Types of Exceptions", + "path": "/learn/programming-fundamentals/exception-handling/types-of-exceptions" + }, + { + "title": "try Blocks", + "path": "/learn/programming-fundamentals/exception-handling/try-blocks" + }, + { + "title": "catch Blocks", + "path": "/learn/programming-fundamentals/exception-handling/catch-blocks" + }, + { + "title": "finally Blocks", + "path": "/learn/programming-fundamentals/exception-handling/finally-blocks" + } + ] + }, + { + "title": "Chapter 10: What's next?", + "path": "/learn/programming-fundamentals/whats-next" + } + ] +} diff --git a/src/pages/learn/index.astro b/src/pages/learn/index.astro new file mode 100644 index 0000000..b1bcf00 --- /dev/null +++ b/src/pages/learn/index.astro @@ -0,0 +1,20 @@ +--- +import HomeLayout from '@/layouts/home.astro'; +--- + + +
+

Learning Catalog

+

Lorem ipsum dolor...

+
+
+ +
+
diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/index.md b/src/pages/learn/programming-fundamentals/conditional-statements/index.md new file mode 100644 index 0000000..5eb67ea --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/index.md @@ -0,0 +1,6 @@ +--- +title: Conditional Statements +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/picking-conditional-pattern.md b/src/pages/learn/programming-fundamentals/conditional-statements/picking-conditional-pattern.md new file mode 100644 index 0000000..55b3c66 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/picking-conditional-pattern.md @@ -0,0 +1,6 @@ +--- +title: How to pick your conditional pattern +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/the-else-if-statement.md b/src/pages/learn/programming-fundamentals/conditional-statements/the-else-if-statement.md new file mode 100644 index 0000000..dc5df6c --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/the-else-if-statement.md @@ -0,0 +1,6 @@ +--- +title: The else if statement +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/the-else-statement.md b/src/pages/learn/programming-fundamentals/conditional-statements/the-else-statement.md new file mode 100644 index 0000000..40db28b --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/the-else-statement.md @@ -0,0 +1,6 @@ +--- +title: The else Statement +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/the-if-statement.md b/src/pages/learn/programming-fundamentals/conditional-statements/the-if-statement.md new file mode 100644 index 0000000..e593305 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/the-if-statement.md @@ -0,0 +1,6 @@ +--- +title: The if Statement +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/the-switch-statement.md b/src/pages/learn/programming-fundamentals/conditional-statements/the-switch-statement.md new file mode 100644 index 0000000..c5784f5 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/the-switch-statement.md @@ -0,0 +1,6 @@ +--- +title: The switch statement +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/the-ternary-operator.md b/src/pages/learn/programming-fundamentals/conditional-statements/the-ternary-operator.md new file mode 100644 index 0000000..a7f0f9b --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/the-ternary-operator.md @@ -0,0 +1,6 @@ +--- +title: The Ternary Operator +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/conditional-statements/what-are-conditional-statements.md b/src/pages/learn/programming-fundamentals/conditional-statements/what-are-conditional-statements.md new file mode 100644 index 0000000..d25cb64 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/conditional-statements/what-are-conditional-statements.md @@ -0,0 +1,6 @@ +--- +title: What are conditional statements? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/arithmetic-operators.md b/src/pages/learn/programming-fundamentals/data-types/arithmetic-operators.md new file mode 100644 index 0000000..e012e6c --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/arithmetic-operators.md @@ -0,0 +1,6 @@ +--- +title: Arithmetic Operators +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/arrays.md b/src/pages/learn/programming-fundamentals/data-types/arrays.md new file mode 100644 index 0000000..8baac27 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/arrays.md @@ -0,0 +1,6 @@ +--- +title: Arrays +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/bitwise-operators.md b/src/pages/learn/programming-fundamentals/data-types/bitwise-operators.md new file mode 100644 index 0000000..d233b45 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/bitwise-operators.md @@ -0,0 +1,6 @@ +--- +title: Bitwise Operators +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/index.md b/src/pages/learn/programming-fundamentals/data-types/index.md new file mode 100644 index 0000000..7f3cd83 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/index.md @@ -0,0 +1,6 @@ +--- +title: Data Types +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/logical-operators.md b/src/pages/learn/programming-fundamentals/data-types/logical-operators.md new file mode 100644 index 0000000..e873a58 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/logical-operators.md @@ -0,0 +1,6 @@ +--- +title: Logical Operators +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/multi-dimensional-arrays.md b/src/pages/learn/programming-fundamentals/data-types/multi-dimensional-arrays.md new file mode 100644 index 0000000..f719cda --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/multi-dimensional-arrays.md @@ -0,0 +1,6 @@ +--- +title: Multi-dimensional Arrays +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/variable-assignment.md b/src/pages/learn/programming-fundamentals/data-types/variable-assignment.md new file mode 100644 index 0000000..636c012 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/variable-assignment.md @@ -0,0 +1,6 @@ +--- +title: Variable Assignment +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/variables.md b/src/pages/learn/programming-fundamentals/data-types/variables.md new file mode 100644 index 0000000..e3516aa --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/variables.md @@ -0,0 +1,6 @@ +--- +title: Variables +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/data-types/what-are-data-types.md b/src/pages/learn/programming-fundamentals/data-types/what-are-data-types.md new file mode 100644 index 0000000..e29cf78 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/data-types/what-are-data-types.md @@ -0,0 +1,6 @@ +--- +title: What are data types? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/exception-handling/catch-blocks.md b/src/pages/learn/programming-fundamentals/exception-handling/catch-blocks.md new file mode 100644 index 0000000..0b719ab --- /dev/null +++ b/src/pages/learn/programming-fundamentals/exception-handling/catch-blocks.md @@ -0,0 +1,6 @@ +--- +title: catch Blocks +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/exception-handling/finally-blocks.md b/src/pages/learn/programming-fundamentals/exception-handling/finally-blocks.md new file mode 100644 index 0000000..6fc532b --- /dev/null +++ b/src/pages/learn/programming-fundamentals/exception-handling/finally-blocks.md @@ -0,0 +1,6 @@ +--- +title: finally Blocks +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/exception-handling/index.md b/src/pages/learn/programming-fundamentals/exception-handling/index.md new file mode 100644 index 0000000..0c7864a --- /dev/null +++ b/src/pages/learn/programming-fundamentals/exception-handling/index.md @@ -0,0 +1,6 @@ +--- +title: Exception Handling +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/exception-handling/try-blocks.md b/src/pages/learn/programming-fundamentals/exception-handling/try-blocks.md new file mode 100644 index 0000000..bcb0450 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/exception-handling/try-blocks.md @@ -0,0 +1,6 @@ +--- +title: try Blocks +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/exception-handling/types-of-exceptions.md b/src/pages/learn/programming-fundamentals/exception-handling/types-of-exceptions.md new file mode 100644 index 0000000..bc5acac --- /dev/null +++ b/src/pages/learn/programming-fundamentals/exception-handling/types-of-exceptions.md @@ -0,0 +1,6 @@ +--- +title: Types of Exceptions +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/command-line-interactions.md b/src/pages/learn/programming-fundamentals/file-io/command-line-interactions.md new file mode 100644 index 0000000..2f89ab6 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/command-line-interactions.md @@ -0,0 +1,6 @@ +--- +title: Command Line Interactions +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/file-permissions.md b/src/pages/learn/programming-fundamentals/file-io/file-permissions.md new file mode 100644 index 0000000..48aab34 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/file-permissions.md @@ -0,0 +1,6 @@ +--- +title: File Permissions +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/file-streaming.md b/src/pages/learn/programming-fundamentals/file-io/file-streaming.md new file mode 100644 index 0000000..e1fc53d --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/file-streaming.md @@ -0,0 +1,6 @@ +--- +title: File Streaming +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/index.md b/src/pages/learn/programming-fundamentals/file-io/index.md new file mode 100644 index 0000000..375decd --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/index.md @@ -0,0 +1,6 @@ +--- +title: File I/O +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/reading-files.md b/src/pages/learn/programming-fundamentals/file-io/reading-files.md new file mode 100644 index 0000000..686ce58 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/reading-files.md @@ -0,0 +1,6 @@ +--- +title: Reading Files +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/file-io/writing-files.md b/src/pages/learn/programming-fundamentals/file-io/writing-files.md new file mode 100644 index 0000000..3d1b850 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/file-io/writing-files.md @@ -0,0 +1,6 @@ +--- +title: Writing Files +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/debugging.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/debugging.md new file mode 100644 index 0000000..776de83 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/debugging.md @@ -0,0 +1,6 @@ +--- +title: Debugging +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/displaying-output.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/displaying-output.md new file mode 100644 index 0000000..21fd19d --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/displaying-output.md @@ -0,0 +1,6 @@ +--- +title: Displaying Output +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/errors.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/errors.md new file mode 100644 index 0000000..c63b225 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/errors.md @@ -0,0 +1,6 @@ +--- +title: Errors +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/function-parameters.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/function-parameters.md new file mode 100644 index 0000000..2bb3a12 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/function-parameters.md @@ -0,0 +1,6 @@ +--- +title: Function Parameters +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/functional-decomposition.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/functional-decomposition.md new file mode 100644 index 0000000..84b7dd9 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/functional-decomposition.md @@ -0,0 +1,6 @@ +--- +title: Functional Decomposition +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/functions-and-methods.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/functions-and-methods.md new file mode 100644 index 0000000..a089c72 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/functions-and-methods.md @@ -0,0 +1,6 @@ +--- +title: Functions and Methods +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/index.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/index.md new file mode 100644 index 0000000..34fb690 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/index.md @@ -0,0 +1,6 @@ +--- +title: Functions and Running Programs +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/return-values.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/return-values.md new file mode 100644 index 0000000..02f3731 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/return-values.md @@ -0,0 +1,6 @@ +--- +title: Return Values +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/functions-and-running-programs/value-v-reference.md b/src/pages/learn/programming-fundamentals/functions-and-running-programs/value-v-reference.md new file mode 100644 index 0000000..3d2bd67 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/functions-and-running-programs/value-v-reference.md @@ -0,0 +1,6 @@ +--- +title: Value v Reference +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/index.md b/src/pages/learn/programming-fundamentals/index.md new file mode 100644 index 0000000..adb2997 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/index.md @@ -0,0 +1,28 @@ +--- +title: Introduction +layout: '@/layouts/learn.astro' +--- + +The software industry is a fantastic collection of individuals of all backgrounds and experiences which allows for an immense amount of creativity and collaboration. The software engineers you meet will have their story of how they got into the industry. Some have been programming since they were teenagers, while others had different careers prior to learning to program. Some have a formal education in mathematics or computer science, some took a coding bootcamp, and some are self-taught using online resources like [Codecademy](https://codecademy.com/), [Khan Academy](https://www.khanacademy.org/), etc. + +Personally, I have been doing some form of software development since I was in high school and have a formal degree in Computer Science from Emory University in Atlanta, GA, USA. My degree aided me in learning strong programming fundamentals. Without these fundamentals, I believe I could achieve what I've achieved in my career to date; however, I don't think I would have achieved them as quickly. + +It is my personal belief that coding bootcamps and self-taught developers generally do not receive a proper education in programming fundamentals. It is my hope that this resource will prove to be a resource that gives everyone an equal opportunity to learn the fundamentals I believe have helped myself and many others excel in this field. + +## Why choose this resource? + +There are several great resources on the internet and in book stores that all have their merits. In my opinion, many of them focus on specific languages and techniques. This resource aims to be agnostic towards specific technologies and will demonstrate the same concepts in a variety of programming languages. + +The goal of this resource is **not** to help you build your first application. However, it is geared towards giving you tools you can use to write simple programs and scripts. These building blocks are the foundation you will eventually use to build out applications. My hope is you absord the content of this book and then go utilize a tool like Codecademy to learn the specific techniques for building the type of application you want to build. The fundamentals presented should give you a deeper understanding of the future content you absorb, making furture learning endeavours easier. + +## How to use this resource? + +The main language choosen is Python. This is due to three main reasons: + +1. It has a very accessible language syntax. +1. It enforces the teaching of proper indentation immediately. +1. Certain syntax choices the language has help teach certain concepts more easily. + +However, all examples will be accompanied by examples in Ruby, JavaScript, TypeScript, and Java. If you would like to see examples in other languages, please let me know in [the project issues](https://github.com/dustinsgoodman/dustingoodman.dev/issues). I've chosen these languages because I have direct experience with them and think they will help demonstrate all the concepts I hope to teach. + +**I strongly encourage you to read the content of this resource and focus in on a single language.** However, some readers will be enthusiastic and want to see how the same code snippet looks in other languages. I urge caution as this can cause confusion when learning your first new language. I encourage you to pick a language before you begin to read and only use that language in this resource. The language selector will persist your choice on your current computer and browser. diff --git a/src/pages/learn/programming-fundamentals/introduction/compiled-v-interpretted.md b/src/pages/learn/programming-fundamentals/introduction/compiled-v-interpretted.md new file mode 100644 index 0000000..4262585 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/compiled-v-interpretted.md @@ -0,0 +1,6 @@ +--- +title: Compiled v Interpretted +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/introduction/how-programs-work.md b/src/pages/learn/programming-fundamentals/introduction/how-programs-work.md new file mode 100644 index 0000000..3fb2fb4 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/how-programs-work.md @@ -0,0 +1,6 @@ +--- +title: How programs work +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/introduction/programming.md b/src/pages/learn/programming-fundamentals/introduction/programming.md new file mode 100644 index 0000000..d1da765 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/programming.md @@ -0,0 +1,6 @@ +--- +title: Programming +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/introduction/styles-of-programming.md b/src/pages/learn/programming-fundamentals/introduction/styles-of-programming.md new file mode 100644 index 0000000..c0273e3 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/styles-of-programming.md @@ -0,0 +1,6 @@ +--- +title: Styles of Programming +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/introduction/syntax.md b/src/pages/learn/programming-fundamentals/introduction/syntax.md new file mode 100644 index 0000000..074fe43 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/syntax.md @@ -0,0 +1,6 @@ +--- +title: Syntax +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/introduction/the-command-line.md b/src/pages/learn/programming-fundamentals/introduction/the-command-line.md new file mode 100644 index 0000000..689b59f --- /dev/null +++ b/src/pages/learn/programming-fundamentals/introduction/the-command-line.md @@ -0,0 +1,6 @@ +--- +title: The Command Line +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/functional-looping.md b/src/pages/learn/programming-fundamentals/loops/functional-looping.md new file mode 100644 index 0000000..a92a1e3 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/functional-looping.md @@ -0,0 +1,6 @@ +--- +title: Functional Looping +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/index.md b/src/pages/learn/programming-fundamentals/loops/index.md new file mode 100644 index 0000000..16db6be --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/index.md @@ -0,0 +1,6 @@ +--- +title: Loops +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/special-loops.md b/src/pages/learn/programming-fundamentals/loops/special-loops.md new file mode 100644 index 0000000..a63adc9 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/special-loops.md @@ -0,0 +1,6 @@ +--- +title: Special Loops +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/the-do-while-loop.md b/src/pages/learn/programming-fundamentals/loops/the-do-while-loop.md new file mode 100644 index 0000000..6b4fecf --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/the-do-while-loop.md @@ -0,0 +1,6 @@ +--- +title: The do while Loop +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/the-for-loop.md b/src/pages/learn/programming-fundamentals/loops/the-for-loop.md new file mode 100644 index 0000000..e378f39 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/the-for-loop.md @@ -0,0 +1,6 @@ +--- +title: The for Loop +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/the-while-loop.md b/src/pages/learn/programming-fundamentals/loops/the-while-loop.md new file mode 100644 index 0000000..9d99f34 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/the-while-loop.md @@ -0,0 +1,6 @@ +--- +title: The while Loop +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/loops/what-are-loops.md b/src/pages/learn/programming-fundamentals/loops/what-are-loops.md new file mode 100644 index 0000000..bd77d46 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/loops/what-are-loops.md @@ -0,0 +1,6 @@ +--- +title: What are loops? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/abstract-classes-and-interfaces.md b/src/pages/learn/programming-fundamentals/objects/abstract-classes-and-interfaces.md new file mode 100644 index 0000000..cc3672a --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/abstract-classes-and-interfaces.md @@ -0,0 +1,6 @@ +--- +title: Abstract Classes and Interfaces +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/class-inheritence.md b/src/pages/learn/programming-fundamentals/objects/class-inheritence.md new file mode 100644 index 0000000..80641bc --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/class-inheritence.md @@ -0,0 +1,6 @@ +--- +title: Class Inheritence +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/creating-objects.md b/src/pages/learn/programming-fundamentals/objects/creating-objects.md new file mode 100644 index 0000000..35dbc1f --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/creating-objects.md @@ -0,0 +1,6 @@ +--- +title: Creating Objects +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/index.md b/src/pages/learn/programming-fundamentals/objects/index.md new file mode 100644 index 0000000..6f1d830 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/index.md @@ -0,0 +1,6 @@ +--- +title: Objects +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/maps-dictionaries-tables.md b/src/pages/learn/programming-fundamentals/objects/maps-dictionaries-tables.md new file mode 100644 index 0000000..528fbab --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/maps-dictionaries-tables.md @@ -0,0 +1,6 @@ +--- +title: Maps, Dictionaries, Tables +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/polymorphism.md b/src/pages/learn/programming-fundamentals/objects/polymorphism.md new file mode 100644 index 0000000..a1bb001 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/polymorphism.md @@ -0,0 +1,6 @@ +--- +title: Polymorphism +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/objects/what-is-an-object.md b/src/pages/learn/programming-fundamentals/objects/what-is-an-object.md new file mode 100644 index 0000000..bae6e3b --- /dev/null +++ b/src/pages/learn/programming-fundamentals/objects/what-is-an-object.md @@ -0,0 +1,6 @@ +--- +title: What is an object? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/converting-recrusion-to-loops.md b/src/pages/learn/programming-fundamentals/recursion/converting-recrusion-to-loops.md new file mode 100644 index 0000000..cbce1cc --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/converting-recrusion-to-loops.md @@ -0,0 +1,6 @@ +--- +title: Converting Recursion to Loops +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/index.md b/src/pages/learn/programming-fundamentals/recursion/index.md new file mode 100644 index 0000000..83de016 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/index.md @@ -0,0 +1,6 @@ +--- +title: Recursion +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/our-first-recursive-function.md b/src/pages/learn/programming-fundamentals/recursion/our-first-recursive-function.md new file mode 100644 index 0000000..e69c73a --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/our-first-recursive-function.md @@ -0,0 +1,6 @@ +--- +title: Our first recursive function +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/tracing-recursive-functions.md b/src/pages/learn/programming-fundamentals/recursion/tracing-recursive-functions.md new file mode 100644 index 0000000..a6fff8b --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/tracing-recursive-functions.md @@ -0,0 +1,6 @@ +--- +title: Tracing recursive functions +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/what-is-recursion.md b/src/pages/learn/programming-fundamentals/recursion/what-is-recursion.md new file mode 100644 index 0000000..728795e --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/what-is-recursion.md @@ -0,0 +1,6 @@ +--- +title: What is recursion? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/recursion/why-use-recursion.md b/src/pages/learn/programming-fundamentals/recursion/why-use-recursion.md new file mode 100644 index 0000000..fd0d623 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/recursion/why-use-recursion.md @@ -0,0 +1,6 @@ +--- +title: Why use recursion? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/regular-expressions/how-to-use-regular-expressions.md b/src/pages/learn/programming-fundamentals/regular-expressions/how-to-use-regular-expressions.md new file mode 100644 index 0000000..4e2e49a --- /dev/null +++ b/src/pages/learn/programming-fundamentals/regular-expressions/how-to-use-regular-expressions.md @@ -0,0 +1,6 @@ +--- +title: How to use regular expressions? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/regular-expressions/index.md b/src/pages/learn/programming-fundamentals/regular-expressions/index.md new file mode 100644 index 0000000..4f23d40 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/regular-expressions/index.md @@ -0,0 +1,6 @@ +--- +title: Regular Expressions +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/regular-expressions/pattern-matching-and-grouping.md b/src/pages/learn/programming-fundamentals/regular-expressions/pattern-matching-and-grouping.md new file mode 100644 index 0000000..3fb0067 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/regular-expressions/pattern-matching-and-grouping.md @@ -0,0 +1,6 @@ +--- +title: Pattern Matching and Grouping +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/regular-expressions/regular-expression-special-tokens.md b/src/pages/learn/programming-fundamentals/regular-expressions/regular-expression-special-tokens.md new file mode 100644 index 0000000..44da877 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/regular-expressions/regular-expression-special-tokens.md @@ -0,0 +1,6 @@ +--- +title: Regular Expression Special Tokens +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/pages/learn/programming-fundamentals/whats-next/index.md b/src/pages/learn/programming-fundamentals/whats-next/index.md new file mode 100644 index 0000000..ee4ea19 --- /dev/null +++ b/src/pages/learn/programming-fundamentals/whats-next/index.md @@ -0,0 +1,6 @@ +--- +title: What's next? +layout: '@/layouts/learn.astro' +--- + +TODO: add content diff --git a/src/styles/base.css b/src/styles/base.css index 38c44e8..200253f 100644 --- a/src/styles/base.css +++ b/src/styles/base.css @@ -23,15 +23,15 @@ } h1 { - @apply my-4 text-4xl font-bold; + @apply mt-2 mb-4 text-4xl font-extrabold leading-snug tracking-wide; } h2 { - @apply mb-4 text-3xl font-bold; + @apply mb-4 text-2xl font-bold; } h3 { - @apply mb-2 text-2xl font-bold; + @apply mb-2 text-xl font-bold; } a { @@ -39,7 +39,7 @@ } p { - @apply mb-4 block leading-relaxed; + @apply mb-4 block leading-relaxed tracking-wide; } ol, diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 869b899..d5c2eac 100644 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -1 +1,3 @@ +/// + declare module '*&imagetools'; diff --git a/src/utils/nav.ts b/src/utils/nav.ts new file mode 100644 index 0000000..a4e8984 --- /dev/null +++ b/src/utils/nav.ts @@ -0,0 +1,102 @@ +export interface RouteItem { + /** Page title (for the sidebar) */ + title: string; + /** Path to page */ + path?: string; + /** List of sub-routes */ + routes?: RouteItem[]; + /** Whether the entry is a heading */ + heading?: boolean; +} + +export interface RouteMeta { + prevRoute?: RouteItem; + currentRoute?: RouteItem; + nextRoute?: RouteItem; + breadcrumbs?: RouteItem[]; +} + +// Converts the map of path modules returned by `import.meta.glob` to an object +// mapping the path module from each module's filepath to the module's path map +function mapDefaultExports(modules: Record) { + const exportMap: Record = {}; + Object.entries(modules).forEach(([path, module]) => { + const [_dot, _navData, pathMap] = path.split('/'); + exportMap[pathMap.replace('.json', '')] = module.default; + }); + return exportMap; +} + +const navData = mapDefaultExports( + import.meta.glob('../navData/*.json', { eager: true }) +); + +export function getNavContent(currentPage: string): RouteItem { + const [_empty, _learn, courseName] = currentPage.split('/'); + return navData[courseName]; +} + +export function getRouteInfo(routeTree: RouteItem, currentPage: string) { + const breadcrumbs = getBreadcrumbs(routeTree, currentPage); + const routeMeta = getRouteMeta(routeTree, currentPage); + return { + ...routeMeta, + breadcrumbs: breadcrumbs.length > 0 ? breadcrumbs : [routeTree], + }; +} + +function getRouteMeta( + routeTree: RouteItem, + currentPage: string, + ctx: RouteMeta = {} +): RouteMeta { + const { routes } = routeTree; + + if (ctx.currentRoute && !ctx.nextRoute) { + ctx.nextRoute = routeTree; + } + + if (routeTree.path === currentPage && !routeTree.heading) { + ctx.currentRoute = routeTree; + } + + if (!ctx.currentRoute && !routeTree.heading) { + ctx.prevRoute = routeTree; + } + + if (!routes) { + return ctx; + } + + for (const route of routes) { + getRouteMeta(route, currentPage, ctx); + } + + return ctx; +} + +function getBreadcrumbs( + routeTree: RouteItem, + currentPage: string, + breadcrumbs: RouteItem[] = [] +): RouteItem[] { + if (currentPage === routeTree.path) { + return breadcrumbs; + } + + if (!routeTree.routes) { + return []; + } + + for (const route of routeTree.routes) { + const childRoute = getBreadcrumbs(route, currentPage, [ + ...breadcrumbs, + routeTree, + ]); + if (childRoute?.length) { + return childRoute; + } + } + + return []; +} diff --git a/src/utils/unescapeHtml.ts b/src/utils/unescapeHtml.ts new file mode 100644 index 0000000..33de84d --- /dev/null +++ b/src/utils/unescapeHtml.ts @@ -0,0 +1,8 @@ +export function unescapeHtml(escapedString: string) { + return escapedString + .replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"') + .replace(/'/g, "'"); +} diff --git a/tsconfig.json b/tsconfig.json index 2172fef..7778890 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,11 +2,15 @@ "moduleResolution": "node", "compilerOptions": { "baseUrl": ".", + "moduleResolution": "node", + "module": "ES2020", + "target": "ES2020", "paths": { "@/components/*": ["src/components/*"], "@/images/*": ["src/images/*"], "@/layouts/*": ["src/layouts/*"], - "@/types": ["src/types/index"] + "@/types": ["src/types/index"], + "@/utils/*": ["src/utils/*"] } } }