From 83e77d4d3c75cde2c8589ebc47949ca9c69a6abe Mon Sep 17 00:00:00 2001 From: Florian <45694132+flo-bit@users.noreply.github.com> Date: Tue, 28 Oct 2025 00:48:25 +0100 Subject: [PATCH] update --- .github/workflows/tiny-docs.yml | 6 ++++- README.md | 28 +++++++++++++++++++- config.server.ts | 44 ++++++++----------------------- config.ts | 23 +--------------- config.type.ts | 22 ++++++++++++++++ scripts/update-config.js | 2 ++ src/components/ExternalLink.astro | 35 ++++++++++++++++++++++++ src/components/Footer.astro | 34 ++++++++++++------------ src/components/SocialIcons.astro | 24 ++++++++--------- src/layouts/MainLayout.astro | 3 ++- todo.md | 27 ++++++++++++------- 11 files changed, 152 insertions(+), 96 deletions(-) create mode 100644 config.type.ts create mode 100644 src/components/ExternalLink.astro diff --git a/.github/workflows/tiny-docs.yml b/.github/workflows/tiny-docs.yml index 38ef821..8ecb4b4 100644 --- a/.github/workflows/tiny-docs.yml +++ b/.github/workflows/tiny-docs.yml @@ -49,7 +49,7 @@ jobs: IN_NAME: ${{ inputs.name }} run: | set -euo pipefail - OWNER="${GITHUB_REPOSITORY%/*}" + OWNER="$GITHUB_REPOSITORY_OWNER" REPO="${GITHUB_REPOSITORY#*/}" SITE_DEFAULT="https://${OWNER}.github.io" @@ -67,6 +67,8 @@ jobs: echo "site=$SITE" >> "$GITHUB_OUTPUT" echo "base=$BASE" >> "$GITHUB_OUTPUT" echo "name=$NAME" >> "$GITHUB_OUTPUT" + echo "owner=$OWNER" >> "$GITHUB_OUTPUT" + echo "repo=$GITHUB_REPOSITORY" >> "$GITHUB_OUTPUT" - name: Setup Node.js uses: actions/setup-node@v4 @@ -78,6 +80,8 @@ jobs: DERIVED_SITE: ${{ steps.derive.outputs.site }} DERIVED_BASE: ${{ steps.derive.outputs.base }} DERIVED_NAME: ${{ steps.derive.outputs.name }} + DERIVED_OWNER: ${{ steps.derive.outputs.owner }} + DERIVED_REPO: ${{ steps.derive.outputs.repo }} run: node docs-builder/scripts/update-config.js - name: Install, build, and upload the site artifact diff --git a/README.md b/README.md index 3a50f2b..191ae52 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ -# Tiny docs \ No newline at end of file +# Tiny docs + +## How to use + +1. Enable github pages in the repo settings. Go to _SETTINGS → PAGES → SOURCE: Github Actions_ + +2. Add a new github action e.g. in `.github/workflows/deploy.yml` with the following content: + +```yaml +name: Deploy Docs + +on: + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +jobs: + docs: + uses: flo-bit/tiny-docs/.github/workflows/tiny-docs.yml@release/v1 +``` + +3. Run the workflow manually or push to the main branch, after a minute or two your docs should be live at `https://.github.io/`. \ No newline at end of file diff --git a/config.server.ts b/config.server.ts index 0377b68..db0bdec 100644 --- a/config.server.ts +++ b/config.server.ts @@ -1,29 +1,7 @@ // config.server.ts import { existsSync, readFileSync } from "node:fs"; import { resolve as r } from "node:path"; - -export type Config = { - SITE?: string; - BASE?: string; - SITE_NAME?: string; - SITE_DESCRIPTION?: string; - SITE_FAVICON?: string; - SHOW_THEME_TOGGLE?: boolean; - SEARCH_ENABLED?: boolean; - BASE_COLOR?: string; - ACCENT_COLOR?: string; - SOCIAL_LINKS?: { - FACEBOOK_URL?: string; - TWITTER_URL?: string; - GITHUB_URL?: string; - LINKEDIN_URL?: string; - YOUTUBE_URL?: string; - BLUESKY_URL?: string; - DISCORD_URL?: string; - EMAIL?: string; - }; - EXCLUDE_README?: boolean; -}; +import type { Config } from "./config.type"; const defaultConfig: Config = { SITE: undefined, @@ -35,16 +13,16 @@ const defaultConfig: Config = { SEARCH_ENABLED: false, BASE_COLOR: "zinc", ACCENT_COLOR: "emerald", - SOCIAL_LINKS: { - FACEBOOK_URL: "", - TWITTER_URL: "", - GITHUB_URL: "", - LINKEDIN_URL: "", - YOUTUBE_URL: "", - BLUESKY_URL: "", - DISCORD_URL: "", - EMAIL: "", - }, + + FACEBOOK_URL: "", + TWITTER_URL: "", + GITHUB_URL: "", + LINKEDIN_URL: "", + YOUTUBE_URL: "", + BLUESKY_URL: "", + DISCORD_URL: "", + EMAIL: "", + EXCLUDE_README: false, }; diff --git a/config.ts b/config.ts index 043f4a0..3854366 100644 --- a/config.ts +++ b/config.ts @@ -1,25 +1,4 @@ -export type Config = { - SITE?: string; - BASE?: string; - SITE_NAME?: string; - SITE_DESCRIPTION?: string; - SITE_FAVICON?: string; - SHOW_THEME_TOGGLE?: boolean; - SEARCH_ENABLED?: boolean; - BASE_COLOR?: string; - ACCENT_COLOR?: string; - SOCIAL_LINKS?: { - FACEBOOK_URL?: string; - TWITTER_URL?: string; - GITHUB_URL?: string; - LINKEDIN_URL?: string; - YOUTUBE_URL?: string; - BLUESKY_URL?: string; - DISCORD_URL?: string; - EMAIL?: string; - }; - EXCLUDE_README?: boolean; -}; +import type { Config } from "./config.type"; declare const __PUBLIC_CONFIG__: Config; diff --git a/config.type.ts b/config.type.ts new file mode 100644 index 0000000..3995bf4 --- /dev/null +++ b/config.type.ts @@ -0,0 +1,22 @@ +export type Config = { + SITE?: string; + BASE?: string; + SITE_NAME?: string; + SITE_DESCRIPTION?: string; + SITE_FAVICON?: string; + SHOW_THEME_TOGGLE?: boolean; + SEARCH_ENABLED?: boolean; + BASE_COLOR?: string; + ACCENT_COLOR?: string; + + FACEBOOK_URL?: string; + TWITTER_URL?: string; + GITHUB_URL?: string; + LINKEDIN_URL?: string; + YOUTUBE_URL?: string; + BLUESKY_URL?: string; + DISCORD_URL?: string; + EMAIL?: string; + + EXCLUDE_README?: boolean; +}; diff --git a/scripts/update-config.js b/scripts/update-config.js index c67605e..f6cac0a 100644 --- a/scripts/update-config.js +++ b/scripts/update-config.js @@ -9,6 +9,8 @@ const derived = { BASE: process.env.DERIVED_BASE, SITE_NAME: process.env.DERIVED_NAME, + GITHUB_URL: "https://github.com/" + process.env.DERIVED_REPO, + SHOW_THEME_TOGGLE: true, SEARCH_ENABLED: true, diff --git a/src/components/ExternalLink.astro b/src/components/ExternalLink.astro new file mode 100644 index 0000000..4c7ad22 --- /dev/null +++ b/src/components/ExternalLink.astro @@ -0,0 +1,35 @@ +--- +const { href }: Record = Astro.props; + +const domain = import.meta.env.SITE; +let attr: { target?: string; rel?: string } = {}; + +let isExternal = false; + +if (!href.includes(domain) && !href.startsWith("/") && !href.startsWith("#")) { + attr["target"] = "_blank"; + attr["rel"] = "noopener noreferrer"; + isExternal = true; +} +--- + + + { + isExternal ? ( + + + + ) : null + } + diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 464305a..761a179 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -9,10 +9,10 @@ const today = new Date(); >
{ - config.SOCIAL_LINKS?.FACEBOOK_URL ? ( + config.FACEBOOK_URL ? ( Facebook @@ -32,10 +32,10 @@ const today = new Date(); ) : null } { - config.SOCIAL_LINKS?.BLUESKY_URL ? ( + config.BLUESKY_URL ? ( Bluesky @@ -55,10 +55,10 @@ const today = new Date(); } { - config.SOCIAL_LINKS?.TWITTER_URL ? ( + config.TWITTER_URL ? ( X @@ -73,10 +73,10 @@ const today = new Date(); ) : null }{ - config.SOCIAL_LINKS?.LINKEDIN_URL ? ( + config.LINKEDIN_URL ? ( LinkedIn @@ -93,10 +93,10 @@ const today = new Date(); } { - config.SOCIAL_LINKS?.YOUTUBE_URL ? ( + config.YOUTUBE_URL ? ( YouTube @@ -116,13 +116,13 @@ const today = new Date(); ) : null } { - config.SOCIAL_LINKS?.EMAIL ? ( + config.EMAIL ? ( - {config.SOCIAL_LINKS.EMAIL} + {config.EMAIL} Discord @@ -162,10 +162,10 @@ const today = new Date(); ) : null } { - config.SOCIAL_LINKS?.GITHUB_URL ? ( + config.GITHUB_URL ? ( GitHub diff --git a/src/components/SocialIcons.astro b/src/components/SocialIcons.astro index 676aeaf..fda3b7b 100644 --- a/src/components/SocialIcons.astro +++ b/src/components/SocialIcons.astro @@ -3,10 +3,10 @@ import { config } from "../../config"; --- { - config.SOCIAL_LINKS?.FACEBOOK_URL ? ( + config.FACEBOOK_URL ? ( Facebook @@ -26,10 +26,10 @@ import { config } from "../../config"; ) : null } { - config.SOCIAL_LINKS?.BLUESKY_URL ? ( + config.BLUESKY_URL ? ( Bluesky @@ -48,10 +48,10 @@ import { config } from "../../config"; ) : null } { - config.SOCIAL_LINKS?.TWITTER_URL ? ( + config.TWITTER_URL ? ( X @@ -67,10 +67,10 @@ import { config } from "../../config"; ) : null } { - config.SOCIAL_LINKS?.YOUTUBE_URL ? ( + config.YOUTUBE_URL ? ( YouTube @@ -91,10 +91,10 @@ import { config } from "../../config"; } { - config.SOCIAL_LINKS?.DISCORD_URL ? ( + config.DISCORD_URL ? ( Discord @@ -118,10 +118,10 @@ import { config } from "../../config"; } { - config.SOCIAL_LINKS?.GITHUB_URL ? ( + config.GITHUB_URL ? ( GitHub diff --git a/src/layouts/MainLayout.astro b/src/layouts/MainLayout.astro index ec02d0c..a042e3d 100644 --- a/src/layouts/MainLayout.astro +++ b/src/layouts/MainLayout.astro @@ -6,6 +6,7 @@ import { getTitle, getSlug } from "src/utils"; import { config } from "../../config"; import SecondaryButton from "$components/buttons/SecondaryButton.astro"; import Footer from "$components/Footer.astro"; +import ExternalLink from "$components/ExternalLink.astro"; type Props = { post: CollectionEntry<"docs">; @@ -27,7 +28,7 @@ const { post, next, previous, Content, headings } = Astro.props; >
- +
diff --git a/todo.md b/todo.md index d973369..fa0511e 100644 --- a/todo.md +++ b/todo.md @@ -2,12 +2,21 @@ - [x] add next and previous buttons - [x] fix click in sidebar - [x] remove numbers and docs/ folder from the urls -- edit on github link -- ally: add skip to content button -- make asides github flavored markdown compatible -- checkout tagged version of repo -- fix relative links -- add npx command to install either workflow or add docs-builder to your repo -- option to not include readme -- have readme as first doc -- option to rename readme \ No newline at end of file +- [x] make asides github flavored markdown compatible +- [ ] edit on github link +- [ ] checkout tagged version of repo +- [ ] fix relative links +- [ ] add npx command to install either workflow or add docs-builder to your repo +- [ ] option to not include readme +- [ ] have readme as first doc +- [ ] option to rename readme +- [ ] automatically add github repo link +- [ ] download images and other assets and include them in the docs +- [ ] open external links in new tab + +- [ ] improve search +- [ ] ally: add skip to content button +- [ ] fix excalidraw diagrams to work with paths in docs +- [ ] 3d models, diagrams, maps, audio files, videos +- [ ] improve checklists, collapsed sections +- [ ] add powered by tiny-docs link to footer \ No newline at end of file -- 2.51.2