Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update v1.7.0 #23

Merged
merged 32 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
22e0392
feat: Update text selection style
LucJosin Feb 24, 2024
bcadf54
feat: Add ThemeIcon component and Add theme toggle
LucJosin Feb 25, 2024
c51e2ab
refactor: Convert description color into root variable
LucJosin Feb 25, 2024
2d9595b
feat: Add new og tags and Update metadata
LucJosin Feb 25, 2024
af6b988
feat: Update selection color
LucJosin Feb 25, 2024
f169e9c
fix: Wrong remark-readme-stats theme detection
LucJosin Feb 25, 2024
496c320
build: Update dependencies
LucJosin Feb 25, 2024
03b9c9a
feat: Update astro expressive code to support themes
LucJosin Feb 25, 2024
5c874c6
style: Format PostLayout file
LucJosin Feb 25, 2024
c8f8027
style: Update expressive code style
LucJosin Feb 25, 2024
5563725
feat: Add remark-code-set package
LucJosin Feb 26, 2024
1a14590
refactor: Replace remark-codeset with remark-code-set package
LucJosin Feb 26, 2024
04b5c86
refactor: Remove old tab listener
LucJosin Feb 26, 2024
cd58e6b
fix: Slow theme transition
LucJosin Feb 26, 2024
d111d53
fix: Codeset code
LucJosin Feb 26, 2024
4d910d6
style: Update codeset style
LucJosin Feb 26, 2024
cbe400d
fix: Change codeset delimiter
LucJosin Feb 26, 2024
5a57e88
style: Fix wrong tip alert block when switching themes
LucJosin Feb 26, 2024
c404d62
fix: Wrong codeset grid column
LucJosin Feb 26, 2024
dbf1c46
style: Update code highlight style
LucJosin Feb 26, 2024
d344aee
feat: Increase post max width
LucJosin Feb 26, 2024
43748d1
wip: Giscus theme toggle
LucJosin Feb 26, 2024
e07f77e
feat: Giscus toggle theme
LucJosin Feb 27, 2024
f27f5de
feat: Update light theme colors
LucJosin Feb 27, 2024
6634ca9
refactor: Move comments to below related posts
LucJosin Feb 27, 2024
950185c
fix: PostRelated missing config and grid layout
LucJosin Feb 27, 2024
2a78ef8
feat: Update remark-readme-status background color
LucJosin Feb 27, 2024
270135e
feat: Add Footer to all pages
LucJosin Feb 27, 2024
1ee5f3d
feat: Increase avatar size
LucJosin Feb 27, 2024
8c11273
fix: Expressive code header with high z-index
LucJosin Feb 28, 2024
78c5656
feat: Increase scrollbar width to 9px
LucJosin Feb 28, 2024
ff69ca0
feat: Update post layout format
LucJosin Feb 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import { s } from 'hastscript';

import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import { pluginLineNumbers } from '@expressive-code/plugin-line-numbers';
import compress from 'astro-compress';
import astroExpressiveCode from 'astro-expressive-code';
import rename from 'astro-rename';
import robotsTxt from 'astro-robots-txt';

import remarkAlertBlocks from '@lucjosin/remark-alert-blocks';
import remarkCodeHighlight from '@lucjosin/remark-code-highlight';
import remarkCodeSet from '@lucjosin/remark-code-set';
import remarkImageCaption from '@lucjosin/remark-image-caption';
import remarkPostReference from '@lucjosin/remark-post-reference';
import remarkReadmeStats from '@lucjosin/remark-readme-stats';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug';
import codeset from 'remark-codeset';
import remarkCollapse from 'remark-collapse';
import numberedFootnoteLabels from 'remark-numbered-footnote-labels';
import remarkToc from 'remark-toc';
Expand All @@ -42,7 +43,13 @@ export default defineConfig({
// Ref: https://docs.astro.build/en/guides/integrations-guide/
// Ref: https://docs.astro.build/en/guides/integrations-guide/sitemap/
integrations: [
astroExpressiveCode(),
astroExpressiveCode({
themes: ['dark-plus', 'light-plus'],
useDarkModeMediaQuery: true,
themeCssSelector: (theme) =>
`[data-theme='${theme.name.replace('-plus', '')}']`,
plugins: [pluginLineNumbers()],
}),
rename({
rename: {
strategy: (key) => renamer.rename(key),
Expand Down Expand Up @@ -116,7 +123,7 @@ export default defineConfig({
remarkReadmeStats,
{
darkBgColor: '111111',
lightBgColor: 'f0f0f0',
lightBgColor: 'ffffff',
borderRadius: '10',
},
],
Expand All @@ -125,7 +132,7 @@ export default defineConfig({
remarkAlertBlocks,
remarkCodeHighlight,
remarkImageCaption,
codeset,
remarkCodeSet,
remarkToc,
[
remarkCollapse,
Expand Down
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,43 @@
"@astrojs/sitemap": "^3.0.2",
"@lucjosin/remark-alert-blocks": "./plugins/remark-alert-blocks",
"@lucjosin/remark-code-highlight": "./plugins/remark-code-highlight",
"@lucjosin/remark-code-set": "./plugins/remark-code-set",
"@lucjosin/remark-image-caption": "./plugins/remark-image-caption",
"@lucjosin/remark-post-reference": "./plugins/remark-post-reference",
"@lucjosin/remark-readme-stats": "./plugins/remark-readme-stats",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"astro": "^3.3.4",
"astro-compress": "^2.1.5",
"astro-expressive-code": "^0.26.2",
"astro-compress": "^2.2.10",
"astro-expressive-code": "^0.33.4",
"astro-icon": "^0.8.1",
"astro-rename": "^1.1.1",
"astro-rename": "^1.1.2",
"astro-robots-txt": "^1.0.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-astro": "^0.29.1",
"prettier": "^3.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^0.31.4",
"prettier": "^3.2.5",
"prettier-plugin-astro": "^0.12.0",
"rehype-autolink-headings": "^7.0.0",
"rehype-autolink-headings": "^7.1.0",
"rehype-external-links": "^3.0.0",
"rehype-slug": "^6.0.0",
"remark-codeset": "^1.1.4",
"remark-collapse": "^0.1.2",
"remark-numbered-footnote-labels": "^1.1.0",
"remark-toc": "^8.0.1",
"satori": "^0.10.9",
"satori": "^0.10.13",
"satori-html": "^0.3.2",
"svgo": "2.8.0",
"typescript": "^5.2.2"
},
"dependencies": {
"@astrojs/react": "^3.0.3",
"@astrojs/rss": "^3.0.0",
"@expressive-code/plugin-line-numbers": "^0.33.4",
"@resvg/resvg-js": "^2.5.0",
"@swup/astro": "^1.3.2",
"@types/react": "^18.2.29",
"@types/react-dom": "^18.2.14",
"medium-zoom": "^1.0.8",
"medium-zoom": "^1.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"reading-time": "^1.5.0"
Expand Down
32 changes: 32 additions & 0 deletions plugins/remark-code-set/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@lucjosin/remark-code-set",
"version": "1.0.0",
"type": "module",
"author": {
"name": "Lucas Josino",
"username": "LucJosin",
"email": "contact@lucasjosino.com",
"url": "https://lucasjosino.com"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"homepage": "https://github.com/LucJosin/lucasjosino.com",
"bugs": {
"url": "https://github.com/LucJosin/lucasjosino.com",
"email": "hawapi@lucasjosino.com"
},
"license": "MIT",
"keywords": [
"remark-plugin",
"remark-code-set"
],
"main": "src/index.js",
"dependencies": {
"hastscript": "^8.0.0",
"remark": "^15.0.1",
"unist-util-is": "^6.0.0",
"unist-util-visit": "^5.0.0"
}
}
72 changes: 72 additions & 0 deletions plugins/remark-code-set/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { parse } from 'node:querystring';
import { remark } from 'remark';
import { visit } from 'unist-util-visit';

const metaDelimiter = ' ';

function createTabs(tabs, children) {
return {
type: 'wrapper',
data: {
hName: 'div',
hProperties: {
id: tabs,
className: 'remark-code-tabs',
},
},
children: children,
};
}

function createTab(childNode, group, index) {
const tabId = `${group}#${index}`;
const code = remark().parse(childNode).children[0];
const meta = parse(code.meta ?? '', metaDelimiter);

return [
{
type: 'html',
value: `<label for="${tabId}" class="remark-code-tab">
<input
type="radio"
id=${tabId}
name="${group}"
${index === 0 ? 'checked' : ''}/>
<span>${meta.label}</span>
</label>`,
},
{
type: 'wrapper',
data: {
hName: 'div',
hProperties: {
className: 'remark-code-content',
},
},
children: [code],
},
];
}

export default function remarkCodeTabs() {
return function transform(tree) {
visit(tree, 'code', function (node) {
if (node.lang !== 'codeset') return;

const meta = parse(node.meta ?? '', metaDelimiter);
if (!meta.tabs) return;

const codeList = node.value.split(':-:');

const tabs = [];
for (let i = 0; i < codeList.length; i++) {
tabs.push(...createTab(codeList[i], meta.tabs, i));
}

// Create wrapper
const newNode = createTabs(meta.tabs, [...tabs]);

Object.assign(node, newNode);
});
};
}
Loading