Skip to content

Instantly share code, notes, and snippets.

View tsuki-lab's full-sized avatar
🏠
Working from home

hanetsuki tsuki-lab

🏠
Working from home
View GitHub Profile
@tsuki-lab
tsuki-lab / index.ts
Created June 13, 2023 23:15
playwrightを用いたmicroCMSへのデータ移行オートメーション試作
import { chromium } from 'playwright';
import dotenv from 'dotenv-flow';
import axios from 'axios';
dotenv.config();
const MICROCMS_SERVICE_ID = process.env.MICROCMS_SERVICE_ID;
const MICROCMS_API_KEY = process.env.MICROCMS_API_KEY;
type FieldValue = {
@tsuki-lab
tsuki-lab / _document.tsx
Last active May 23, 2022 08:14
Google Tag Manager setting to Next.js
import Document, { Html, Head, Main, NextScript } from 'next/document'
const GTM_ID = process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID || ''
export default class MyDocument extends Document {
public render() {
return (
<Html lang="ja">
<Head>
{/* Google Tag Manager - Global base code */}
@tsuki-lab
tsuki-lab / pagePaths.ts
Last active May 20, 2022 00:18
pathpidaをリスペクト
const root = '/'
const blogs = '/blogs'
const page = '/page'
export const pagesPath = {
$url: () => `${root}`,
blogs: {
$url: () => `${blogs}/`,
@tsuki-lab
tsuki-lab / index.md
Last active May 14, 2022 11:24
Sample workflow when deploying to GitHub Pages.

Deploy workflows to GitHub Pages

Sample workflow when deploying to GitHub Pages.

Dependencies

  • pnpm v7.0.0

Feature

@tsuki-lab
tsuki-lab / colors.variable.ts
Last active May 11, 2022 02:02
カラーコードを管理するための手法切り取り
import { constColorsToColorObject } from './utils'
export const colors = constColorsToColorObject({
/* 本文テキスト */
body: '#333333',
/* プライマリー */
primary: '#529fff',
/* セカンダリー */
secondary: '#3d3dff',
/* エラー */
@tsuki-lab
tsuki-lab / getAllContents.js
Last active June 8, 2023 10:40
microCMSで全件取得する
const client = createClient({
serviceDomain: process.env.MICROCMS_DOMAIN,
apiKey: process.env.API_KEY
})
const getAllContents = async (offset=0, limit=10) => {
const data = await client.get({
endpoint: `{MICROCMS_ENDPOINT}`,
queries: {
offset,
@tsuki-lab
tsuki-lab / createFileNodeForFeedImage.js
Last active July 27, 2021 02:21
[Gatsby.js]RSS情報を元にFeed画像を取得してnodeに詰める。
const { createRemoteFileNode } = require(`gatsby-source-filesystem`);
const axios = require('axios')
const { JSDOM } = require('jsdom')
/**
* Feedのurl情報からOGP画像を取得してファイルノードを作成する
*
* @param {*} { actions: { createNode, createNodeField }, createNodeId, cache, store, getNodes }
*/
async function createFileNodeForFeedImage({ actions: { createNode, createNodeField }, createNodeId, cache, store, getNodes }) {