Code Monkey home page Code Monkey logo

hakuba's Introduction

Hakuba screenshots

Hakuba

中文版介绍

Hakuba (白馬村 , Hakuba-mura) is a village located in Nagano Prefecture, Japan. If you enjoy hiking or climbing, skiing or other activities, this would be a great place to go (btw I haven't been there yet...)

A fast blog starter that reads data off GitHub Discussions.

See how fast it is in action!!

Please star and fork if you like it!

How Does It Work

Hakuba fetches the contents on GitHub Discussions with GitHub GraphQL API and webhooks. Then renders the actual blog pages from them.

Quick Start

Recommended hosting services:

The output directory named build.

Deploy with Vercel:
Deploy with Vercel

... or continue scrolling for guide about manual deployment

Hakuba just a blog starter,data and code are completely separated,so you can create a empty repository to write posts and pages discussion, and write a script to clone this repository and build.

The advantage of this is that you can easily deploy your blog and don't need to worry about code updates.

Configuration

There are various ways to configure it, you can choose to configure it all using environment variables, or partly through discussion.

If configured blog through discussion, title must be index, category must be CONFIG_CATEGORY, Here is an example.

Name Description Required env configured through discussion
GITHUB_TOKEN Require a access token with permissions in the public_repo scope for public repositories, or the repo scope for private ones.
REPOSITORY The target repository
CONFIG_CATEGORY Category name of posts for configuration purposes on GitHub Discussion. Config at default.
POST_CATEGORY Category name of actual posts on GitHub Discussion. Post at default. Regex Supported.
PAGE_CATEGORY Category name of posts for dedicated pages on GitHub Discussion. Page at default.
PAGE_SIZE Number Category name of posts for configuration purposes in GitHub Discussion.kof posts per page, 10 at default.
BLOG_NAME Name of the blog, Hakuba fetches it from GitHub profile if left blank.
BIO Biography of the block, Hakuba fetches it from GitHub profile if left blank.
EMAIL Email for contact in the about section
TWITTER Twitter handle without the leading @ (e.g. SvelteJS)
DOMAIN Domain of the blog. RSS feed will be disabled if left blank.
DESCRIPTION Description of the blog in SEO metadata.
KEYWORDS Keywords for SEO metadata.
COMMENT Whether to enable comments, true at default.
LANGUAGE Language of the block in form of HTML language code. en at default.
TIMEZONE Timezone of Date.prototype.toLocaleDateString(locals, options), GMT at default.

Setup GitHub Discussions

Create discussions categories for configurations, posts, and pages. Then Set their format to Announcement.

Hakuba supports mdx and HTML script tags for pages and posts, so don't make them public-editable❗❗❗

Only the page named index will be used as the main configuration. Here is an example.

Setup Webhooks

If you deployed Hakuba using vercel, netlify or Cloudflare Pages, update of the contents could be automated with webhooks when discussions are modified.

  • Create a new Deploy Hook.
  • Go to the repository settings page to set up the webhook. Select Discussion events.

Manual Deployment

Clone the repository with git:

git clone [email protected]:YeungKC/Hakuba.git

Then, generate the pages:

# Run any one of them

yarn build
npm run build
pnpm build

Finally, upload the build directory to your web server.

Update code

If you are using a fork or clone, you need to run the following command:

git remote add upstream https://github.com/YeungKC/Hakuba.git
git fetch upstream/master
git merge upstream/master
git push origin master

Additional Settings for Pages and Posts

Pages and posts support Markdown front matter for metadata and configuration overrides.

Front matter for pages

Added page will be displayed in navigation.

If you added page title is __error, it will be replaced the error page.

Here is an example

name desc
lang Language of the post in the form of html language attribute
comment Whether to enable comments
priority Priority for indexing
path Path to the page, use all lowercase title by default
excerpt Excerpt of the page for SEO metadata

Post front matter

Here is an example

name desc
lang Language of the post in the form of html language tag
comment Whether to enable comments
path Path to the post, use discussion number by default
excerpt Excerpt of the page for SEO metadata
title Title of the post. Hakuba uses the title of the discussion post at default.
published Date published. Hakuba uses the date of the discussion post at default.
updated Date updated. Hakuba uses the latest date of modification of the discussion post at default.
timezone Timezone of Date.prototype.toLocaleDateString(locals, options), config.TIMEZONE at default.

Limitations

Because use Mdsvex to preprocess the markdown, the following limitations apply:

In markdown you can begin a code block by indenting 4 spaces. This doesn’t work in mdsvex as indentation is common with XML-based languages. Indenting 4 spaces will do nothing.

see also: https://mdsvex.com/docs#limitations

Dependabot Auto Merge

This project uses action-dependabot-auto-merge for updating dependencies automatically. If there is a CI failure, try to configure Dependabot secrets.

Migrate

Clone this repository, configure GITHUB_TOKEN and REPOSITORY environment variables, install dependencies with package manager and run:

# Run any one of them

npm run generateData
yarn generateData
pnpm generateData

The post path is src/routes/post/_source/[discussion number].md and the page path is src/routes/_page/[title].md.

Roadmap

  • Design a logo.
  • Page transitions.
  • Pre-download resources.
  • Lazy load images.
  • Dark mode.

Credits

  • hexo-theme-cactus, I have used this theme for a long time, it has inspired the current theme of Hakuba.

License

GPL-3.0

hakuba's People

Contributors

dependabot[bot] avatar yeungkc avatar string10 avatar redl0tus avatar

Stargazers

Hobart Zhi-xin Lin avatar

Watchers

Hobart Zhi-xin Lin avatar

hakuba's Issues

Favicon cannot Loading directly from Build Result

Describe the bug
Favicon not loading while deployed in Vercel.

To Reproduce
Delete cp -r static/* build then give it a build then start a http server via python.

Expected behavior
Site has a favicon.

Support Github Style Alerts

Support GFM Alerts like this.

Note

Useful information that users should know, even when skimming content.

Tip

Helpful advice for doing things better or more easily.

Important

Key information users need to know to achieve their goal.

Warning

Urgent info that needs immediate user attention to avoid problems.

Caution

Advises about risks or negative outcomes of certain actions.

Describe the solution you'd like
There's one rehype plugin rehype-github-alerts, but doesn't work with this repo.

Describe alternatives you've considered

  1. DIY: Crafting Custom flavored Markdown for Svelte with mdsvex, or
  2. Waiting for MDsveX's update.

Multiple Reference Calls to the Same Footnote

Describe the bug
Multiple reference call to the same footnotes will only generate one footnote-to-content link.

To Reproduce
Check the following markdown:

Several calls[^1] [^1] to the same definition may occur.

[^1]: One definition here.

Then we get:

<p>Several calls<sup id="fnref-1"><a href="#fn-1" class="footnote-ref">1</a></sup> <sup id="fnref-1"><a href="#fn-1" class="footnote-ref">1</a></sup> to the same definition may occur.</p>
<div class="footnotes">
  <hr>
  <ol>
    <li id="fn-1">One definition here.<a href="#fnref-1" class="footnote-backref"></a></li>
  </ol>
</div>

Two reference calls get the same id and click the back link will only lead to the first call.

Expected behavior

Something like this:

<p>Several calls<sup id="fnref-1"><a href="#fn-1" class="footnote-ref">1</a></sup> <sup id="fnref-1:1"><a href="#fn-1" class="footnote-ref">1</a></sup> to the same definition may occur.</p>
<div class="footnotes">
  <hr>
  <ol>
    <li id="fn-1">One definition here.<a href="#fnref-1" class="footnote-backref"></a><a href="#fnref-1-1" class="footnote-backref"></a></li>
  </ol>
</div>

Additional context
See String10/KGarden#37 for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.